parisc: move CPU field back into thread_info
authorArd Biesheuvel <ardb@kernel.org>
Thu, 4 Nov 2021 08:26:28 +0000 (09:26 +0100)
committerHelge Deller <deller@gmx.de>
Thu, 4 Nov 2021 10:21:47 +0000 (11:21 +0100)
In commit 2214c0e77259 ("parisc: Move thread_info into task struct")
PA-RISC gained support for THREAD_INFO_IN_TASK while changes were
already underway to keep the CPU field in thread_info rather than move
it into task_struct when THREAD_INFO_IN_TASK is enabled. The result is a
broken build for all PA-RISC configs that enable SMP.

So let's partially revert that commit, and get rid of the ugly hack to
get at the offset of task_struct::cpu without having to include
linux/sched.h, and put the CPU field back where it was before.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Fixes: bcf9033e5449 ("sched: move CPU field back into thread_info if THREAD_INFO_IN_TASK=y")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Helge Deller <deller@gmx.de>
arch/parisc/include/asm/smp.h
arch/parisc/include/asm/thread_info.h
arch/parisc/kernel/asm-offsets.c
arch/parisc/kernel/smp.c

index 16d41127500ed381798bfc04f18c5863f48e0de8..2279ebe5e2dad1028147dee2e858607be621f311 100644 (file)
@@ -32,25 +32,10 @@ extern void smp_send_all_nop(void);
 extern void arch_send_call_function_single_ipi(int cpu);
 extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
 
+#define raw_smp_processor_id()         (current_thread_info()->cpu)
+
 #endif /* !ASSEMBLY */
 
-/*
- * 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
-#include <asm/asm-offsets.h>
-#define raw_smp_processor_id()         (*(unsigned int *)((void *)current + TASK_CPU))
-#endif
 #else /* CONFIG_SMP */
 
 static inline void smp_send_all_nop(void) { return; }
index 75657c2c54e115a11f196538f865d322c8f97b39..1a58795f785c59e2c0b6bea77ed8822e9a629a42 100644 (file)
@@ -9,6 +9,9 @@
 struct thread_info {
        unsigned long flags;            /* thread_info flags (see TIF_*) */
        int preempt_count;              /* 0=premptable, <0=BUG; will also serve as bh-counter */
+#ifdef CONFIG_SMP
+       unsigned int cpu;
+#endif
 };
 
 #define INIT_THREAD_INFO(tsk)                  \
index e351540354416610f07ea5dadc265ef290beb0ea..55c1c5189c6a72b45a02b8cc131f7c1b6d5010b8 100644 (file)
@@ -14,8 +14,6 @@
  *    Copyright (C) 2003 James Bottomley <jejb at parisc-linux.org>
  */
 
-#define GENERATING_ASM_OFFSETS /* asm/smp.h */
-
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/thread_info.h>
@@ -39,9 +37,6 @@ int main(void)
 {
        DEFINE(TASK_TI_FLAGS, offsetof(struct task_struct, thread_info.flags));
        DEFINE(TASK_STACK, offsetof(struct task_struct, stack));
-#ifdef CONFIG_SMP
-       DEFINE(TASK_CPU, offsetof(struct task_struct, cpu));
-#endif
        BLANK();
        DEFINE(TASK_REGS, offsetof(struct task_struct, thread.regs));
        DEFINE(TASK_PT_PSW, offsetof(struct task_struct, thread.regs.gr[ 0]));
index 171925285f3ebbfe59c121aa67eaf955a568c269..a32a882a2d58beb9a378cb19d87e9409bbe3d432 100644 (file)
@@ -339,8 +339,6 @@ int smp_boot_one_cpu(int cpuid, struct task_struct *idle)
        const struct cpuinfo_parisc *p = &per_cpu(cpu_data, cpuid);
        long timeout;
 
-       idle->cpu = cpuid;
-
        /* Let _start know what logical CPU we're booting
        ** (offset into init_tasks[],cpu_data[])
        */