Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mshv: clear eventfd counter on irqfd shutdown

While unhooking from the irqfd waitqueue, clear the internal eventfd
counter by using eventfd_ctx_remove_wait_queue() instead of
remove_wait_queue(), preventing potential spurious interrupts. This
removes the need to store a pointer into the workqueue, as the eventfd
already keeps track of it.

This mimicks what other similar subsystems do on their equivalent paths
with their irqfds (KVM, Xen, ACRN support, etc).

Signed-off-by: Carlos López <clopez@suse.de>
Signed-off-by: Wei Liu <wei.liu@kernel.org>

authored by

Carlos López and committed by
Wei Liu
2b424615 5ed8cbca

+2 -4
+2 -3
drivers/hv/mshv_eventfd.c
··· 247 247 { 248 248 struct mshv_irqfd *irqfd = 249 249 container_of(work, struct mshv_irqfd, irqfd_shutdown); 250 + u64 cnt; 250 251 251 252 /* 252 253 * Synchronize with the wait-queue and unhook ourselves to prevent 253 254 * further events. 254 255 */ 255 - remove_wait_queue(irqfd->irqfd_wqh, &irqfd->irqfd_wait); 256 + eventfd_ctx_remove_wait_queue(irqfd->irqfd_eventfd_ctx, &irqfd->irqfd_wait, &cnt); 256 257 257 258 if (irqfd->irqfd_resampler) { 258 259 mshv_irqfd_resampler_shutdown(irqfd); ··· 371 370 { 372 371 struct mshv_irqfd *irqfd = 373 372 container_of(polltbl, struct mshv_irqfd, irqfd_polltbl); 374 - 375 - irqfd->irqfd_wqh = wqh; 376 373 377 374 /* 378 375 * TODO: Ensure there isn't already an exclusive, priority waiter, e.g.
-1
drivers/hv/mshv_eventfd.h
··· 32 32 struct mshv_lapic_irq irqfd_lapic_irq; 33 33 struct hlist_node irqfd_hnode; 34 34 poll_table irqfd_polltbl; 35 - wait_queue_head_t *irqfd_wqh; 36 35 wait_queue_entry_t irqfd_wait; 37 36 struct work_struct irqfd_shutdown; 38 37 struct mshv_irqfd_resampler *irqfd_resampler;