diff -ruN linux-2.4.18/arch/i386/kernel/smpboot.c linux-2.4.18.up-opt/arch/i386/kernel/smpboot.c --- linux-2.4.18/arch/i386/kernel/smpboot.c Fri Dec 21 23:19:54 2001 +++ linux-2.4.18.up-opt/arch/i386/kernel/smpboot.c Tue Feb 26 13:40:57 2002 @@ -365,7 +365,7 @@ * (This works even if the APIC is not enabled.) */ phys_id = GET_APIC_ID(apic_read(APIC_ID)); - cpuid = current->processor; + cpuid = task_cpu(current); if (test_and_set_bit(cpuid, &cpu_online_map)) { printk("huh, phys CPU#%d, CPU#%d already present??\n", phys_id, cpuid); @@ -803,7 +803,7 @@ if (!idle) panic("No idle process for CPU %d", cpu); - idle->processor = cpu; + set_task_cpu(idle, cpu); idle->cpus_runnable = 1 << cpu; /* we schedule the first task manually */ map_cpu_to_boot_apicid(cpu, apicid); @@ -1020,7 +1020,7 @@ map_cpu_to_boot_apicid(0, boot_cpu_apicid); global_irq_holder = 0; - current->processor = 0; + set_task_cpu(current, 0); init_idle(); smp_tune_scheduling(); diff -ruN linux-2.4.18/fs/proc/array.c linux-2.4.18.up-opt/fs/proc/array.c --- linux-2.4.18/fs/proc/array.c Wed Oct 24 11:59:15 2001 +++ linux-2.4.18.up-opt/fs/proc/array.c Tue Feb 26 13:40:57 2002 @@ -387,7 +387,7 @@ task->nswap, task->cnswap, task->exit_signal, - task->processor); + task_cpu(task)); if(mm) mmput(mm); return res; diff -ruN linux-2.4.18/include/asm-i386/smp.h linux-2.4.18.up-opt/include/asm-i386/smp.h --- linux-2.4.18/include/asm-i386/smp.h Fri Dec 21 23:19:55 2001 +++ linux-2.4.18.up-opt/include/asm-i386/smp.h Tue Feb 26 13:40:57 2002 @@ -104,7 +104,7 @@ * so this is correct in the x86 case. */ -#define smp_processor_id() (current->processor) +#define smp_processor_id() task_cpu(current) static __inline int hard_smp_processor_id(void) { diff -ruN linux-2.4.18/include/linux/sched.h linux-2.4.18.up-opt/include/linux/sched.h --- linux-2.4.18/include/linux/sched.h Fri Dec 21 23:19:55 2001 +++ linux-2.4.18.up-opt/include/linux/sched.h Tue Feb 26 13:40:57 2002 @@ -278,6 +278,17 @@ extern struct user_struct root_user; #define INIT_USER (&root_user) +/* XXX: move to ? */ +#ifdef CONFIG_SMP +typedef struct { int val; } cpu_t; +static inline int cpu_get(const cpu_t *cpu) { return cpu->val; } +static inline void cpu_set(cpu_t *cpu, int val) { cpu->val = val; } +#else +typedef struct { } cpu_t; +static inline int cpu_get(const cpu_t *cpu) { return 0; } +static inline void cpu_set(const cpu_t *cpu, int val) { } +#endif + struct task_struct { /* * offsets of these are hardcoded elsewhere - touch with care @@ -304,7 +315,7 @@ long nice; unsigned long policy; struct mm_struct *mm; - int processor; + cpu_t _cpu; /* * cpus_runnable is ~0 if the process is not running on any * CPU. It's (1 << cpu) if it's running on a CPU. This mask @@ -412,6 +423,16 @@ void *journal_info; }; +static inline int task_cpu(const struct task_struct *p) +{ + return cpu_get(&p->_cpu); +} + +static inline void set_task_cpu(struct task_struct *p, int cpu) +{ + cpu_set(&p->_cpu, cpu); +} + /* * Per process flags */ @@ -555,7 +576,7 @@ static inline void task_set_cpu(struct task_struct *tsk, unsigned int cpu) { - tsk->processor = cpu; + set_task_cpu(tsk, cpu); tsk->cpus_runnable = 1UL << cpu; } diff -ruN linux-2.4.18/init/main.c linux-2.4.18.up-opt/init/main.c --- linux-2.4.18/init/main.c Tue Feb 26 13:26:58 2002 +++ linux-2.4.18.up-opt/init/main.c Tue Feb 26 13:40:57 2002 @@ -507,7 +507,7 @@ /* Get other processors into their bootup holding patterns. */ smp_boot_cpus(); wait_init_idle = cpu_online_map; - clear_bit(current->processor, &wait_init_idle); /* Don't wait on me! */ + clear_bit(task_cpu(current), &wait_init_idle); /* Don't wait on me! */ smp_threads_ready=1; smp_commence(); diff -ruN linux-2.4.18/kernel/fork.c linux-2.4.18.up-opt/kernel/fork.c --- linux-2.4.18/kernel/fork.c Tue Feb 26 13:26:58 2002 +++ linux-2.4.18.up-opt/kernel/fork.c Tue Feb 26 13:40:57 2002 @@ -649,7 +649,7 @@ { int i; p->cpus_runnable = ~0UL; - p->processor = current->processor; + set_task_cpu(p, task_cpu(current)); /* ?? should we just memset this ?? */ for(i = 0; i < smp_num_cpus; i++) p->per_cpu_utime[i] = p->per_cpu_stime[i] = 0; diff -ruN linux-2.4.18/kernel/sched.c linux-2.4.18.up-opt/kernel/sched.c --- linux-2.4.18/kernel/sched.c Fri Dec 21 23:19:55 2001 +++ linux-2.4.18.up-opt/kernel/sched.c Tue Feb 26 13:40:57 2002 @@ -172,7 +172,7 @@ #ifdef CONFIG_SMP /* Give a largish advantage to the same processor... */ /* (this is equivalent to penalizing other processors) */ - if (p->processor == this_cpu) + if (task_cpu(p) == this_cpu) weight += PROC_CHANGE_PENALTY; #endif @@ -221,7 +221,7 @@ * shortcut if the woken up task's last CPU is * idle now. */ - best_cpu = p->processor; + best_cpu = task_cpu(p); if (can_schedule(p, best_cpu)) { tsk = idle_task(best_cpu); if (cpu_curr(best_cpu) == tsk) { @@ -295,12 +295,12 @@ tsk = target_tsk; if (tsk) { if (oldest_idle != -1ULL) { - best_cpu = tsk->processor; + best_cpu = task_cpu(tsk); goto send_now_idle; } tsk->need_resched = 1; - if (tsk->processor != this_cpu) - smp_send_reschedule(tsk->processor); + if (task_cpu(tsk) != this_cpu) + smp_send_reschedule(task_cpu(tsk)); } return; @@ -559,7 +559,7 @@ if (!current->active_mm) BUG(); need_resched_back: prev = current; - this_cpu = prev->processor; + this_cpu = task_cpu(prev); if (unlikely(in_interrupt())) { printk("Scheduling in interrupt\n"); @@ -1311,7 +1311,7 @@ } sched_data->curr = current; sched_data->last_schedule = get_cycles(); - clear_bit(current->processor, &wait_init_idle); + clear_bit(task_cpu(current), &wait_init_idle); } extern void init_timervecs (void); @@ -1325,7 +1325,7 @@ int cpu = smp_processor_id(); int nr; - init_task.processor = cpu; + set_task_cpu(&init_task, cpu); for(nr = 0; nr < PIDHASH_SZ; nr++) pidhash[nr] = NULL; diff -ruN linux-2.4.18/kernel/signal.c linux-2.4.18.up-opt/kernel/signal.c --- linux-2.4.18/kernel/signal.c Fri Nov 23 22:40:15 2001 +++ linux-2.4.18.up-opt/kernel/signal.c Tue Feb 26 13:40:57 2002 @@ -479,8 +479,8 @@ * other than doing an extra (lightweight) IPI interrupt. */ spin_lock(&runqueue_lock); - if (task_has_cpu(t) && t->processor != smp_processor_id()) - smp_send_reschedule(t->processor); + if (task_has_cpu(t) && task_cpu(t) != smp_processor_id()) + smp_send_reschedule(task_cpu(t)); spin_unlock(&runqueue_lock); #endif /* CONFIG_SMP */