linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] atomics: generate atomic headers
@ 2018-05-29 18:07 Mark Rutland
  2018-05-29 18:07 ` [PATCH 1/7] atomics/tty: add missing atomic_long_t * cast Mark Rutland
                   ` (8 more replies)
  0 siblings, 9 replies; 31+ messages in thread
From: Mark Rutland @ 2018-05-29 18:07 UTC (permalink / raw)
  To: linux-kernel, boqun.feng, peterz, will.deacon
  Cc: Mark Rutland, arnd, aryabinin, dvyukov, glider, gregkh, jslaby,
	parri.andrea

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.

[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

Mark Rutland (7):
  atomics/tty: add missing atomic_long_t * cast
  atomics/treewide: rework ordering barriers
  atomics: separate basic {cmp,}xchg()
  atomics: add common header generation files
  atomics: switch to generated fallbacks
  atomics: switch to generated atomic-long
  atomics: switch to generated instrumentation

 MAINTAINERS                                      |    1 +
 arch/alpha/include/asm/atomic.h                  |    8 +-
 arch/powerpc/include/asm/atomic.h                |   17 +-
 arch/riscv/include/asm/atomic.h                  |   17 +-
 drivers/tty/tty_ldsem.c                          |    2 +-
 include/asm-generic/atomic-instrumented-atomic.h | 1629 ++++++++++++++++
 include/asm-generic/atomic-instrumented.h        |  394 +---
 include/asm-generic/atomic-long.h                | 1150 +++++++++--
 include/linux/atomic-fallback.h                  | 2223 ++++++++++++++++++++++
 include/linux/atomic.h                           | 1244 +-----------
 scripts/atomic/atomic-tbl.sh                     |  186 ++
 scripts/atomic/atomics.tbl                       |   41 +
 scripts/atomic/fallbacks/acquire                 |    9 +
 scripts/atomic/fallbacks/add_negative            |   16 +
 scripts/atomic/fallbacks/add_unless              |   16 +
 scripts/atomic/fallbacks/andnot                  |    7 +
 scripts/atomic/fallbacks/dec                     |    7 +
 scripts/atomic/fallbacks/dec_and_test            |   15 +
 scripts/atomic/fallbacks/dec_if_positive         |   15 +
 scripts/atomic/fallbacks/dec_unless_positive     |   14 +
 scripts/atomic/fallbacks/fence                   |   11 +
 scripts/atomic/fallbacks/fetch_add_unless        |   23 +
 scripts/atomic/fallbacks/inc                     |    7 +
 scripts/atomic/fallbacks/inc_and_test            |   15 +
 scripts/atomic/fallbacks/inc_not_zero            |   14 +
 scripts/atomic/fallbacks/inc_unless_negative     |   14 +
 scripts/atomic/fallbacks/read_acquire            |    7 +
 scripts/atomic/fallbacks/release                 |    8 +
 scripts/atomic/fallbacks/set_release             |    7 +
 scripts/atomic/fallbacks/sub_and_test            |   16 +
 scripts/atomic/fallbacks/try_cmpxchg             |   11 +
 scripts/atomic/gen-atomic-fallback.sh            |  144 ++
 scripts/atomic/gen-atomic-instrumented.sh        |  122 ++
 scripts/atomic/gen-atomic-long.sh                |   98 +
 34 files changed, 5671 insertions(+), 1837 deletions(-)
 create mode 100644 include/asm-generic/atomic-instrumented-atomic.h
 create mode 100644 include/linux/atomic-fallback.h
 create mode 100755 scripts/atomic/atomic-tbl.sh
 create mode 100644 scripts/atomic/atomics.tbl
 create mode 100644 scripts/atomic/fallbacks/acquire
 create mode 100644 scripts/atomic/fallbacks/add_negative
 create mode 100644 scripts/atomic/fallbacks/add_unless
 create mode 100644 scripts/atomic/fallbacks/andnot
 create mode 100644 scripts/atomic/fallbacks/dec
 create mode 100644 scripts/atomic/fallbacks/dec_and_test
 create mode 100644 scripts/atomic/fallbacks/dec_if_positive
 create mode 100644 scripts/atomic/fallbacks/dec_unless_positive
 create mode 100644 scripts/atomic/fallbacks/fence
 create mode 100644 scripts/atomic/fallbacks/fetch_add_unless
 create mode 100644 scripts/atomic/fallbacks/inc
 create mode 100644 scripts/atomic/fallbacks/inc_and_test
 create mode 100644 scripts/atomic/fallbacks/inc_not_zero
 create mode 100644 scripts/atomic/fallbacks/inc_unless_negative
 create mode 100644 scripts/atomic/fallbacks/read_acquire
 create mode 100644 scripts/atomic/fallbacks/release
 create mode 100644 scripts/atomic/fallbacks/set_release
 create mode 100644 scripts/atomic/fallbacks/sub_and_test
 create mode 100644 scripts/atomic/fallbacks/try_cmpxchg
 create mode 100755 scripts/atomic/gen-atomic-fallback.sh
 create mode 100755 scripts/atomic/gen-atomic-instrumented.sh
 create mode 100755 scripts/atomic/gen-atomic-long.sh

-- 
2.11.0

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2018-06-28 12:27 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).