All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Boqun Feng <boqun.feng@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Will Deacon <will.deacon@arm.com>, Arnd Bergmann <arnd@arndb.de>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>,
	Alexander Potapenko <glider@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	Andrea Parri <parri.andrea@gmail.com>
Subject: Re: [PATCH 0/7] atomics: generate atomic headers
Date: Tue, 5 Jun 2018 06:56:13 +0100	[thread overview]
Message-ID: <20180605055613.dsgb4g5gudxf4ebr@salmiak> (raw)
In-Reply-To: <CACT4Y+Y_p1x-gZW7V3hm9jvC2k7pKUNh37_b8KBTywxkd0OKqg@mail.gmail.com>

On Mon, Jun 04, 2018 at 06:21:22PM +0200, Dmitry Vyukov wrote:
> On Tue, May 29, 2018 at 8:07 PM, Mark Rutland <mark.rutland@arm.com> wrote:
> > This series scripts the generation of the various atomic headers, to
> > ensure that the various atomic APIs remain consistent, reducing the risk
> > of human error, and simplifying future rework.
> >
> > The series is based on my atomic API cleanup patches [1,2], and can be
> > found on my atomics/generated branch [3] on kernel.org.
> >
> > The first three patches are preparatory rework, with patch four
> > introducing the infrastructure. The final three patches migrate to
> > generated headers. The scripts themselves are mostly POSIX sh (modulo
> > local), without bashisms, and work in dash and bash.
> >
> > Per Linus request that it is possible to use git grep to inspect the
> > atomic headers [3], the headers are committed (and not generated by
> > kbuild). Since we now expand the fallback definitions inline, each
> > *should* be easier to find with grep. Each header also has a comment at
> > the top with a path to the script used to generate it.
> >
> > While the diff stat looks like a huge addition, the scripting comes in
> > at ~800 lines in total, including the fallback definitions, so we're
> > removing ~1000 lines of hand-written code. At the same time, we fill in
> > gaps in the atomic_long API, and the instrumented atomic wrappers.
> >
> > Longer-term, I think things could be simplified if we were to rework the
> > headers such that we have:
> >
> > * arch/*/include/asm/atomic.h providing arch_atomic_*().
> >
> > * include/linux/atomic-raw.h building raw_atomic_*() atop of the
> >   arch_atomic_*() definitions, filling in gaps in the API. Having
> >   separate arch_ and raw_ namespaces would simplify the ifdeffery.
> >
> > * include/linux/atomic.h building atomic_*() atop of the raw_atomic_*()
> >   definitions, complete with any instrumentation. Instrumenting at this
> >   level would lower the instrumentation overhead, and would not require
> >   any ifdeffery as the whole raw_atomic_*() API would be available.
> >
> > ... I've avoided this for the time being due to the necessary churn in
> > arch code.
> >
> > Thanks,
> > Mark.
> 
> Wow! Nice work!

Thanks!

> I can say that besides KASAN, we will need hooking into atomics for
> KMSAN and KTSAN in future. Without this it would be lots of manual
> work with possibility of copy-paste errors.

Indeed!

This was largely driven by wanting the arm64 atomics instrumented, and
generating that does end up easier to get right than manually expanding all the
acquire/release/relaxed ifdeffery manually.

First we need to get the preparatory patches [1,2] merged. Those have had a few
fixups since they were last posted, so I'll send an updated version come
v4.18-rc1 unless the atomics maintainers really want to queue those ASAP.

There'll be some additional prep work for instrumentation on arm64, too (e.g.
fiddling with the (cmp)xchg instrumentation), so I'll look into that in the
mean time.

Thanks,
Mark.

> > [1] https://lkml.kernel.org/r/20180529154346.3168-1-mark.rutland@arm.com
> > [2] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git atomics/api-cleanup
> > [3] git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git atomics/generated
> > [4] https://lkml.kernel.org/r/CA+55aFxjU0op8QLLu0n-RjHBs7gQsLvD8jcyedgw6jeZFN7B+Q@mail.gmail.com

  reply	other threads:[~2018-06-05  5:56 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-29 18:07 [PATCH 0/7] atomics: generate atomic headers Mark Rutland
2018-05-29 18:07 ` [PATCH 1/7] atomics/tty: add missing atomic_long_t * cast Mark Rutland
2018-05-29 18:35   ` Greg Kroah-Hartman
2018-06-05 12:00   ` Peter Zijlstra
2018-06-05 14:20     ` Greg Kroah-Hartman
2018-06-05 14:43       ` Peter Zijlstra
2018-06-05 14:53         ` Peter Zijlstra
2018-06-06 13:55           ` Mark Rutland
2018-06-06 14:00           ` Greg Kroah-Hartman
2018-06-22 16:55             ` Mark Rutland
2018-06-28 12:07               ` Greg Kroah-Hartman
2018-05-29 18:07 ` [PATCH 2/7] atomics/treewide: rework ordering barriers Mark Rutland
2018-06-05 12:16   ` Peter Zijlstra
2018-06-05 13:28     ` Mark Rutland
2018-06-05 13:56       ` Peter Zijlstra
2018-06-05 14:02         ` Mark Rutland
2018-06-05 14:15           ` Peter Zijlstra
2018-05-29 18:07 ` [PATCH 3/7] atomics: separate basic {cmp,}xchg() Mark Rutland
2018-05-29 18:07 ` [PATCH 4/7] atomics: add common header generation files Mark Rutland
2018-06-05 12:25   ` Peter Zijlstra
2018-06-05 12:52     ` Mark Rutland
2018-05-29 18:07 ` [PATCH 5/7] atomics: switch to generated fallbacks Mark Rutland
2018-05-29 18:07 ` [PATCH 6/7] atomics: switch to generated atomic-long Mark Rutland
2018-05-29 18:07 ` [PATCH 7/7] atomics: switch to generated instrumentation Mark Rutland
2018-06-04 16:21 ` [PATCH 0/7] atomics: generate atomic headers Dmitry Vyukov
2018-06-05  5:56   ` Mark Rutland [this message]
2018-06-05 13:31   ` Peter Zijlstra
2018-06-05 13:29 ` Peter Zijlstra
2018-06-05 13:58   ` Mark Rutland
2018-06-05 14:14     ` Peter Zijlstra
2018-06-05 14:23       ` Mark Rutland

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=20180605055613.dsgb4g5gudxf4ebr@salmiak \
    --to=mark.rutland@arm.com \
    --cc=arnd@arndb.de \
    --cc=aryabinin@virtuozzo.com \
    --cc=boqun.feng@gmail.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=parri.andrea@gmail.com \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.com \
    /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.