All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linhaifeng <haifeng.lin-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Huawei Xie <huawei.xie-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	<dev-VfR2kkLFssw@public.gmane.org>
Cc: mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH] vhost: flush used->idx update before reading avail->flags
Date: Fri, 24 Apr 2015 09:01:15 +0800	[thread overview]
Message-ID: <553995DB.4000801@huawei.com> (raw)
In-Reply-To: <1429720392-25345-1-git-send-email-huawei.xie-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>



On 2015/4/23 0:33, Huawei Xie wrote:
> update of used->idx and read of avail->flags could be reordered.
> memory fence should be used to ensure the order, otherwise guest could see a stale used->idx value after it toggles the interrupt suppression flag.
> 
> Signed-off-by: Huawei Xie <huawei.xie-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
>  lib/librte_vhost/vhost_rxtx.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
> index 510ffe8..6afba35 100644
> --- a/lib/librte_vhost/vhost_rxtx.c
> +++ b/lib/librte_vhost/vhost_rxtx.c
> @@ -178,6 +178,9 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
>  	*(volatile uint16_t *)&vq->used->idx += count;
>  	vq->last_used_idx = res_end_idx;
>  
> +	/* flush used->idx update before we read avail->flags. */
> +	rte_mb();
> +
>  	/* Kick the guest if necessary. */
>  	if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT))
>  		eventfd_write((int)vq->callfd, 1);
> 

If not add memory fence what would happen? Packets loss or interrupt loss?How to test it ?

  parent reply	other threads:[~2015-04-24  1:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22 16:33 [PATCH] vhost: flush used->idx update before reading avail->flags Huawei Xie
     [not found] ` <1429720392-25345-1-git-send-email-huawei.xie-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-04-23 13:57   ` Luke Gorrie
2015-04-24  1:01   ` Linhaifeng [this message]
     [not found]     ` <553995DB.4000801-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2015-04-24  2:40       ` Xie, Huawei
2015-04-24  7:27       ` Luke Gorrie
2015-06-09  7:04         ` Linhaifeng
2015-06-09  7:45           ` Luke Gorrie
2015-06-09  8:46           ` Michael S. Tsirkin
2015-06-09 13:34             ` Xie, Huawei
2015-06-10  2:36               ` Linhaifeng
2015-06-10  8:30             ` Luke Gorrie
2015-06-11  0:50               ` Linhaifeng
2015-04-29 11:11   ` [PATCH v2] " Huawei Xie
2015-05-13 10:46     ` Thomas Monjalon
2015-05-15 13:43       ` Nikita Kalyazin
2015-05-15 15:23         ` Michael S. Tsirkin
2015-05-18  6:18           ` Nikita Kalyazin

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=553995DB.4000801@huawei.com \
    --to=haifeng.lin-hv44wf8li93qt0dzr+alfa@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    --cc=huawei.xie-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.