virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: virtualization@lists.linux-foundation.org
Subject: Re: [PATCHv2] virtio: use smp_XX barriers on SMP
Date: Fri, 29 Jan 2010 15:48:17 +0200	[thread overview]
Message-ID: <20100129134817.GA4256@redhat.com> (raw)
In-Reply-To: <201001290744.59324.rusty@rustcorp.com.au>

On Fri, Jan 29, 2010 at 07:44:59AM +1030, Rusty Russell wrote:
> On Fri, 29 Jan 2010 12:07:08 am Michael S. Tsirkin wrote:
> > On Thu, Jan 28, 2010 at 10:01:09AM +1030, Rusty Russell wrote:
> > > On Thu, 28 Jan 2010 09:12:23 am Michael S. Tsirkin wrote:
> > > > Where possible, we should use SMP barriers which are more lightweight than
> > > > mandatory barriers, because mandatory barriers also control MMIO effects on
> > > > accesses through relaxed memory I/O windows (which virtio does not use)
> > > > (compare specifically smp_rmb and rmb on x86_64).
> > > 
> > > Xen had a similar issue, in that UP guests running on SMP hosts need to issue
> > > SMP barriers.  Is this not also a requirement for virtio?
> > 
> > Of course it is. That's why I have ifdef CONFIG_SMP and use
> > mandatory barriers on UP.
> 
> Sorry, this was an off-the-cuff comment.  I was concerned that UP barriers
> might be insufficient on some archs.  But I can't find any such archs when
> I actually look (at least, x86, s390 and powerpc).

I see. Yes, smp barriers seem in practice to be a subset of mandatory
barriers.  Maybe a documentation patch specifying this is in order.

> I've applied your patch, minus the first two substitutions:
> 
> @@ -36,10 +54,10 @@
>                         panic("%s:in_use = %i\n",               \
>                               (_vq)->vq.name, (_vq)->in_use);   \
>                 (_vq)->in_use = __LINE__;                       \
> -               mb();                                           \
> +               virtio_mb();                                            \
>         } while (0)
>  #define END_USE(_vq) \
> -       do { BUG_ON(!(_vq)->in_use); (_vq)->in_use = 0; mb(); } while(0)
> +       do { BUG_ON(!(_vq)->in_use); (_vq)->in_use = 0; virtio_mb(); } while(0)
>  #else
>  #define BAD_RING(_vq, fmt, args...)                            \
>         do {                                                    \
> 
> These barriers are actually trying to make sure in_use is set in a timely
> manner (this is debug code).  They're bogus AFAICT: if you don't have any
> other synchronization then you're in danger of nesting and you want to know.
> And barriers might change timing too much when DEBUG is defined.
> 
> Thanks!
> Rusty.

      parent reply	other threads:[~2010-01-29 13:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-27 22:42 [PATCHv2] virtio: use smp_XX barriers on SMP Michael S. Tsirkin
2010-01-27 23:31 ` Rusty Russell
2010-01-28 13:37   ` Michael S. Tsirkin
2010-01-28 21:14     ` Rusty Russell
2010-01-29 11:27       ` Michael S. Tsirkin
2010-01-30  4:52         ` Rusty Russell
2010-01-29 13:48       ` Michael S. Tsirkin [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=20100129134817.GA4256@redhat.com \
    --to=mst@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --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;
as well as URLs for NNTP newsgroup(s).