All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Emilio G. Cota" <cota@braap.org>
Cc: qemu-devel@nongnu.org, alex bennee <alex.bennee@linaro.org>
Subject: Re: [Qemu-devel] [PATCH 2/5] cpus: use atomic_read to read seqlock-protected variables
Date: Thu, 13 Oct 2016 16:45:00 -0400 (EDT)	[thread overview]
Message-ID: <891420528.3270107.1476391500461.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20161013192015.GA22617@flamenco>

> Is tsan happy with the way seqlocks are written right now?

I honestly don't know.  But if there are tsan bugs there's
not much we can do.  The alternative below has overhead on
ARM and PPC and does not quite fit in atomic.h.

In any case, a bigger issue is that this patch breaks on
32-bit because it does 64-bit atomic_read.  We might have
to fall back to volatile when not running on tsan.

Paolo

> Dmitry Vyukov wrote:
> > 1. Tsan is bad at handling stand-alone memory barriers.
> > And here is a way to express seqlock that is both correct, is
> > understood by tsan and is no overhead on x86:
> > 
> > // writer
> > atomic_store(&seq, seq+1, memory_order_relaxed);
> > atomic_store(&data[0], ..., memory_order_release);
> > ...
> > atomic_store(&data[N], ..., memory_order_release);
> > atomic_store(&seq, seq+1, memory_order_release);
> > 
> > // reader
> > atomic_load(&seq, memory_order_acquire);
> > d0 = atomic_load(&data[0], memory_order_acquire);
> > ...
> > dN = atomic_load(&data[N], memory_order_acquire);
> > atomic_load(&seq, memory_order_relaxed);
> 
> Source: https://groups.google.com/forum/#!topic/thread-sanitizer/B4i9EMQ4BQE
> 
> Thanks,
> 
> 		Emilio
> 

  reply	other threads:[~2016-10-13 20:45 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-10 13:59 [Qemu-devel] [PATCH 0/5] More thread sanitizer fixes and atomic.h improvements Paolo Bonzini
2016-10-10 13:59 ` [Qemu-devel] [PATCH 1/5] atomic: introduce smp_mb_acquire and smp_mb_release Paolo Bonzini
2016-10-10 15:29   ` Eric Blake
2016-10-10 16:38     ` Paolo Bonzini
2016-10-10 13:59 ` [Qemu-devel] [PATCH 2/5] cpus: use atomic_read to read seqlock-protected variables Paolo Bonzini
2016-10-12  8:44   ` Alex Bennée
2016-10-13 19:20   ` Emilio G. Cota
2016-10-13 20:45     ` Paolo Bonzini [this message]
2016-10-10 13:59 ` [Qemu-devel] [PATCH 3/5] qemu-thread: use acquire/release to clarify semantics of QemuEvent Paolo Bonzini
2016-10-12  9:21   ` Alex Bennée
2016-10-12  9:31     ` Paolo Bonzini
2016-10-10 13:59 ` [Qemu-devel] [PATCH 4/5] rcu: simplify memory barriers Paolo Bonzini
2016-10-10 13:59 ` [Qemu-devel] [PATCH 5/5] atomic: base mb_read/mb_set on load-acquire and store-release Paolo Bonzini
2016-10-12  9:28   ` Alex Bennée
2016-10-12  9:30     ` Paolo Bonzini
2016-10-20 18:36   ` Pranith Kumar
2016-10-10 16:53 ` [Qemu-devel] [PATCH 0/5] More thread sanitizer fixes and atomic.h improvements no-reply
2016-10-11 19:21 ` no-reply
2016-10-12 11:32 ` Alex Bennée
2016-10-12 11:34   ` Paolo Bonzini
2016-10-12 22:45 ` Emilio G. Cota
2016-10-13  7:39   ` Paolo Bonzini
2016-10-13 19:29     ` Emilio G. Cota
2016-10-14  9:55       ` Paolo Bonzini
2016-10-21 17:38 ` Alex Bennée
2016-10-22  9:10   ` Paolo Bonzini

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=891420528.3270107.1476391500461.JavaMail.zimbra@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=cota@braap.org \
    --cc=qemu-devel@nongnu.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.