Skip to content

random: Resolve circular include dependency and include <linux/percpu.h>

Uros Bizjak bpf dri-devel intel-gfx linux-crypto linux-fscrypt linux-kselftest linux-media linux-mtd linux-scsi lkml 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest19 patches 3 repliesIn review
  2. v2 posting 2/219 patches 9 repliesSuperseded
  3. v2 posting 1/219 patches 0 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v118 patches11 repliesApplied

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/19x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h>arch/x86/mm/kaslr.c+1 -10 replies
2/19crypto: testmgr: Include <linux/prandom.h> instead of <linux/random.h>crypto/testmgr.c+1 -11 reply
3/19drm/i915/selftests: Include <linux/prandom.h> instead of <linux/random.h>drivers/gpu/drm/i915/selftests/i915_gem.c drivers/gpu/drm/i915/selftests/i915_random.h drivers/gpu/drm/i915/selftests/scatterlist.c+3 -30 replies
4/19drm/lib: Include <linux/prandom.h> instead of <linux/random.h>drivers/gpu/drm/lib/drm_random.h+1 -10 replies
5/19media: vivid: Include <linux/prandom.h> in vivid-vid-cap.cdrivers/media/test-drivers/vivid/vivid-vid-cap.c+1 -00 replies
6/19mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>drivers/mtd/tests/oobtest.c drivers/mtd/tests/pagetest.c drivers/mtd/tests/subpagetest.c+3 -30 replies
7/19fscrypt: Include <linux/once.h> in fs/crypto/keyring.cfs/crypto/keyring.c+1 -00 replies
8/19scsi: libfcoe: Include <linux/prandom.h> instead of <linux/random.h>include/scsi/libfcoe.h+1 -10 replies
9/19bpf: Include <linux/prandom.h> instead of <linux/random.h>kernel/bpf/core.c+1 -10 replies
10/19lib/interval_tree_test.c: Include <linux/prandom.h> instead of <linux/random.h>lib/interval_tree_test.c+1 -10 replies
11/19kunit: string-stream-test: Include <linux/prandom.h>lib/kunit/string-stream-test.c+1 -00 replies
12/19random32: Include <linux/prandom.h> instead of <linux/random.h>lib/random32.c+1 -10 replies
13/19lib/rbtree-test: Include <linux/prandom.h> instead of <linux/random.h>lib/rbtree_test.c+1 -10 replies
14/19bpf/tests: Include <linux/prandom.h> instead of <linux/random.h>lib/test_bpf.c+1 -10 replies
15/19lib/test_parman: Include <linux/prandom.h> instead of <linux/random.h>lib/test_parman.c+1 -10 replies
16/19lib/test_scanf: Include <linux/prandom.h> instead of <linux/random.h>lib/test_scanf.c+1 -10 replies
17/19netem: Include <linux/prandom.h> in sch_netem.cnet/sched/sch_netem.c+1 -01 reply
18/19random: Do not include <linux/prandom.h> in <linux/random.h>include/linux/random.h+0 -70 replies
19/19prandom: Include <linux/percpu.h> in <linux/prandom.h>include/linux/prandom.h+1 -00 replies

Reviews trailers per patch

8 of 19 patches have a Reviewed-by or Acked-by.

PatchJani NikulaHans VerkuilMiquel RaynalEric BiggersBart Van AsschePetr MladekStephen HemmingerHerbert Xu
1/19
2/19A-b
3/19A-b
4/19
5/19A-b
6/19A-b
7/19A-b
8/19R-b
9/19
10/19
11/19
12/19
13/19
14/19
15/19
16/19A-b
17/19A-b
18/19
19/19

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 8 reviewers.

Read the v3 thread

Cover letter [PATCH v3 00/19] random: Resolve circular include dependency and include <linux/percpu.h>

There were several attempts to resolve circular include dependency after the addition of percpu.h: 1c9df907da83 ("random: fix circular include dependency on arm64 after addition of percpu.h"), c0842fbc1b18 ("random32: move the pseudo-random 32-bit definitions to prandom.h") and finally d9f29deb7fe8 ("prandom: Remove unused include") that completely removes the inclusion of <linux/percpu.h>.

Due to legacy reasons, <linux/random.h> includes <linux/prandom.h>, but with the commit entry remark:

--quote--
A further cleanup step would be to remove this from <linux/random.h> entirely, and make people who use the prandom infrastructure include just the new header file. That's a bit of a churn patch, but grepping for "prandom_" and "next_pseudo_random32" "struct rnd_state" should catch most users.

But it turns out that that nice cleanup step is fairly painful, because a _lot_ of code currently seems to depend on the implicit include of <linux/random.h>, which can currently come in a lot of ways, including such fairly core headfers as <linux/net.h>.

So the "nice cleanup" part may or may never happen. --/quote--

We would like to include <linux/percpu.h> in <linux/prandom.h>. In [1] we would like to repurpose __percpu tag as a named address space qualifier, where __percpu macro uses defines from <linux/percpu.h>.

The major roadblock to inclusion of <linux/percpu.h> is the above mentioned legacy inclusion of <linux/prandom.h> in <linux/random.h> that causes circular include dependency that prevents <linux/percpu.h> inclusion.

