All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, Luke Gorrie <luke@snabb.co>
Cc: "snabb-devel@googlegroups.com" <snabb-devel@googlegroups.com>,
	VirtualOpenSystems Technical Team <tech@virtualopensystems.com>,
	virtualization@lists.linux-foundation.org
Subject: Re: memory barriers in virtq.lua?
Date: Wed, 28 Jan 2015 12:27:27 +0200	[thread overview]
Message-ID: <CADDJ2=M6hwFwooXqUjUc9+JxjW1sVYvKhY9dBavrmMUrej6Ysw__42080.5913433016$1422457790$gmane$org@mail.gmail.com> (raw)
In-Reply-To: <20150127160126.GA10651@redhat.com>

Hello Michael,


On Tue, Jan 27, 2015 at 6:01 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> Hi Nikolay,
> I poked at src/lib/virtio/virtq.lua a bit -
> I was surprised to find no explicit CPU memory
> barriers in the virtq implementation.
> These are typically required when using virtio
> on smp machines - the spec actually mention where
> barriers are necessary.
> Are the barriers implicit somehow for lua?
> I'd be curious to learn.
>


thanks for looking at our code and providing your feedback.

The virtq.lua implements the virtq operations from a device point of
view. We compile this with LuaJIT which is guaranteed to not reorder
operations [1]. We also target the x86 architecture, which is
guaranteed to not reorder stores [2]:
"Stores Are Seen in a Consistent Order by Other Processors".
We rely on both these facts and don't use barrier in the virtq code.
However I do agree that we'll have to put barriers once we switch to
other architectures and/or LuaJIT implements ordering optmisations.

Finally, I checked the virtio 1.0 spec again and didn't see any
explicit mentioning of memory barriers regarding the device side of
the spec. There are several places where memory barriers are mentioned
and these all are about the driver. Maybe they are omitted because
they are implicit somehow? Please clarify.

regards,
Nikolay Nikolaev

[1] https://www.freelists.org/post/luajit/Compiler-loadstore-barrier-volatile-pointer-barriers-in-general,1
[2] http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-3a-part-1-manual.pdf
 - 8.2.3.7

>
> Thanks,
>
> --
> MST

  reply	other threads:[~2015-01-28 10:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-27 16:01 memory barriers in virtq.lua? Michael S. Tsirkin
2015-01-28 10:27 ` Nikolay Nikolaev [this message]
     [not found] ` <CADDJ2=M6hwFwooXqUjUc9+JxjW1sVYvKhY9dBavrmMUrej6Ysw@mail.gmail.com>
     [not found]   ` <CADDJ2=M6hwFwooXqUjUc9+JxjW1sVYvKhY9dBavrmMUrej6Ysw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-04-07 14:22     ` [snabb-devel] " Luke Gorrie
2015-04-07 15:30       ` Michael S. Tsirkin
     [not found]       ` <CAA2XHbcU0tV0NrBXT6oh6LOz7sKm9P8jqD1=T-ZgTahSVM_qwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-04-07 15:30         ` Michael S. Tsirkin
     [not found]           ` <20150407172849-mutt-send-email-mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-04-08  3:40             ` Luke Gorrie
2015-04-08  3:40           ` Luke Gorrie
2015-04-08 15:15       ` [dpdk-dev] " Xie, Huawei
2015-04-08 15:15       ` [dpdk-dev] " Xie, Huawei
2015-04-09  3:12         ` [dpdk-dev] [snabb-devel] " Luke Gorrie
2015-04-09  3:12         ` [dpdk-dev] " Luke Gorrie
2015-04-09 15:00           ` [dpdk-dev] [snabb-devel] " Xie, Huawei
     [not found]           ` <CAA2XHbdNAB1ZsBFYHW7W1yhnkzaSixwKk4KvjU8G=7OLECpZhQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-04-09 15:00             ` Xie, Huawei
2015-04-07 14:22   ` Luke Gorrie

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='CADDJ2=M6hwFwooXqUjUc9+JxjW1sVYvKhY9dBavrmMUrej6Ysw__42080.5913433016$1422457790$gmane$org@mail.gmail.com' \
    --to=n.nikolaev@virtualopensystems.com \
    --cc=luke@snabb.co \
    --cc=mst@redhat.com \
    --cc=snabb-devel@googlegroups.com \
    --cc=tech@virtualopensystems.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 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.