Skip to content

Commit 336868a

Browse files
committed
powerpc: smp: remove hack to obtain offset of task_struct::cpu
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 <[email protected]> Acked-by: Mark Rutland <[email protected]> Acked-by: Michael Ellerman <[email protected]>
1 parent bcf9033 commit 336868a

File tree

3 files changed

+1
-29
lines changed

3 files changed

+1
-29
lines changed

arch/powerpc/Makefile

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -446,17 +446,6 @@ else
446446
endif
447447
endif
448448

449-
ifdef CONFIG_SMP
450-
ifdef CONFIG_PPC32
451-
prepare: task_cpu_prepare
452-
453-
PHONY += task_cpu_prepare
454-
task_cpu_prepare: prepare0
455-
$(eval KBUILD_CFLAGS += -D_TASK_CPU=$(shell awk '{if ($$2 == "TASK_CPU") print $$3;}' include/generated/asm-offsets.h))
456-
457-
endif # CONFIG_PPC32
458-
endif # CONFIG_SMP
459-
460449
PHONY += checkbin
461450
# Check toolchain versions:
462451
# - gcc-4.6 is the minimum kernel-wide version so nothing required.

arch/powerpc/include/asm/smp.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,7 @@ int is_cpu_dead(unsigned int cpu);
8787
/* 32-bit */
8888
extern int smp_hw_index[];
8989

90-
/*
91-
* This is particularly ugly: it appears we can't actually get the definition
92-
* of task_struct here, but we need access to the CPU this task is running on.
93-
* Instead of using task_struct we're using _TASK_CPU which is extracted from
94-
* asm-offsets.h by kbuild to get the current processor ID.
95-
*
96-
* This also needs to be safeguarded when building asm-offsets.s because at
97-
* that time _TASK_CPU is not defined yet. It could have been guarded by
98-
* _TASK_CPU itself, but we want the build to fail if _TASK_CPU is missing
99-
* when building something else than asm-offsets.s
100-
*/
101-
#ifdef GENERATING_ASM_OFFSETS
102-
#define raw_smp_processor_id() (0)
103-
#else
104-
#define raw_smp_processor_id() (*(unsigned int *)((void *)current + _TASK_CPU))
105-
#endif
90+
#define raw_smp_processor_id() (current_thread_info()->cpu)
10691
#define hard_smp_processor_id() (smp_hw_index[smp_processor_id()])
10792

10893
static inline int get_hard_smp_processor_id(int cpu)

arch/powerpc/kernel/asm-offsets.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
* #defines from the assembly-language output.
1010
*/
1111

12-
#define GENERATING_ASM_OFFSETS /* asm/smp.h */
13-
1412
#include <linux/compat.h>
1513
#include <linux/signal.h>
1614
#include <linux/sched.h>

0 commit comments

Comments
 (0)