This patch series is the "nice cleanup" part that:

a) Substitutes the inclusion of <linux/random.h> with the inclusion of <linux/prandom.h> where needed (patches 1 - 17).

b) Removes legacy inclusion of <linux/prandom.h> from <linux/random.h> (patch 18).

c) Includes <linux/percpu.h> in <linux/prandom.h> (patch 19).

The whole series was tested by compiling the kernel for x86_64 allconfig and some popular architectures, namely arm64 defconfig, powerpc defconfig and loongarch defconfig.

[1] https://lore.kernel.org/lkml/[email protected]/

Cc Dave Hansen <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc Hans Verkuil <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Miquel Raynal <[email protected]>
Cc Richard Weinberger <[email protected]>
Cc Vignesh Raghavendra <[email protected]>
Cc Eric Biggers <[email protected]>
Cc "Theodore Y. Ts'o" <[email protected]>
Cc Jaegeuk Kim <[email protected]>
Cc "Jason A. Donenfeld" <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc John Fastabend <[email protected]>
Cc Andrii Nakryiko <[email protected]>
Cc Martin KaFai Lau <[email protected]>
Cc Eduard Zingerman <[email protected]>
Cc Song Liu <[email protected]>
Cc Yonghong Song <[email protected]>
Cc KP Singh <[email protected]>
Cc Stanislav Fomichev <[email protected]>
Cc Hao Luo <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Brendan Higgins <[email protected]>
Cc David Gow <[email protected]>
Cc Rae Moar <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Jiri Pirko <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Rasmus Villemoes <[email protected]>
Cc Sergey Senozhatsky <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Jamal Hadi Salim <[email protected]>
Cc Cong Wang <[email protected]>
Cc Kent Overstreet <[email protected]>

---
v2: - Reword commit messages to mention the removal of legacy inclusion
of <linux/prandom.h> from <linux/random.h>
- Add missing substitution in crypto/testmgr.c
(reported by kernel test robot)
- Add Acked-by: tags.
v3: - Update to linux 6.12rc1.
- Add more Acked-by: tags.

Uros Bizjak (19):
x86/kaslr: Include <linux/prandom.h> instead of <linux/random.h>
crypto: testmgr: Include <linux/prandom.h> instead of <linux/random.h> drm/i915/selftests: Include <linux/prandom.h> instead of
<linux/random.h>
drm/lib: Include <linux/prandom.h> instead of <linux/random.h>
media: vivid: Include <linux/prandom.h> in vivid-vid-cap.c
mtd: tests: Include <linux/prandom.h> instead of <linux/random.h>
fscrypt: Include <linux/once.h> in fs/crypto/keyring.c
scsi: libfcoe: Include <linux/prandom.h> instead of <linux/random.h>
bpf: Include <linux/prandom.h> instead of <linux/random.h> lib/interval_tree_test.c: Include <linux/prandom.h> instead of
<linux/random.h>
kunit: string-stream-test: Include <linux/prandom.h>
random32: Include <linux/prandom.h> instead of <linux/random.h> lib/rbtree-test: Include <linux/prandom.h> instead of <linux/random.h> bpf/tests: Include <linux/prandom.h> instead of <linux/random.h> lib/test_parman: Include <linux/prandom.h> instead of <linux/random.h> lib/test_scanf: Include <linux/prandom.h> instead of <linux/random.h>
netem: Include <linux/prandom.h> in sch_netem.c
random: Do not include <linux/prandom.h> in <linux/random.h>
prandom: Include <linux/percpu.h> in <linux/prandom.h>

 arch/x86/mm/kaslr.c                              | 2 +-
 crypto/testmgr.c                                 | 2 +-
 drivers/gpu/drm/i915/selftests/i915_gem.c        | 2 +-
 drivers/gpu/drm/i915/selftests/i915_random.h     | 2 +-
 drivers/gpu/drm/i915/selftests/scatterlist.c     | 2 +-
 drivers/gpu/drm/lib/drm_random.h                 | 2 +-
 drivers/media/test-drivers/vivid/vivid-vid-cap.c | 1 +
 drivers/mtd/tests/oobtest.c                      | 2 +-
 drivers/mtd/tests/pagetest.c                     | 2 +-
 drivers/mtd/tests/subpagetest.c                  | 2 +-
 fs/crypto/keyring.c                              | 1 +
 include/linux/prandom.h                          | 1 +
 include/linux/random.h                           | 7 -------
 include/scsi/libfcoe.h                           | 2 +-
 kernel/bpf/core.c                                | 2 +-
 lib/interval_tree_test.c                         | 2 +-
 lib/kunit/string-stream-test.c                   | 1 +
 lib/random32.c                                   | 2 +-
 lib/rbtree_test.c                                | 2 +-
 lib/test_bpf.c                                   | 2 +-
 lib/test_parman.c                                | 2 +-
 lib/test_scanf.c                                 | 2 +-
 net/sched/sch_netem.c                            | 1 +
 23 files changed, 22 insertions(+), 24 deletions(-)
Signature · 1 line
2.46.2