Cleanup cpumask.h inclusion in core headers
Subsystems (14)
Yury Norov
maintainercover Cleanup cpumask.h inclusion in core headers
Many core headers include linux/cpumask.h for nothing, and some others include it just for types. We already have nodemask_types.h, and this series adds cpumask_types.h to optimize core headers inclusion paths.
Interestingly, it doesn't improve on build time for me, but the headers cleanup work should keep going.
Yury Norov (6):
MAINTAINERS: add linux/nodemask_types.h to BITMAP API
sched: pre-caculate ilog2(TASK_REPORT_MAX)
cpumask: split out include/linux/cpumask_types.h
sched: drop dependency on cpumask.h
cpumask: cleanup core headers inclusion
cpumask: make core headers including cpumask_types.h where possible
Yury Norov (6):
MAINTAINERS: add linux/nodemask_types.h to BITMAP API
sched: pre-caculate ilog2(TASK_REPORT_MAX)
cpumask: split out include/linux/cpumask_types.h
sched: drop dependency on cpumask.h
cpumask: cleanup core headers inclusion
cpumask: make core headers including cpumask_types.h where possible
MAINTAINERS | 2 + include/linux/cacheinfo.h | 2 +- include/linux/cgroup.h | 1 - include/linux/clockchips.h | 2 +- include/linux/cpu.h | 1 - include/linux/cpu_cooling.h | 1 - include/linux/cpu_rmap.h | 2 +- include/linux/cpumask.h | 56 +---------------- include/linux/cpumask_types.h | 66 ++++++++++++++++++++ include/linux/interrupt.h | 2 +- include/linux/irqchip/irq-partition-percpu.h | 2 +- include/linux/kernel_stat.h | 1 - include/linux/msi.h | 2 +- include/linux/node.h | 1 - include/linux/percpu.h | 1 - include/linux/pm_domain.h | 2 +- include/linux/profile.h | 1 - include/linux/rcupdate.h | 1 - include/linux/sched.h | 7 ++- include/linux/seq_file.h | 1 - include/linux/stop_machine.h | 2 +- include/linux/torture.h | 2 +- include/linux/tracepoint.h | 1 - include/linux/workqueue.h | 2 +- 24 files changed, 83 insertions(+), 78 deletions(-) create mode 100644 include/linux/cpumask_types.h
Signature · 1 line
2.40.1
Yury Norov
maintainerPATCH 1/6 MAINTAINERS: add linux/nodemask_types.h to BITMAP API
Commit bea32141764b ("nodemask: Split out include/linux/nodemask_types.h") added the nodemask_types.h but didn't cover it with corresponding record in the MAINTAINERS file.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -3733,6 +3733,7 @@ F: include/linux/bits.h F: include/linux/cpumask.h F: include/linux/find.h F: include/linux/nodemask.h +F: include/linux/nodemask_types.h F: include/vdso/bits.h F: lib/bitmap-str.c F: lib/bitmap.c
Signature · 1 line
2.40.1
Yury Norov
maintainerPATCH 2/6 sched: avoid using ilog2() in sched.h
In reply to Yury Norov<linux/sched.h> indirectly via cpumask.h path includes the ilog2.h header to calculate ilog2(TASK_REPORT_MAX). The following patches drops sched.h dependency on cpumask.h, and to have a successful build, the header has to be included explicitly.
sched.h is a frequently included header, and it's better to keep the dependency list as small as possible. So, instead of including ilog2.h for a single BUILD_BUG_ON() check, the same check may be implemented by taking exponent of the other part of equation.
--- include/linux/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sched.h +1 -1
@@ -1604,7 +1604,7 @@ static inline char task_index_to_char(unsigned int state) {static const char state_char[] ="RSDTtXZPI" ; -BUILD_BUG_ON (1 +ilog2 (TASK_REPORT_MAX ) !=sizeof (state_char) -1 ); +BUILD_BUG_ON (TASK_REPORT_MAX *2 !=1 << (sizeof (state_char) -1 ));return state_char[state]; }
Signature · 1 line
2.40.1
Yury Norov
maintainerPATCH 3/6 cpumask: split out include/linux/cpumask_types.h
In reply to Yury NorovFrom: Yury Norov <[email protected]>
Many core headers, like sched.h, include cpumask.h mostly for struct cpumask and cpumask_var_t. Those are frequently used headers and shouldn't pull more than the bare minimum.
--- MAINTAINERS | 1 + include/linux/cpumask.h | 56 +---------------------------- include/linux/cpumask_types.h | 66 +++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 55 deletions(-) create mode 100644 include/linux/cpumask_types.h
MAINTAINERS +1 -0
@@ -3731,6 +3731,7 @@ F: include/linux/bitmap-str.h F: include/linux/bitmap.h F: include/linux/bits.h F: include/linux/cpumask.h +F: include/linux/cpumask_types.h F: include/linux/find.h F: include/linux/nodemask.h F: include/linux/nodemask_types.h
include/linux/cpumask.h +1 -55
81 lines not on this page · raw message
include/linux/cpumask_types.h new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.40.1
Yury Norov
maintainerPATCH 4/6 sched: drop sched.h dependency on cpumask
In reply to Yury Norovsched.h needs cpumask.h mostly for types declaration. Now that we have cpumask_types.h, which is a significantly smaller header, we can rely on it.
The only exception is UP stub for set_cpus_allowed_ptr(). The function needs to test bit #0 in a @new_mask, which can be trivially opencoded.
--- include/linux/sched.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/linux/sched.h +3 -2
@@ -13,7 +13,7 @@#include <asm/processor.h> #include <linux/thread_info.h> #include <linux/preempt.h> -#include <linux/cpumask.h> +#include <linux/cpumask_types.h> #include <linux/cache.h> #include <linux/irqflags_types.h>
@@ -1778,7 +1778,8 @@ static inline void do_set_cpus_allowed(struct task_struct *p, const struct cpuma }static inline int set_cpus_allowed_ptr (struct task_struct *p,const struct cpumask *new_mask) { -if (!cpumask_test_cpu (0 , new_mask)) +/* Opencoded cpumask_test_cpu(0, new_mask) to avoid dependency on cpumask.h */ +if ((*cpumask_bits (new_mask) &1 ) ==0 )return -EINVAL ;return 0 ; }
Signature · 1 line
2.40.1
Yury Norov
maintainerPATCH 5/6 cpumask: cleanup core headers inclusion
In reply to Yury NorovMany core headers include cpumask.h for nothing. Drop it.
--- include/linux/cgroup.h | 1 - include/linux/cpu.h | 1 - include/linux/cpu_cooling.h | 1 - include/linux/kernel_stat.h | 1 - include/linux/node.h | 1 - include/linux/percpu.h | 1 - include/linux/profile.h | 1 - include/linux/rcupdate.h | 1 - include/linux/seq_file.h | 1 - include/linux/tracepoint.h | 1 - 10 files changed, 10 deletions(-)
include/linux/cgroup.h +0 -1
@@ -10,7 +10,6 @@*/ #include <linux/sched.h> -#include <linux/cpumask.h> #include <linux/nodemask.h> #include <linux/rculist.h> #include <linux/cgroupstats.h>
include/linux/cpu.h +0 -1
@@ -16,7 +16,6 @@#include <linux/node.h> #include <linux/compiler.h> -#include <linux/cpumask.h> #include <linux/cpuhotplug.h> #include <linux/cpu_smt.h>
include/linux/cpu_cooling.h +0 -1
@@ -15,7 +15,6 @@#include <linux/of.h> #include <linux/thermal.h> -#include <linux/cpumask.h> struct cpufreq_policy ;
include/linux/kernel_stat.h +0 -1
@@ -5,7 +5,6 @@#include <linux/smp.h> #include <linux/threads.h> #include <linux/percpu.h> -#include <linux/cpumask.h> #include <linux/interrupt.h> #include <linux/sched.h> #include <linux/vtime.h>
include/linux/node.h +0 -1
@@ -16,7 +16,6 @@#define _LINUX_NODE_H_#include <linux/device.h> -#include <linux/cpumask.h> #include <linux/list.h> /**
include/linux/percpu.h +0 -1
@@ -6,7 +6,6 @@#include <linux/mmdebug.h> #include <linux/preempt.h> #include <linux/smp.h> -#include <linux/cpumask.h> #include <linux/pfn.h> #include <linux/init.h> #include <linux/cleanup.h>
include/linux/profile.h +0 -1
@@ -4,7 +4,6 @@#include <linux/kernel.h> #include <linux/init.h> -#include <linux/cpumask.h> #include <linux/cache.h> #include <asm/errno.h>
include/linux/rcupdate.h +0 -1
@@ -29,7 +29,6 @@#include <linux/lockdep.h> #include <linux/cleanup.h> #include <asm/processor.h> -#include <linux/cpumask.h> #include <linux/context_tracking_irq.h> #define ULONG_CMP_GE (a, b) (ULONG_MAX / 2 >= (a) - (b))
include/linux/seq_file.h +0 -1
@@ -7,7 +7,6 @@#include <linux/string_helpers.h> #include <linux/bug.h> #include <linux/mutex.h> -#include <linux/cpumask.h> #include <linux/nodemask.h> #include <linux/fs.h> #include <linux/cred.h>
include/linux/tracepoint.h +0 -1
@@ -16,7 +16,6 @@#include <linux/srcu.h> #include <linux/errno.h> #include <linux/types.h> -#include <linux/cpumask.h> #include <linux/rcupdate.h> #include <linux/tracepoint-defs.h> #include <linux/static_call.h>
Signature · 1 line
2.40.1
Yury Norov
maintainerPATCH 6/6 cpumask: make core headers including cpumask_types.h where possible
In reply to Yury NorovNow that cpumask types are split out to a separate smaller header, many frequently included core headers may switch to using it.
--- include/linux/cacheinfo.h | 2 +- include/linux/clockchips.h | 2 +- include/linux/cpu_rmap.h | 2 +- include/linux/interrupt.h | 2 +- include/linux/irqchip/irq-partition-percpu.h | 2 +- include/linux/msi.h | 2 +- include/linux/pm_domain.h | 2 +- include/linux/stop_machine.h | 2 +- include/linux/torture.h | 2 +- include/linux/workqueue.h | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-)
include/linux/cacheinfo.h +1 -1
@@ -3,7 +3,7 @@#define _LINUX_CACHEINFO_H#include <linux/bitops.h> -#include <linux/cpumask.h> +#include <linux/cpumask_types.h> #include <linux/smp.h> struct device_node ;
include/linux/clockchips.h +1 -1
@@ -12,7 +12,7 @@#ifdef CONFIG_GENERIC_CLOCKEVENTS # include <linux/clocksource.h> -# include <linux/cpumask.h> +# include <linux/cpumask_types.h> # include <linux/ktime.h> # include <linux/notifier.h>
include/linux/cpu_rmap.h +1 -1
@@ -7,7 +7,7 @@* Copyright 2011 Solarflare Communications Inc. */ -#include <linux/cpumask.h> +#include <linux/cpumask_types.h> #include <linux/gfp.h> #include <linux/slab.h> #include <linux/kref.h>
include/linux/interrupt.h +1 -1
@@ -5,7 +5,7 @@#include <linux/kernel.h> #include <linux/bitops.h> -#include <linux/cpumask.h> +#include <linux/cpumask_types.h> #include <linux/irqreturn.h> #include <linux/irqnr.h> #include <linux/hardirq.h>
include/linux/irqchip/irq-partition-percpu.h +1 -1
@@ -8,7 +8,7 @@#define __LINUX_IRQCHIP_IRQ_PARTITION_PERCPU_H#include <linux/fwnode.h> -#include <linux/cpumask.h> +#include <linux/cpumask_types.h> #include <linux/irqdomain.h> struct partition_affinity {
include/linux/msi.h +1 -1
@@ -19,7 +19,7 @@*/ #include <linux/irqdomain_defs.h> -#include <linux/cpumask.h> +#include <linux/cpumask_types.h> #include <linux/msi_api.h> #include <linux/xarray.h> #include <linux/mutex.h>
include/linux/pm_domain.h +1 -1
@@ -16,7 +16,7 @@#include <linux/of.h> #include <linux/notifier.h> #include <linux/spinlock.h> -#include <linux/cpumask.h> +#include <linux/cpumask_types.h> #include <linux/time64.h> /*
include/linux/stop_machine.h +1 -1
@@ -3,7 +3,7 @@#define _LINUX_STOP_MACHINE#include <linux/cpu.h> -#include <linux/cpumask.h> +#include <linux/cpumask_types.h> #include <linux/smp.h> #include <linux/list.h>
include/linux/torture.h +1 -1
@@ -14,7 +14,7 @@#include <linux/cache.h> #include <linux/spinlock.h> #include <linux/threads.h> -#include <linux/cpumask.h> +#include <linux/cpumask_types.h> #include <linux/seqlock.h> #include <linux/lockdep.h> #include <linux/completion.h>
include/linux/workqueue.h +1 -1
@@ -12,7 +12,7 @@#include <linux/lockdep.h> #include <linux/threads.h> #include <linux/atomic.h> -#include <linux/cpumask.h> +#include <linux/cpumask_types.h> #include <linux/rcupdate.h> #include <linux/workqueue_types.h>
Signature · 1 line
2.40.1