Messages in this thread | | | From | Michael Kelley <> | Subject | RE: [PATCH 06/11] Drivers: hv: vmbus: Use a spin lock for synchronizing channel scheduling vs. channel removal | Date | Fri, 10 Apr 2020 19:28:44 +0000 |
| |
From: Andrea Parri (Microsoft) <parri.andrea@gmail.com> Sent: Sunday, April 5, 2020 5:15 PM > > Since vmbus_chan_sched() dereferences the ring buffer pointer, we have > to make sure that the ring buffer data structures don't get freed while > such dereferencing is happening. Current code does this by sending an > IPI to the CPU that is allowed to access that ring buffer from interrupt > level, cf., vmbus_reset_channel_cb(). But with the new functionality > to allow changing the CPU that a channel will interrupt, we can't be > sure what CPU will be running the vmbus_chan_sched() function for a > particular channel, so the current IPI mechanism is infeasible. > > Instead synchronize vmbus_chan_sched() and vmbus_reset_channel_cb() by > using the (newly introduced) per-channel spin lock "sched_lock". Move > the test for onchannel_callback being NULL before the "switch" control > statement in vmbus_chan_sched(), in order to not access the ring buffer > if the vmbus_reset_channel_cb() has been completed on the channel. > > Suggested-by: Michael Kelley <mikelley@microsoft.com> > Signed-off-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com> > --- > drivers/hv/channel.c | 24 +++++++----------------- > drivers/hv/channel_mgmt.c | 1 + > drivers/hv/vmbus_drv.c | 30 +++++++++++++++++------------- > include/linux/hyperv.h | 6 ++++++ > 4 files changed, 31 insertions(+), 30 deletions(-) >
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
| |