From: Stefano Garzarella <sgarzare@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: virtualization <virtualization@lists.linux-foundation.org>,
netdev <netdev@vger.kernel.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
kvm <kvm@vger.kernel.org>, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [RFC PATCH] vhost: cache avail index in vhost_enable_notify()
Date: Fri, 14 Jan 2022 09:02:05 +0100 [thread overview]
Message-ID: <20220114080205.ls4txgj7qbqmc3q5@steredhat> (raw)
In-Reply-To: <CACGkMEsqY5RHL=9=iny6xRVs_=EdACUCfX-Rmpq+itpdoT_rrg@mail.gmail.com>
On Fri, Jan 14, 2022 at 02:18:01PM +0800, Jason Wang wrote:
>On Thu, Jan 13, 2022 at 10:57 PM Stefano Garzarella <sgarzare@redhat.com> 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@redhat.com>
>
>Patch looks fine but I guess we won't get performance improvement
>since it doesn't save any userspace/VM memory access?
It should save the memory access when vhost_enable_notify() find
something new in the VQ, so in this path:
vhost_enable_notify() <- VM memory access for avail index
== true
vhost_disable_notify()
...
vhost_get_vq_desc() <- VM memory access for avail index
with the patch applied, this access is
avoided since avail index is cached
In any case, I don't expect this to be a very common path, indeed we
usually use unlikely() for this path:
if (unlikely(vhost_enable_notify(dev, vq))) {
vhost_disable_notify(dev, vq);
continue;
}
So I don't expect a significant performance increase.
v1 coming with a better commit description.
Thanks,
Stefano
prev parent reply other threads:[~2022-01-14 8:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-13 14:56 [RFC PATCH] vhost: cache avail index in vhost_enable_notify() Stefano Garzarella
2022-01-13 15:19 ` Michael S. Tsirkin
2022-01-13 15:44 ` Stefano Garzarella
2022-01-13 16:05 ` Michael S. Tsirkin
2022-01-14 6:18 ` Jason Wang
2022-01-14 8:02 ` Stefano Garzarella [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220114080205.ls4txgj7qbqmc3q5@steredhat \
--to=sgarzare@redhat.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox