Re: [RFC PATCH] vhost: cache avail index in vhost_enable_notify()

From: Michael S. Tsirkin
Date: Thu Jan 13 2022 - 11:05:57 EST


On Thu, Jan 13, 2022 at 04:44:47PM +0100, Stefano Garzarella wrote:
> On Thu, Jan 13, 2022 at 10:19:46AM -0500, Michael S. Tsirkin wrote:
> > On Thu, Jan 13, 2022 at 03:56:42PM +0100, Stefano Garzarella wrote:
> > > In vhost_enable_notify() we enable the notifications and we read
> > > the avail index to check if new buffers have become available in
> > > the meantime. In this case, the device would go to re-read avail
> > > index to access the descriptor.
> > >
> > > As we already do in other place, we can cache the value in `avail_idx`
> > > and compare it with `last_avail_idx` to check if there are new
> > > buffers available.
> > >
> > > Signed-off-by: Stefano Garzarella <sgarzare@xxxxxxxxxx>
> >
> > I guess we can ... but what's the point?
> >
>
> That without this patch if avail index is new, then device when will call
> vhost_get_vq_desc() will find old value in cache and will read it again.
>
> With this patch we also do the same path and update the cache every time we
> read avail index.
>
> I marked it RFC because I don't know if it's worth it :-)
>
> Stefano

Pls include info like this in commit log. Thanks!

--
MST