Skip to contentSkip to conversation

cpumask: Don't use "proxy" headers

PATCH In review Andy Shevchenko 2 participants 5 messages Nov 24, 2025 – Nov 26, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpumask: Don't use "proxy" headers

Update header inclusions to follow IWYU (Include What You Use) principle.

Note that kernel.h is discouraged to be included as it's written at the top of that file.

---

Not fully compile tested, might give some compilation errors

 arch/x86/include/asm/cpumask.h |  2 ++
 include/linux/cpumask.h        | 12 +++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)
arch/x86/include/asm/cpumask.h +2 -0
index 70f6b60ad67b..9df9e9cde670 100644
@@ -2,6 +2,8 @@
 #ifndef _ASM_X86_CPUMASK_H
 #define _ASM_X86_CPUMASK_H
 #ifndef __ASSEMBLER__
+
+#include <linux/compiler.h>
 #include <linux/cpumask.h>
 
 extern void setup_cpu_local_masks(void);
include/linux/cpumask.h +7 -5
index 66694ee8d86e..6abf3d7e9435 100644
@@ -7,14 +7,16 @@
  * set of CPUs in a system, one bit position per CPU number.  In general,
  * only nr_cpu_ids (<= NR_CPUS) bits are valid.
  */
-#include <linux/cleanup.h>
-#include <linux/kernel.h>
-#include <linux/bitmap.h>
-#include <linux/cpumask_types.h>
 #include <linux/atomic.h>
-#include <linux/bug.h>
+#include <linux/bitmap.h>
+#include <linux/cleanup.h>
+#include <linux/cpumask_types.h>
 #include <linux/gfp_types.h>
 #include <linux/numa.h>
+#include <linux/threads.h>
+#include <linux/types.h>
+
+#include <asm/bug.h>
 
 /**
  * cpumask_pr_args - printf args to output a cpumask
Signature · 1 line
2.50.1
maintainer
#1 lore raw
Quoted 33 lines · Andy Shevchenko

Update header inclusions to follow IWYU (Include What You Use) principle.

Note that kernel.h is discouraged to be included as it's written at the top of that file.

---

Not fully compile tested, might give some compilation errors

 arch/x86/include/asm/cpumask.h |  2 ++
 include/linux/cpumask.h        | 12 +++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)
arch/x86/include/asm/cpumask.h +2 -0
index 70f6b60ad67b..9df9e9cde670 100644
@@ -2,6 +2,8 @@
 #ifndef _ASM_X86_CPUMASK_H
 #define _ASM_X86_CPUMASK_H
 #ifndef __ASSEMBLER__
+
+#include <linux/compiler.h>
 #include <linux/cpumask.h>
 
 extern void setup_cpu_local_masks(void);
include/linux/cpumask.h +0 -0
index 66694ee8d86e..6abf3d7e9435 100644

include/linux/cpumask.h line 11

Quoted 5 lines
include/linux/cpumask.h +0 -2
@@ -7,14 +7,16 @@
  * set of CPUs in a system, one bit position per CPU number.  In general,
  * only nr_cpu_ids (<= NR_CPUS) bits are valid.
  */
-#include <linux/cleanup.h>
-#include <linux/kernel.h>

I recall, removing kernel.h from cpumasks was a troublesome exercise back then. But it may be my false memory.

Added this for testing in bitmap-for-next.

Thanks,
Yury

Quoted 18 lines
include/linux/cpumask.h +7 -3
-#include <linux/bitmap.h>
-#include <linux/cpumask_types.h>
 #include <linux/atomic.h>
-#include <linux/bug.h>
+#include <linux/bitmap.h>
+#include <linux/cleanup.h>
+#include <linux/cpumask_types.h>
 #include <linux/gfp_types.h>
 #include <linux/numa.h>
+#include <linux/threads.h>
+#include <linux/types.h>
+
+#include <asm/bug.h>
 
 /**
  * cpumask_pr_args - printf args to output a cpumask
Signature · 1 line
2.50.1
#2 lore raw
Quoted 3 lines · Yury Norov
Quoted 1 line · Andy Shevchenko

Not fully compile tested, might give some compilation errors

...

Quoted 5 lines

include/linux/cpumask.h line 11

Quoted 2 lines
include/linux/cpumask.h +0 -2
-#include <linux/cleanup.h>
-#include <linux/kernel.h>

I recall, removing kernel.h from cpumasks was a troublesome exercise back then. But it may be my false memory.

Yeah, there are several headers that are too tangled together. At least it builds on my configurations on x86_64.

Quoted 1 line

Added this for testing in bitmap-for-next.

Thanks, let's see how it will go. But note that it might fall the builds in some cases.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Yury Norov
Quoted 1 line · Andy Shevchenko

Not fully compile tested, might give some compilation errors

...

Quoted 6 lines
Quoted 5 lines

include/linux/cpumask.h line 11

Quoted 2 lines
include/linux/cpumask.h +0 -2
-#include <linux/cleanup.h>
-#include <linux/kernel.h>

I recall, removing kernel.h from cpumasks was a troublesome exercise back then. But it may be my false memory.

Quoted 7 lines

Yeah, there are several headers that are too tangled together. At least it builds on my configurations on x86_64.

Quoted 1 line

Added this for testing in bitmap-for-next.

Thanks, let's see how it will go. But note that it might fall the builds in some cases.

So, we survived already a couple of Linux Next integration builds, I believe we are quite okay with this change and if anything appears, it can be fixed in a followups.

Thanks!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#4 lore raw
Quoted 17 lines · Andy Shevchenko
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Yury Norov
Quoted 1 line · Andy Shevchenko

Not fully compile tested, might give some compilation errors

...

Quoted 9 lines
Quoted 5 lines

include/linux/cpumask.h line 11

Quoted 2 lines
include/linux/cpumask.h +0 -2
-#include <linux/cleanup.h>
-#include <linux/kernel.h>

I recall, removing kernel.h from cpumasks was a troublesome exercise back then. But it may be my false memory.

Yeah, there are several headers that are too tangled together. At least it builds on my configurations on x86_64.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Added this for testing in bitmap-for-next.

Thanks, let's see how it will go. But note that it might fall the builds in some cases.

So, we survived already a couple of Linux Next integration builds, I believe we are quite okay with this change and if anything appears, it can be fixed in a followups.

Yeah. I'll just keep the patch in my branch, so hopefully it will land in mainline in the next merge cycle.

Thanks,
Yury