powerpc: smp: remove hack to obtain offset of task_struct::cpu
authorArd Biesheuvel <ardb@kernel.org>
Tue, 14 Sep 2021 12:10:34 +0000 (14:10 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Thu, 30 Sep 2021 14:13:11 +0000 (16:13 +0200)
Instead of relying on awful hacks to obtain the offset of the cpu field
in struct task_struct, move it back into struct thread_info, which does
not create the same level of circular dependency hell when trying to
include the header file that defines it.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/Makefile
arch/powerpc/include/asm/smp.h
arch/powerpc/kernel/asm-offsets.c

index aa6808e706470d9c109c28647ac3da7c0451623f..54cad1faa5d071dd4b0b0a8281187df2382def96 100644 (file)
@@ -446,17 +446,6 @@ else
 endif
 endif
 
-ifdef CONFIG_SMP
-ifdef CONFIG_PPC32
-prepare: task_cpu_prepare
-
-PHONY += task_cpu_prepare
-task_cpu_prepare: prepare0
-       $(eval KBUILD_CFLAGS += -D_TASK_CPU=$(shell awk '{if ($$2 == "TASK_CPU") print $$3;}' include/generated/asm-offsets.h))
-
-endif # CONFIG_PPC32
-endif # CONFIG_SMP
-
 PHONY += checkbin
 # Check toolchain versions:
 # - gcc-4.6 is the minimum kernel-wide version so nothing required.
index 7ef1cd8168a055cd4a9c6211446df9ef4c80f4a2..007332a4a73257ed88d412957071281fd0c7cbc7 100644 (file)
@@ -87,22 +87,7 @@ int is_cpu_dead(unsigned int cpu);
 /* 32-bit */
 extern int smp_hw_index[];
 
-/*
- * This is particularly ugly: it appears we can't actually get the definition
- * of task_struct here, but we need access to the CPU this task is running on.
- * Instead of using task_struct we're using _TASK_CPU which is extracted from
- * asm-offsets.h by kbuild to get the current processor ID.
- *
- * This also needs to be safeguarded when building asm-offsets.s because at
- * that time _TASK_CPU is not defined yet. It could have been guarded by
- * _TASK_CPU itself, but we want the build to fail if _TASK_CPU is missing
- * when building something else than asm-offsets.s
- */
-#ifdef GENERATING_ASM_OFFSETS
-#define raw_smp_processor_id()         (0)
-#else
-#define raw_smp_processor_id()         (*(unsigned int *)((void *)current + _TASK_CPU))
-#endif
+#define raw_smp_processor_id()         (current_thread_info()->cpu)
 #define hard_smp_processor_id()        (smp_hw_index[smp_processor_id()])
 
 static inline int get_hard_smp_processor_id(int cpu)
index e37e4546034e8b0cefcabea0a27ba842b2fc0cfb..cc05522f50bf7b6c8492e8a19108a76ced215e7f 100644 (file)
@@ -9,8 +9,6 @@
  * #defines from the assembly-language output.
  */
 
-#define GENERATING_ASM_OFFSETS /* asm/smp.h */
-
 #include <linux/compat.h>
 #include <linux/signal.h>
 #include <linux/sched.h>