[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <295818C4-C5B8-43DF-9D5B-445EBA02FC4F@lca.pw>
Date: Tue, 11 Feb 2020 06:57:05 -0500
From: Qian Cai <cai@....pw>
To: Marco Elver <elver@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH -next] locking/osq_lock: annotate a data race in osq_lock
> On Feb 11, 2020, at 5:16 AM, Marco Elver <elver@...gle.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.
Powered by blists - more mailing lists