From: Marco Elver <elver@google.com>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: paulmck@kernel.org, linux-kernel@vger.kernel.org,
kasan-dev@googlegroups.com, kernel-team@fb.com, mingo@kernel.org,
andreyknvl@google.com, glider@google.com, dvyukov@google.com,
cai@lca.pw, Will Deacon <will@kernel.org>,
Arnd Bergmann <arnd@arndb.de>, Daniel Axtens <dja@axtens.net>,
Michael Ellerman <mpe@ellerman.id.au>,
linux-arch@vger.kernel.org
Subject: Re: [PATCH kcsan 18/19] bitops, kcsan: Partially revert instrumentation for non-atomic bitops
Date: Wed, 2 Sep 2020 08:13:15 +0200 [thread overview]
Message-ID: <20200902061315.GA1167979@elver.google.com> (raw)
In-Reply-To: <20200902033006.GB49492@debian-boqun.qqnc3lrjykvubdpftowmye0fmh.lx.internal.cloudapp.net>
On Wed, Sep 02, 2020 at 11:30AM +0800, Boqun Feng wrote:
> Hi Paul and Marco,
>
> The whole update patchset looks good to me, just one question out of
> curiosity fo this one, please see below:
>
> On Mon, Aug 31, 2020 at 11:18:04AM -0700, paulmck@kernel.org wrote:
> > From: Marco Elver <elver@google.com>
> >
> > Previous to the change to distinguish read-write accesses, when
> > CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC=y is set, KCSAN would consider
> > the non-atomic bitops as atomic. We want to partially revert to this
> > behaviour, but with one important distinction: report racing
> > modifications, since lost bits due to non-atomicity are certainly
> > possible.
> >
> > Given the operations here only modify a single bit, assuming
> > non-atomicity of the writer is sufficient may be reasonable for certain
> > usage (and follows the permissible nature of the "assume plain writes
> > atomic" rule). In other words:
> >
> > 1. We want non-atomic read-modify-write races to be reported;
> > this is accomplished by kcsan_check_read(), where any
> > concurrent write (atomic or not) will generate a report.
> >
> > 2. We do not want to report races with marked readers, but -do-
> > want to report races with unmarked readers; this is
> > accomplished by the instrument_write() ("assume atomic
> > write" with Kconfig option set).
> >
>
> Is there any code in kernel using the above assumption (i.e.
> non-atomicity of the writer is sufficient)? IOW, have you observed
> anything bad (e.g. an anoying false positive) after applying the
> read_write changes but without this patch?
We were looking for an answer to:
https://lkml.kernel.org/r/20200810124516.GM17456@casper.infradead.org
Initially we thought using atomic bitops might be required, but after a
longer offline discussion realized that simply marking the reader in
this case, but retaining the non-atomic bitop is probably all that's
needed.
The version of KCSAN that found the above was still using KCSAN from
Linux 5.8, but we realized with the changed read-write instrumentation
to bitops in this series, we'd regress and still report the race even if
the reader was marked. To avoid this with the default KCSAN config, we
determined that we need the patch here.
The bitops are indeed a bit more special, because for both the atomic
and non-atomic bitops we *can* reason about the generated code (since we
control it, although not sure about the asm-generic ones), and that
makes reasoning about accesses racing with non-atomic bitops more
feasible. At least that's our rationale for deciding that reverting
non-atomic bitops treatment to it's more relaxed version is ok.
Thanks,
-- Marco
next prev parent reply other threads:[~2020-09-02 6:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-31 18:17 [PATCH kcsan 0/19] KCSAN updates for v5.10 Paul E. McKenney
2020-08-31 18:17 ` [PATCH kcsan 01/19] kcsan: Add support for atomic builtins paulmck
2020-08-31 18:17 ` [PATCH kcsan 02/19] objtool: Add atomic builtin TSAN instrumentation to uaccess whitelist paulmck
2020-08-31 18:17 ` [PATCH kcsan 03/19] kcsan: Add atomic builtin test case paulmck
2020-08-31 18:17 ` [PATCH kcsan 04/19] kcsan: Support compounded read-write instrumentation paulmck
2020-08-31 18:17 ` [PATCH kcsan 05/19] objtool, kcsan: Add __tsan_read_write to uaccess whitelist paulmck
2020-08-31 18:17 ` [PATCH kcsan 06/19] kcsan: Skew delay to be longer for certain access types paulmck
2020-08-31 18:17 ` [PATCH kcsan 07/19] kcsan: Add missing CONFIG_KCSAN_IGNORE_ATOMICS checks paulmck
2020-08-31 18:17 ` [PATCH kcsan 08/19] kcsan: Test support for compound instrumentation paulmck
2020-08-31 18:17 ` [PATCH kcsan 09/19] instrumented.h: Introduce read-write instrumentation hooks paulmck
2020-08-31 18:17 ` [PATCH kcsan 10/19] asm-generic/bitops: Use instrument_read_write() where appropriate paulmck
2020-08-31 18:17 ` [PATCH kcsan 11/19] locking/atomics: Use read-write instrumentation for atomic RMWs paulmck
2020-08-31 18:17 ` [PATCH kcsan 12/19] kcsan: Simplify debugfs counter to name mapping paulmck
2020-08-31 18:17 ` [PATCH kcsan 13/19] kcsan: Simplify constant string handling paulmck
2020-08-31 18:18 ` [PATCH kcsan 14/19] kcsan: Remove debugfs test command paulmck
2020-08-31 18:18 ` [PATCH kcsan 15/19] kcsan: Show message if enabled early paulmck
2020-08-31 18:18 ` [PATCH kcsan 16/19] kcsan: Use pr_fmt for consistency paulmck
2020-08-31 18:18 ` [PATCH kcsan 17/19] kcsan: Optimize debugfs stats counters paulmck
2020-08-31 18:18 ` [PATCH kcsan 18/19] bitops, kcsan: Partially revert instrumentation for non-atomic bitops paulmck
2020-09-02 3:30 ` Boqun Feng
2020-09-02 6:13 ` Marco Elver [this message]
2020-09-04 1:24 ` Boqun Feng
2020-08-31 18:18 ` [PATCH kcsan 19/19] kcsan: Use tracing-safe version of prandom paulmck
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=20200902061315.GA1167979@elver.google.com \
--to=elver@google.com \
--cc=andreyknvl@google.com \
--cc=arnd@arndb.de \
--cc=boqun.feng@gmail.com \
--cc=cai@lca.pw \
--cc=dja@axtens.net \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=kernel-team@fb.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=paulmck@kernel.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
all inboxes | Powered by JetHome®