2018-02-13 17:35:44

by Stephen Hemminger

[permalink] [raw]
Subject: Re: [PATCH char-misc 1/1] Drivers: hv: vmbus: Fix ring buffer signaling


> if (rbi->ring_buffer->feature_bits.feat_pending_send_sz) {
> u32 pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
>
> /*
> + * Ensure the read of write_index in hv_get_bytes_to_write()
> + * happens after the read of pending_send_sz.
> + */
> + virt_rmb();
> + curr_write_sz = hv_get_bytes_to_write(rbi);
> +
> + /*
> * If there was space before we began iteration,
> * then host was not blocked. Also handles case where
> * pending_sz is zero then host has nothing pending
> * and does not need to be signaled.
> */
> - if (orig_write_sz > pending_sz)
> + if (curr_write_sz - delta > pending_sz)
> return;
>
> /* If pending write will not fit, don't give false hope. */
> - if (hv_get_bytes_to_write(rbi) < pending_sz)
> + if (curr_write_sz <= pending_sz)
> return;
> +
> + vmbus_setevent(channel);
> }
>
> - vmbus_setevent(channel);
> }

I think this won't work on older versions of Windows where feat_pending_sz
is never set. On those versions vmbus_setevent needs to always be called.


2018-02-14 02:13:15

by Michael Kelley (EOSG)

[permalink] [raw]
Subject: RE: [PATCH char-misc 1/1] Drivers: hv: vmbus: Fix ring buffer signaling

> -----Original Message-----
> From: Stephen Hemminger <[email protected]>
> Sent: Tuesday, February 13, 2018 9:35 AM
> To: Michael Kelley <[email protected]>
> Cc: Michael Kelley (EOSG) <[email protected]>; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; Stephen Hemminger
> <[email protected]>; KY Srinivasan <[email protected]>
> Subject: Re: [PATCH char-misc 1/1] Drivers: hv: vmbus: Fix ring buffer signaling
>
>
> > if (rbi->ring_buffer->feature_bits.feat_pending_send_sz) {
> > u32 pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz);
> >
> > /*
> > + * Ensure the read of write_index in hv_get_bytes_to_write()
> > + * happens after the read of pending_send_sz.
> > + */
> > + virt_rmb();
> > + curr_write_sz = hv_get_bytes_to_write(rbi);
> > +
> > + /*
> > * If there was space before we began iteration,
> > * then host was not blocked. Also handles case where
> > * pending_sz is zero then host has nothing pending
> > * and does not need to be signaled.
> > */
> > - if (orig_write_sz > pending_sz)
> > + if (curr_write_sz - delta > pending_sz)
> > return;
> >
> > /* If pending write will not fit, don't give false hope. */
> > - if (hv_get_bytes_to_write(rbi) < pending_sz)
> > + if (curr_write_sz <= pending_sz)
> > return;
> > +
> > + vmbus_setevent(channel);
> > }
> >
> > - vmbus_setevent(channel);
> > }
>
> I think this won't work on older versions of Windows where feat_pending_sz
> is never set. On those versions vmbus_setevent needs to always be called.

The older Windows/Hyper-V hosts poll if they can't write to the
host->guest ring buffer because it is full. We don't want to call
vmbus_setevent() every time through this routine because then
the guest would be signaling the host every time the host interrupts
the guest.

Michael