aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i386/i386/cswitch.S2
-rw-r--r--i386/i386/i386asm.sym1
-rw-r--r--i386/i386/locore.S2
-rw-r--r--i386/i386/pcb.c2
-rw-r--r--i386/i386/percpu.h2
-rw-r--r--kern/ipc_sched.c2
-rw-r--r--kern/machine.c2
-rw-r--r--kern/sched_prim.c2
-rw-r--r--kern/startup.c2
-rw-r--r--kern/thread.c3
-rw-r--r--kern/thread.h3
-rw-r--r--kern/timer.c4
12 files changed, 13 insertions, 14 deletions
diff --git a/i386/i386/cswitch.S b/i386/i386/cswitch.S
index d97093ff..598e32cf 100644
--- a/i386/i386/cswitch.S
+++ b/i386/i386/cswitch.S
@@ -79,7 +79,7 @@ ENTRY(Switch_context)
lea KERNEL_STACK_SIZE-IKS_SIZE-IEL_SIZE(%ecx),%ebx
/* point to stack top */
- movl %esi,CX(EXT(active_threads),%edx) /* new thread is active */
+ movl %esi,MY(ACTIVE_THREAD) /* new thread is active */
movl %ecx,CX(EXT(active_stacks),%edx) /* set current stack */
movl %ebx,CX(EXT(kernel_stack),%edx) /* set stack top */
diff --git a/i386/i386/i386asm.sym b/i386/i386/i386asm.sym
index 1c4654db..e9a53bd5 100644
--- a/i386/i386/i386asm.sym
+++ b/i386/i386/i386asm.sym
@@ -54,6 +54,7 @@ expr CALL_PMAP_UPDATE
offset ApicLocalUnit lu apic_id APIC_ID
offset percpu pc cpu_id PERCPU_CPU_ID
+offset percpu pc active_thread PERCPU_ACTIVE_THREAD
size percpu pcs
diff --git a/i386/i386/locore.S b/i386/i386/locore.S
index 05b3b13d..8fba7638 100644
--- a/i386/i386/locore.S
+++ b/i386/i386/locore.S
@@ -1082,7 +1082,7 @@ syscall_entry_2:
* Check for MACH or emulated system call
*/
syscall_entry_3:
- movl CX(EXT(active_threads),%edx),%edx
+ movl MY(ACTIVE_THREAD),%edx
/* point to current thread */
movl TH_TASK(%edx),%edx /* point to task */
movl TASK_EMUL(%edx),%edx /* get emulation vector */
diff --git a/i386/i386/pcb.c b/i386/i386/pcb.c
index e0f4f57a..9576c147 100644
--- a/i386/i386/pcb.c
+++ b/i386/i386/pcb.c
@@ -316,7 +316,7 @@ void stack_handoff(
stack = current_stack();
old->kernel_stack = 0;
new->kernel_stack = stack;
- active_threads[mycpu] = new;
+ percpu_assign(active_thread, new);
/*
* Switch exception link to point to new
diff --git a/i386/i386/percpu.h b/i386/i386/percpu.h
index 202504da..ad4836ce 100644
--- a/i386/i386/percpu.h
+++ b/i386/i386/percpu.h
@@ -58,10 +58,10 @@ struct percpu {
int apic_id;
int cpu_id;
struct processor processor;
+ thread_t active_thread;
/*
struct machine_slot machine_slot;
struct mp_desc_table mp_desc_table;
- thread_t active_thread;
vm_offset_t active_stack;
vm_offset_t int_stack_top;
vm_offset_t int_stack_base;
diff --git a/kern/ipc_sched.c b/kern/ipc_sched.c
index be82971b..4519c654 100644
--- a/kern/ipc_sched.c
+++ b/kern/ipc_sched.c
@@ -233,7 +233,7 @@ thread_handoff(
/*
* stack_handoff is machine-dependent. It does the
* machine-dependent components of a context-switch, like
- * changing address spaces. It updates active_threads.
+ * changing address spaces. It updates active_thread.
*/
stack_handoff(old, new);
diff --git a/kern/machine.c b/kern/machine.c
index 0aa0f3c6..87fbc4d1 100644
--- a/kern/machine.c
+++ b/kern/machine.c
@@ -635,7 +635,7 @@ void processor_doshutdown(processor_t processor)
*/
PMAP_DEACTIVATE_KERNEL(cpu);
#ifndef MIGRATING_THREADS
- active_threads[cpu] = THREAD_NULL;
+ percpu_array[cpu].active_thread = THREAD_NULL;
#endif
cpu_down(cpu);
thread_wakeup((event_t)processor);
diff --git a/kern/sched_prim.c b/kern/sched_prim.c
index 6617db7c..5ee0521a 100644
--- a/kern/sched_prim.c
+++ b/kern/sched_prim.c
@@ -806,7 +806,7 @@ boolean_t thread_invoke(
/*
* switch_context is machine-dependent. It does the
* machine-dependent components of a context-switch, like
- * changing address spaces. It updates active_threads.
+ * changing address spaces. It updates active_thread.
* It returns only if a continuation is not supplied.
*/
counter(c_thread_invoke_csw++);
diff --git a/kern/startup.c b/kern/startup.c
index 88608c7d..13acb850 100644
--- a/kern/startup.c
+++ b/kern/startup.c
@@ -300,7 +300,7 @@ void cpu_launch_first_thread(thread_t th)
PMAP_ACTIVATE_KERNEL(mycpu);
- active_threads[mycpu] = th;
+ percpu_assign(active_thread, th);
active_stacks[mycpu] = th->kernel_stack;
thread_lock(th);
th->state &= ~TH_UNINT;
diff --git a/kern/thread.c b/kern/thread.c
index 9bbe8342..c397de84 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -69,7 +69,6 @@
#include <machine/pcb.h>
#include <machine/thread.h> /* for MACHINE_STACK */
-thread_t active_threads[NCPUS];
vm_offset_t active_stacks[NCPUS];
struct kmem_cache thread_cache;
@@ -2572,7 +2571,7 @@ kern_return_t processor_set_stack_usage(
stack = thread->kernel_stack;
for (cpu = 0; cpu < smp_get_numcpus(); cpu++)
- if (active_threads[cpu] == thread) {
+ if (percpu_array[cpu].active_thread == thread) {
stack = active_stacks[cpu];
break;
}
diff --git a/kern/thread.h b/kern/thread.h
index bf07828a..144160d5 100644
--- a/kern/thread.h
+++ b/kern/thread.h
@@ -269,7 +269,6 @@ typedef mach_port_t *thread_array_t;
#endif /* _KERN_KERN_TYPES_H_ */
-extern thread_t active_threads[NCPUS]; /* active threads */
extern vm_offset_t active_stacks[NCPUS]; /* active kernel stacks */
#ifdef KERNEL
@@ -415,7 +414,7 @@ extern void thread_unfreeze(
* designate this by defining CURRENT_THREAD.
*/
#ifndef CURRENT_THREAD
-#define current_thread() (active_threads[cpu_number()])
+#define current_thread() (percpu_get(thread_t, active_thread))
#endif /* CURRENT_THREAD */
#define current_stack() (active_stacks[cpu_number()])
diff --git a/kern/timer.c b/kern/timer.c
index 7d029b7c..13dfc207 100644
--- a/kern/timer.c
+++ b/kern/timer.c
@@ -132,7 +132,7 @@ time_trap_uentry(unsigned ts)
/*
* Record new timer.
*/
- mytimer = &(active_threads[mycpu]->system_timer);
+ mytimer = &(current_thread()->system_timer);
current_timer[mycpu] = mytimer;
mytimer->tstamp = ts;
}
@@ -170,7 +170,7 @@ time_trap_uexit(int ts)
timer_normalize(mytimer); /* SYSTEMMODE */
}
- mytimer = &(active_threads[mycpu]->user_timer);
+ mytimer = &(current_thread()->user_timer);
/*
* Record new timer.