Skip to content

RFC headers: start rework to avoid recursive inclusion

Arnd Bergmann kernelci linux-fsdevel linux-kbuild lkml llvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3headers: add more types to linux/types.harch/arc/include/asm/atomic64-arcv2.h arch/arm/include/asm/atomic.h arch/x86/include/asm/atomic64_32.h +12 more+89 -952 replies
2/3headers: introduce linux/struct_types.harch/alpha/include/asm/spinlock_types.h arch/arm/include/asm/spinlock_types.h arch/arm64/include/asm/spinlock_types.h +39 more+506 -4836 replies
3/3headers: repurpose linux/fs_types.hinclude/linux/fs.h include/linux/fs_types.h include/linux/quota.h+1227 -11783 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC 0/3] headers: start rework to avoid recursive inclusion

From: Arnd Bergmann <[email protected]>

I've gotten back to a patch series I worked on a while back, to clean up the way we include headers recursively in the kernel, analysing the dependency chains and reducing them as much as possible. The most common issue is headers that need a data structure definition from another header but shouldn't really pull in the rest of it.

Improving this will help both the compilation speed of single files (earlier experiments with clang showed a crazy 30% improvement after reducing the average size of the indirect headers by 90%), and those people that build a lot of similar kernels, where a modification in a common header tends to require rebuilding everything.

These three patches are a first step in the direction of minimizing the headers needed for defining data structures that embed other structures. Rather than split up each header into one that only defines structures, and another one for the rest, this adds more fundamental types to linux/types.h and introduces a new linux/struct_types.h with the most commonly embedded structures.

The fs_types.h change in the third patch shows how high-level structure definitions can then be done with a much smaller set of indirect includes, using one of the central headers (linux/fs.h) as the example. The same would need to be done for other headers that are currently included in most drivers and that in turn indirectly include hundreds of other headers (linux/skbuff.h, linux/mm.h, linux/device.h, linux/sched.h, ...).

None of this work actually removes the indirect includes yet, as that can only be done after each .c file that currently relies on indirect includes of common headers is changed to include them directly. The first step toward that however is to come to a rough agreement on what the structure should be.

Any comments, suggestions, ideas?

Arnd

Arnd Bergmann (3):
headers: add more types to linux/types.h
headers: introduce linux/struct_types.h
headers: repurpose linux/fs_types.h

 arch/alpha/include/asm/spinlock_types.h       |    2 +-
 arch/arc/include/asm/atomic64-arcv2.h         |    4 -
 arch/arm/include/asm/atomic.h                 |    4 -
 arch/arm/include/asm/spinlock_types.h         |    2 +-
 arch/arm64/include/asm/spinlock_types.h       |    2 +-
 arch/csky/include/asm/spinlock_types.h        |    2 +-
 arch/hexagon/include/asm/spinlock_types.h     |    2 +-
 arch/ia64/include/asm/spinlock_types.h        |    2 +-
 .../include/asm/simple_spinlock_types.h       |    2 +-
 arch/powerpc/include/asm/spinlock_types.h     |    2 +-
 arch/riscv/include/asm/spinlock_types.h       |    2 +-
 arch/s390/include/asm/spinlock_types.h        |    2 +-
 arch/sh/include/asm/spinlock_types.h          |    2 +-
 arch/x86/include/asm/atomic64_32.h            |    4 -
 arch/xtensa/include/asm/spinlock_types.h      |    2 +-
 include/asm-generic/atomic64.h                |    4 -
 include/linux/atomic/atomic-long.h            |    4 +-
 include/linux/bitops.h                        |    6 -
 include/linux/bits.h                          |    6 +
 include/linux/bvec.h                          |   18 -
 include/linux/completion.h                    |   17 -
 include/linux/cpumask.h                       |    3 -
 include/linux/fs.h                            | 1151 +---------------
 include/linux/fs_types.h                      | 1225 ++++++++++++++++-
 include/linux/hrtimer.h                       |   32 -
 include/linux/kobject.h                       |   18 -
 include/linux/kref.h                          |    4 -
 include/linux/ktime.h                         |    3 -
 include/linux/list_bl.h                       |    7 -
 include/linux/list_lru.h                      |   15 -
 include/linux/llist.h                         |    8 -
 include/linux/mmzone.h                        |    3 -
 include/linux/mutex.h                         |   51 -
 include/linux/osq_lock.h                      |    8 -
 include/linux/percpu-rwsem.h                  |   11 -
 include/linux/pid.h                           |    9 -
 include/linux/plist.h                         |   10 -
 include/linux/quota.h                         |   29 -
 include/linux/rcu_sync.h                      |    9 -
 include/linux/rcuwait.h                       |   12 -
 include/linux/refcount.h                      |   12 -
 include/linux/rtmutex.h                       |    8 +-
 include/linux/rwbase_rt.h                     |    5 -
 include/linux/rwlock_types.h                  |   19 -
 include/linux/rwsem.h                         |   40 -
 include/linux/seqlock.h                       |   31 -
 include/linux/spinlock_types.h                |   21 -
 include/linux/spinlock_types_raw.h            |   21 +-
 include/linux/spinlock_types_up.h             |    2 +-
 include/linux/struct_types.h                  |  483 +++++++
 include/linux/swait.h                         |   12 -
 include/linux/time64.h                        |   13 -
 include/linux/timer.h                         |   16 +-
 include/linux/timerqueue.h                    |   12 +-
 include/linux/types.h                         |   90 +-
 include/linux/uidgid.h                        |    9 -
 include/linux/uuid.h                          |    6 -
 include/linux/wait.h                          |   29 -
 include/linux/workqueue.h                     |   27 -
 include/linux/xarray.h                        |   23 -
 60 files changed, 1822 insertions(+), 1756 deletions(-)
 create mode 100644 include/linux/struct_types.h
Signature · 25 lines
2.29.2

Cc: Al Viro <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Guenter Roeck <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Masahiro Yamada <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Nick Desaulniers <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Cc: kernel test robot <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Waiman Long <[email protected]>
Cc: Boqun Feng <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]