From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: "Xie, Huawei" <huawei.xie@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
"stephen@networkplumber.org" <stephen@networkplumber.org>,
"Ananyev, Konstantin" <konstantin.ananyev@intel.com>,
"thomas.monjalon@6wind.com" <thomas.monjalon@6wind.com>
Subject: Re: [dpdk-dev] [PATCH] virtio: use volatile to get used->idx in the loop
Date: Thu, 2 Jun 2016 16:52:15 +0800 [thread overview]
Message-ID: <20160602085215.GU10038@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <C37D651A908B024F974696C65296B57B4C7C22F6@SHSMSX101.ccr.corp.intel.com>
On Thu, Jun 02, 2016 at 08:39:36AM +0000, Xie, Huawei wrote:
> On 6/1/2016 2:03 PM, Yuanhan Liu wrote:
> > On Wed, Jun 01, 2016 at 05:40:08AM +0000, Xie, Huawei wrote:
> >> On 5/30/2016 4:20 PM, Yuanhan Liu wrote:
> >>> On Wed, May 25, 2016 at 12:16:41AM +0800, Huawei Xie wrote:
> >>>> There is no external function call or any barrier in the loop,
> >>>> the used->idx would only be retrieved once.
> >>>>
> >>>> Signed-off-by: Huawei Xie <huawei.xie@intel.com>
> >>>> ---
> >>>> drivers/net/virtio/virtio_ethdev.c | 3 ++-
> >>>> 1 file changed, 2 insertions(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> >>>> index c3fb628..f6d6305 100644
> >>>> --- a/drivers/net/virtio/virtio_ethdev.c
> >>>> +++ b/drivers/net/virtio/virtio_ethdev.c
> >>>> @@ -204,7 +204,8 @@ virtio_send_command(struct virtqueue *vq, struct virtio_pmd_ctrl *ctrl,
> >>>> usleep(100);
> >>>> }
> >>>>
> >>>> - while (vq->vq_used_cons_idx != vq->vq_ring.used->idx) {
> >>>> + while (vq->vq_used_cons_idx !=
> >>>> + *((volatile uint16_t *)(&vq->vq_ring.used->idx))) {
> >>> I'm wondering maybe we could fix VIRTQUEUE_NUSED (which has no such
> >>> qualifier) and use this macro here?
> >>>
> >>> If you check the reference of that macro, you might find similar
> >>> issues, say, it is also used inside the while-loop of
> >>> virtio_recv_mergeable_pkts().
> >>>
> >>> --yliu
> >>>
> >>>
> >> Yes, seems it has same issue though haven't confirmed with asm code.
> > So, move the "volatile" qualifier to VIRTQUEUE_NUSED?
> >
> > --yliu
> >
>
> Yes, anyway this is just intermediate fix. In next patch, will declare
> the idx as volatile, and remove the qualifier in the macro.
Hmm.., why we need an intermediate fix then, if we can come up with an
ultimate fix very quickly?
--yliu
next prev parent reply other threads:[~2016-06-02 8:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 16:16 Huawei Xie
2016-05-25 8:25 ` Xie, Huawei
2016-05-25 8:34 ` Michael S. Tsirkin
2016-05-25 9:47 ` Bruce Richardson
2016-05-25 9:50 ` Michael S. Tsirkin
2016-05-25 10:00 ` Bruce Richardson
2016-05-25 15:24 ` Xie, Huawei
2016-05-30 8:22 ` Yuanhan Liu
2016-06-01 5:40 ` Xie, Huawei
2016-06-01 6:05 ` Yuanhan Liu
2016-06-02 8:39 ` Xie, Huawei
2016-06-02 8:52 ` Yuanhan Liu [this message]
2016-06-02 8:54 ` Xie, Huawei
2016-06-14 13:23 ` Yuanhan Liu
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=20160602085215.GU10038@yliu-dev.sh.intel.com \
--to=yuanhan.liu@linux.intel.com \
--cc=dev@dpdk.org \
--cc=huawei.xie@intel.com \
--cc=konstantin.ananyev@intel.com \
--cc=stephen@networkplumber.org \
--cc=thomas.monjalon@6wind.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;
as well as URLs for NNTP newsgroup(s).