linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qian Cai <cai@lca.pw>
To: Marco Elver <elver@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -next] locking/osq_lock: annotate a data race in osq_lock
Date: Tue, 11 Feb 2020 06:57:05 -0500	[thread overview]
Message-ID: <295818C4-C5B8-43DF-9D5B-445EBA02FC4F@lca.pw> (raw)
In-Reply-To: <CANpmjNPWCu+w3O8cg++X4=viVFsWNehTXzTuqbwV8-DcXXpFng@mail.gmail.com>



> On Feb 11, 2020, at 5:16 AM, Marco Elver <elver@google.com> wrote:
> 
> I have said this before: we're not just guarding against load/store
> tearing, although on their own, they make it deceptively easy to
> reason about data races.
> 
> The case here seems to be another instance of a C-CAS, to avoid
> unnecessarily dirtying a cacheline.
> 
> Here, the loop would make me suspicious, because a compiler could
> optimize out re-loading the value. Due to the smp_load_acquire,
> however, at the least we have 1 implied compiler barrier in this loop
> which means that will likely not happen.
> 
> Before jumping to 'data_race()', I would ask again: how bad is the
> READ_ONCE? Is the generated code the same? If so, just use the
> READ_ONCE. Do you want to reason about all compiler optimizations? For
> this code here, I certainly don't want to.
> 
> But in the end it's up to what maintainers prefer, and maybe there is
> a very compelling argument that I missed that makes the fact this is a
> data race always safe.

Yes, I feel like locking maintainers prefer data_race() rather than blindly adding READ_ONCE() unless there is an strong evidence that the later is needed.

Since I can’t prove it is strictly needed to prevent from which specific optimization, I had chosen the data_race() approach.

  reply	other threads:[~2020-02-11 11:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11  4:06 [PATCH -next] locking/osq_lock: annotate a data race in osq_lock Qian Cai
2020-02-11 10:16 ` Marco Elver
2020-02-11 11:57   ` Qian Cai [this message]
2020-02-11 12:47   ` Peter Zijlstra

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=295818C4-C5B8-43DF-9D5B-445EBA02FC4F@lca.pw \
    --to=cai@lca.pw \
    --cc=elver@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=will@kernel.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).