Skip to content

Commit 5c73b9a

Browse files
a-darwishPeter Zijlstra
authored andcommitted
kvm/eventfd: Use sequence counter with associated spinlock
A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Paolo Bonzini <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 2ca97ac commit 5c73b9a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/linux/kvm_irqfd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct kvm_kernel_irqfd {
4242
wait_queue_entry_t wait;
4343
/* Update side is protected by irqfds.lock */
4444
struct kvm_kernel_irq_routing_entry irq_entry;
45-
seqcount_t irq_entry_sc;
45+
seqcount_spinlock_t irq_entry_sc;
4646
/* Used for level IRQ fast-path */
4747
int gsi;
4848
struct work_struct inject;

virt/kvm/eventfd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
303303
INIT_LIST_HEAD(&irqfd->list);
304304
INIT_WORK(&irqfd->inject, irqfd_inject);
305305
INIT_WORK(&irqfd->shutdown, irqfd_shutdown);
306-
seqcount_init(&irqfd->irq_entry_sc);
306+
seqcount_spinlock_init(&irqfd->irq_entry_sc, &kvm->irqfds.lock);
307307

308308
f = fdget(args->fd);
309309
if (!f.file) {

0 commit comments

Comments
 (0)