* RE: [Patch v3] uio_hv_generic: Set event for all channels on the device
2025-03-10 22:12 [Patch v3] uio_hv_generic: Set event for all channels on the device longli
@ 2025-03-11 3:47 ` Michael Kelley
2025-03-11 4:12 ` Saurabh Singh Sengar
2025-03-25 16:10 ` Wei Liu
2 siblings, 0 replies; 6+ messages in thread
From: Michael Kelley @ 2025-03-11 3:47 UTC (permalink / raw)
To: longli@linuxonhyperv.com, K. Y. Srinivasan, Haiyang Zhang,
Wei Liu, Dexuan Cui, Greg Kroah-Hartman,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Long Li
From: longli@linuxonhyperv.com <longli@linuxonhyperv.com> Sent: Monday, March 10, 2025 3:12 PM
>
> Hyper-V may offer a non latency sensitive device with subchannels without
> monitor bit enabled. The decision is entirely on the Hyper-V host not
> configurable within guest.
>
> When a device has subchannels, also signal events for the subchannel
> if its monitor bit is disabled.
>
> This patch also removes the memory barrier when monitor bit is enabled
> as it is not necessary. The memory barrier is only needed between
> setting up interrupt mask and calling vmbus_set_event() when monitor
> bit is disabled.
>
> Signed-off-by: Long Li <longli@microsoft.com>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
> ---
> Change log
> v2: Use vmbus_set_event() to avoid additional check on monitored bit
> Lock vmbus_connection.channel_mutex when going through subchannels
> v3: Add details in commit messsage on the memory barrier.
>
> drivers/uio/uio_hv_generic.c | 32 ++++++++++++++++++++++++++------
> 1 file changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
> index 3976360d0096..45be2f8baade 100644
> --- a/drivers/uio/uio_hv_generic.c
> +++ b/drivers/uio/uio_hv_generic.c
> @@ -65,6 +65,16 @@ struct hv_uio_private_data {
> char send_name[32];
> };
>
> +static void set_event(struct vmbus_channel *channel, s32 irq_state)
> +{
> + channel->inbound.ring_buffer->interrupt_mask = !irq_state;
> + if (!channel->offermsg.monitor_allocated && irq_state) {
> + /* MB is needed for host to see the interrupt mask first */
> + virt_mb();
> + vmbus_set_event(channel);
> + }
> +}
> +
> /*
> * This is the irqcontrol callback to be registered to uio_info.
> * It can be used to disable/enable interrupt from user space processes.
> @@ -79,12 +89,15 @@ hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
> {
> struct hv_uio_private_data *pdata = info->priv;
> struct hv_device *dev = pdata->device;
> + struct vmbus_channel *primary, *sc;
>
> - dev->channel->inbound.ring_buffer->interrupt_mask = !irq_state;
> - virt_mb();
> + primary = dev->channel;
> + set_event(primary, irq_state);
>
> - if (!dev->channel->offermsg.monitor_allocated && irq_state)
> - vmbus_setevent(dev->channel);
> + mutex_lock(&vmbus_connection.channel_mutex);
> + list_for_each_entry(sc, &primary->sc_list, sc_list)
> + set_event(sc, irq_state);
> + mutex_unlock(&vmbus_connection.channel_mutex);
>
> return 0;
> }
> @@ -95,12 +108,19 @@ hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
> static void hv_uio_channel_cb(void *context)
> {
> struct vmbus_channel *chan = context;
> - struct hv_device *hv_dev = chan->device_obj;
> - struct hv_uio_private_data *pdata = hv_get_drvdata(hv_dev);
> + struct hv_device *hv_dev;
> + struct hv_uio_private_data *pdata;
>
> chan->inbound.ring_buffer->interrupt_mask = 1;
> virt_mb();
>
> + /*
> + * The callback may come from a subchannel, in which case look
> + * for the hv device in the primary channel
> + */
> + hv_dev = chan->primary_channel ?
> + chan->primary_channel->device_obj : chan->device_obj;
> + pdata = hv_get_drvdata(hv_dev);
> uio_event_notify(&pdata->info);
> }
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Patch v3] uio_hv_generic: Set event for all channels on the device
2025-03-10 22:12 [Patch v3] uio_hv_generic: Set event for all channels on the device longli
2025-03-11 3:47 ` Michael Kelley
@ 2025-03-11 4:12 ` Saurabh Singh Sengar
2025-03-25 16:10 ` Wei Liu
2 siblings, 0 replies; 6+ messages in thread
From: Saurabh Singh Sengar @ 2025-03-11 4:12 UTC (permalink / raw)
To: longli
Cc: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui,
Greg Kroah-Hartman, linux-hyperv, linux-kernel, Long Li
On Mon, Mar 10, 2025 at 03:12:01PM -0700, longli@linuxonhyperv.com wrote:
> From: Long Li <longli@microsoft.com>
>
> Hyper-V may offer a non latency sensitive device with subchannels without
> monitor bit enabled. The decision is entirely on the Hyper-V host not
> configurable within guest.
>
> When a device has subchannels, also signal events for the subchannel
> if its monitor bit is disabled.
>
> This patch also removes the memory barrier when monitor bit is enabled
> as it is not necessary. The memory barrier is only needed between
> setting up interrupt mask and calling vmbus_set_event() when monitor
> bit is disabled.
>
> Signed-off-by: Long Li <longli@microsoft.com>
> ---
> Change log
> v2: Use vmbus_set_event() to avoid additional check on monitored bit
> Lock vmbus_connection.channel_mutex when going through subchannels
> v3: Add details in commit messsage on the memory barrier.
>
> drivers/uio/uio_hv_generic.c | 32 ++++++++++++++++++++++++++------
> 1 file changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
> index 3976360d0096..45be2f8baade 100644
> --- a/drivers/uio/uio_hv_generic.c
> +++ b/drivers/uio/uio_hv_generic.c
> @@ -65,6 +65,16 @@ struct hv_uio_private_data {
> char send_name[32];
> };
>
> +static void set_event(struct vmbus_channel *channel, s32 irq_state)
> +{
> + channel->inbound.ring_buffer->interrupt_mask = !irq_state;
> + if (!channel->offermsg.monitor_allocated && irq_state) {
> + /* MB is needed for host to see the interrupt mask first */
> + virt_mb();
> + vmbus_set_event(channel);
> + }
> +}
> +
> /*
> * This is the irqcontrol callback to be registered to uio_info.
> * It can be used to disable/enable interrupt from user space processes.
> @@ -79,12 +89,15 @@ hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
> {
> struct hv_uio_private_data *pdata = info->priv;
> struct hv_device *dev = pdata->device;
> + struct vmbus_channel *primary, *sc;
>
> - dev->channel->inbound.ring_buffer->interrupt_mask = !irq_state;
> - virt_mb();
> + primary = dev->channel;
> + set_event(primary, irq_state);
>
> - if (!dev->channel->offermsg.monitor_allocated && irq_state)
> - vmbus_setevent(dev->channel);
> + mutex_lock(&vmbus_connection.channel_mutex);
> + list_for_each_entry(sc, &primary->sc_list, sc_list)
> + set_event(sc, irq_state);
> + mutex_unlock(&vmbus_connection.channel_mutex);
>
> return 0;
> }
> @@ -95,12 +108,19 @@ hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
> static void hv_uio_channel_cb(void *context)
> {
> struct vmbus_channel *chan = context;
> - struct hv_device *hv_dev = chan->device_obj;
> - struct hv_uio_private_data *pdata = hv_get_drvdata(hv_dev);
> + struct hv_device *hv_dev;
> + struct hv_uio_private_data *pdata;
>
> chan->inbound.ring_buffer->interrupt_mask = 1;
> virt_mb();
>
> + /*
> + * The callback may come from a subchannel, in which case look
> + * for the hv device in the primary channel
> + */
> + hv_dev = chan->primary_channel ?
> + chan->primary_channel->device_obj : chan->device_obj;
> + pdata = hv_get_drvdata(hv_dev);
> uio_event_notify(&pdata->info);
> }
>
> --
> 2.34.1
>
Reviewed-by: Saurabh Sengar <ssengar@linux.microsoft.com>
- Saurabh
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Patch v3] uio_hv_generic: Set event for all channels on the device
2025-03-10 22:12 [Patch v3] uio_hv_generic: Set event for all channels on the device longli
2025-03-11 3:47 ` Michael Kelley
2025-03-11 4:12 ` Saurabh Singh Sengar
@ 2025-03-25 16:10 ` Wei Liu
2025-03-25 16:39 ` Greg Kroah-Hartman
2 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2025-03-25 16:10 UTC (permalink / raw)
To: longli
Cc: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui,
Greg Kroah-Hartman, linux-hyperv, linux-kernel, Long Li
On Mon, Mar 10, 2025 at 03:12:01PM -0700, longli@linuxonhyperv.com wrote:
> From: Long Li <longli@microsoft.com>
>
> Hyper-V may offer a non latency sensitive device with subchannels without
> monitor bit enabled. The decision is entirely on the Hyper-V host not
> configurable within guest.
>
> When a device has subchannels, also signal events for the subchannel
> if its monitor bit is disabled.
>
> This patch also removes the memory barrier when monitor bit is enabled
> as it is not necessary. The memory barrier is only needed between
> setting up interrupt mask and calling vmbus_set_event() when monitor
> bit is disabled.
>
> Signed-off-by: Long Li <longli@microsoft.com>
Greg, are you going to take this patch?
I can take it if you want.
Thanks,
Wei.
> ---
> Change log
> v2: Use vmbus_set_event() to avoid additional check on monitored bit
> Lock vmbus_connection.channel_mutex when going through subchannels
> v3: Add details in commit messsage on the memory barrier.
>
> drivers/uio/uio_hv_generic.c | 32 ++++++++++++++++++++++++++------
> 1 file changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
> index 3976360d0096..45be2f8baade 100644
> --- a/drivers/uio/uio_hv_generic.c
> +++ b/drivers/uio/uio_hv_generic.c
> @@ -65,6 +65,16 @@ struct hv_uio_private_data {
> char send_name[32];
> };
>
> +static void set_event(struct vmbus_channel *channel, s32 irq_state)
> +{
> + channel->inbound.ring_buffer->interrupt_mask = !irq_state;
> + if (!channel->offermsg.monitor_allocated && irq_state) {
> + /* MB is needed for host to see the interrupt mask first */
> + virt_mb();
> + vmbus_set_event(channel);
> + }
> +}
> +
> /*
> * This is the irqcontrol callback to be registered to uio_info.
> * It can be used to disable/enable interrupt from user space processes.
> @@ -79,12 +89,15 @@ hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
> {
> struct hv_uio_private_data *pdata = info->priv;
> struct hv_device *dev = pdata->device;
> + struct vmbus_channel *primary, *sc;
>
> - dev->channel->inbound.ring_buffer->interrupt_mask = !irq_state;
> - virt_mb();
> + primary = dev->channel;
> + set_event(primary, irq_state);
>
> - if (!dev->channel->offermsg.monitor_allocated && irq_state)
> - vmbus_setevent(dev->channel);
> + mutex_lock(&vmbus_connection.channel_mutex);
> + list_for_each_entry(sc, &primary->sc_list, sc_list)
> + set_event(sc, irq_state);
> + mutex_unlock(&vmbus_connection.channel_mutex);
>
> return 0;
> }
> @@ -95,12 +108,19 @@ hv_uio_irqcontrol(struct uio_info *info, s32 irq_state)
> static void hv_uio_channel_cb(void *context)
> {
> struct vmbus_channel *chan = context;
> - struct hv_device *hv_dev = chan->device_obj;
> - struct hv_uio_private_data *pdata = hv_get_drvdata(hv_dev);
> + struct hv_device *hv_dev;
> + struct hv_uio_private_data *pdata;
>
> chan->inbound.ring_buffer->interrupt_mask = 1;
> virt_mb();
>
> + /*
> + * The callback may come from a subchannel, in which case look
> + * for the hv device in the primary channel
> + */
> + hv_dev = chan->primary_channel ?
> + chan->primary_channel->device_obj : chan->device_obj;
> + pdata = hv_get_drvdata(hv_dev);
> uio_event_notify(&pdata->info);
> }
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Patch v3] uio_hv_generic: Set event for all channels on the device
2025-03-25 16:10 ` Wei Liu
@ 2025-03-25 16:39 ` Greg Kroah-Hartman
2025-03-25 17:59 ` Wei Liu
0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2025-03-25 16:39 UTC (permalink / raw)
To: Wei Liu
Cc: longli, K. Y. Srinivasan, Haiyang Zhang, Dexuan Cui, linux-hyperv,
linux-kernel, Long Li
On Tue, Mar 25, 2025 at 04:10:59PM +0000, Wei Liu wrote:
> On Mon, Mar 10, 2025 at 03:12:01PM -0700, longli@linuxonhyperv.com wrote:
> > From: Long Li <longli@microsoft.com>
> >
> > Hyper-V may offer a non latency sensitive device with subchannels without
> > monitor bit enabled. The decision is entirely on the Hyper-V host not
> > configurable within guest.
> >
> > When a device has subchannels, also signal events for the subchannel
> > if its monitor bit is disabled.
> >
> > This patch also removes the memory barrier when monitor bit is enabled
> > as it is not necessary. The memory barrier is only needed between
> > setting up interrupt mask and calling vmbus_set_event() when monitor
> > bit is disabled.
> >
> > Signed-off-by: Long Li <longli@microsoft.com>
>
> Greg, are you going to take this patch?
>
> I can take it if you want.
It's the merge window right now, neither of us should be taking it. Let
me look into it after -rc1 is out.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch v3] uio_hv_generic: Set event for all channels on the device
2025-03-25 16:39 ` Greg Kroah-Hartman
@ 2025-03-25 17:59 ` Wei Liu
0 siblings, 0 replies; 6+ messages in thread
From: Wei Liu @ 2025-03-25 17:59 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Wei Liu, longli, K. Y. Srinivasan, Haiyang Zhang, Dexuan Cui,
linux-hyperv, linux-kernel, Long Li
On Tue, Mar 25, 2025 at 12:39:54PM -0400, Greg Kroah-Hartman wrote:
> On Tue, Mar 25, 2025 at 04:10:59PM +0000, Wei Liu wrote:
> > On Mon, Mar 10, 2025 at 03:12:01PM -0700, longli@linuxonhyperv.com wrote:
> > > From: Long Li <longli@microsoft.com>
> > >
> > > Hyper-V may offer a non latency sensitive device with subchannels without
> > > monitor bit enabled. The decision is entirely on the Hyper-V host not
> > > configurable within guest.
> > >
> > > When a device has subchannels, also signal events for the subchannel
> > > if its monitor bit is disabled.
> > >
> > > This patch also removes the memory barrier when monitor bit is enabled
> > > as it is not necessary. The memory barrier is only needed between
> > > setting up interrupt mask and calling vmbus_set_event() when monitor
> > > bit is disabled.
> > >
> > > Signed-off-by: Long Li <longli@microsoft.com>
> >
> > Greg, are you going to take this patch?
> >
> > I can take it if you want.
>
> It's the merge window right now, neither of us should be taking it. Let
> me look into it after -rc1 is out.
Understood. Thank you for your response.
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread