From: "Michael S. Tsirkin" <mst@redhat.com>
To: Ladi Prosek <lprosek@redhat.com>
Cc: kvm@vger.kernel.org, Yan Vugenfirer <yvugenfi@redhat.com>,
virtio-dev@lists.oasis-open.org
Subject: Re: [PATCH] virtio_ring: Make interrupt suppression spec compliant
Date: Mon, 22 Aug 2016 17:26:30 +0300 [thread overview]
Message-ID: <20160822171746-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1465206694-1150-1-git-send-email-lprosek@redhat.com>
On Mon, Jun 06, 2016 at 11:51:34AM +0200, Ladi Prosek wrote:
> According to the spec, if the VIRTIO_RING_F_EVENT_IDX feature bit is
> negotiated the driver MUST set flags to 0. Not dirtying the available
> ring in virtqueue_disable_cb may also have a positive performance impact.
>
> Writes to the used event field (vring_used_event) are still unconditional.
>
> Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Write it to match Linux coding style please:
if (!vq->event)
vq->vring.avail->flags = cpu_to_virtio16(_vq->vdev, vq->avail_flags_shadow);
Also, please Cc stable as this is a spec compliance issue.
Looks like older Linux guests will have to cherry-pick
virtio_ring: shadow available ring flags & index
to fix this. Pls mention this when you resubmit.
And pls Cc virtio lists as per MAINTAINERS.
We should also list this as one of the differences between
virtio 1.0 and 0.9.X.
Also Cc windows driver devs to make sure windows drivers do not
have spec issues.
> ---
> drivers/virtio/virtio_ring.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index ca6bfdd..d6345e1 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -718,7 +718,9 @@ void virtqueue_disable_cb(struct virtqueue *_vq)
>
> if (!(vq->avail_flags_shadow & VRING_AVAIL_F_NO_INTERRUPT)) {
> vq->avail_flags_shadow |= VRING_AVAIL_F_NO_INTERRUPT;
> - vq->vring.avail->flags = cpu_to_virtio16(_vq->vdev, vq->avail_flags_shadow);
> + if (!vq->event) {
> + vq->vring.avail->flags = cpu_to_virtio16(_vq->vdev, vq->avail_flags_shadow);
> + }
> }
>
> }
> @@ -750,7 +752,9 @@ unsigned virtqueue_enable_cb_prepare(struct virtqueue *_vq)
> * entry. Always do both to keep code simple. */
> if (vq->avail_flags_shadow & VRING_AVAIL_F_NO_INTERRUPT) {
> vq->avail_flags_shadow &= ~VRING_AVAIL_F_NO_INTERRUPT;
> - vq->vring.avail->flags = cpu_to_virtio16(_vq->vdev, vq->avail_flags_shadow);
> + if (!vq->event) {
> + vq->vring.avail->flags = cpu_to_virtio16(_vq->vdev, vq->avail_flags_shadow);
> + }
> }
> vring_used_event(&vq->vring) = cpu_to_virtio16(_vq->vdev, last_used_idx = vq->last_used_idx);
> END_USE(vq);
> @@ -818,10 +822,12 @@ bool virtqueue_enable_cb_delayed(struct virtqueue *_vq)
> * more to do. */
> /* Depending on the VIRTIO_RING_F_USED_EVENT_IDX feature, we need to
> * either clear the flags bit or point the event index at the next
> - * entry. Always do both to keep code simple. */
> + * entry. Always update the event index to keep code simple. */
> if (vq->avail_flags_shadow & VRING_AVAIL_F_NO_INTERRUPT) {
> vq->avail_flags_shadow &= ~VRING_AVAIL_F_NO_INTERRUPT;
> - vq->vring.avail->flags = cpu_to_virtio16(_vq->vdev, vq->avail_flags_shadow);
> + if (!vq->event) {
> + vq->vring.avail->flags = cpu_to_virtio16(_vq->vdev, vq->avail_flags_shadow);
> + }
> }
> /* TODO: tune this threshold */
> bufs = (u16)(vq->avail_idx_shadow - vq->last_used_idx) * 3 / 4;
> @@ -939,7 +945,9 @@ struct virtqueue *__vring_new_virtqueue(unsigned int index,
> /* No callback? Tell other side not to bother us. */
> if (!callback) {
> vq->avail_flags_shadow |= VRING_AVAIL_F_NO_INTERRUPT;
> - vq->vring.avail->flags = cpu_to_virtio16(vdev, vq->avail_flags_shadow);
> + if (!vq->event) {
> + vq->vring.avail->flags = cpu_to_virtio16(vdev, vq->avail_flags_shadow);
> + }
> }
>
> /* Put everything in free lists. */
> --
> 2.5.5
next prev parent reply other threads:[~2016-08-22 14:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 9:51 [PATCH] virtio_ring: Make interrupt suppression spec compliant Ladi Prosek
2016-06-06 13:55 ` Michael S. Tsirkin
2016-06-06 14:35 ` Paolo Bonzini
2016-06-06 21:31 ` Ladi Prosek
2016-06-08 12:58 ` Ladi Prosek
2016-08-22 14:29 ` Michael S. Tsirkin
2016-08-30 14:26 ` Ladi Prosek
2016-08-22 14:26 ` Michael S. Tsirkin [this message]
2016-08-30 14:25 ` Ladi Prosek
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=20160822171746-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lprosek@redhat.com \
--cc=virtio-dev@lists.oasis-open.org \
--cc=yvugenfi@redhat.com \
/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