On Wed, Sep 08, 2021 at 12:06:02PM -0700, Keith Packard wrote: > To allow architectures to use the 'cpu' field in task_struct for cpu > identification, the task_struct must be visible whereever the > raw_smp_processor_id macro is used. It would be simplest to include > linux/sched.h from the relevant asm/smp.h file, but that file is > included from linux/sched.h, and the recursive include ends up with > several declarations in the wrong order. > > To avoid this, the PowerPC architecture code has this ugly hack: > > #define raw_smp_processor_id() \ > (*(unsigned int *)((void *)current + _TASK_CPU)) > > As an alternative, placing includes of linux/sched.h in a few files > that are used along with asm/smp.h means we can use the task_struct > field directly. > > Signed-off-by: Keith Packard <keithpac@xxxxxxxxxx> > --- > arch/arm/mm/proc-v7-bugs.c | 1 + > drivers/vhost/vhost.c | 1 + > drivers/vhost/vhost.h | 1 + > include/asm-generic/irq_regs.h | 1 + > include/linux/of_address.h | 1 + Where does the DT code use raw_smp_processor_id()? The header itself certainly doesn't and the headers should only include what the headers use directly. In general this seems pretty terrible pulling in all of sched.h (and then everything else it includes) for just raw_smp_processor_id(). > include/linux/random.h | 1 + > include/linux/topology.h | 1 + > init/calibrate.c | 1 + > kernel/bpf/bpf_lru_list.h | 1 + > kernel/bpf/percpu_freelist.h | 1 + > kernel/sched/cpuacct.c | 2 +- > lib/irq_regs.c | 1 + > 12 files changed, 12 insertions(+), 1 deletion(-)