diff options
author | Damien Zammit <damien@zamaudio.com> | 2023-09-24 05:29:06 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-09-24 15:21:32 +0200 |
commit | 9d78d30a34ae406620b5b25847fc17ed2b08949a (patch) | |
tree | 5ed0cb4afd2fc096655c421b676de03e1775dc1e /kern | |
parent | 72180cd9ffa02b747d1e11d315b63d5f71436aba (diff) | |
download | gnumach-9d78d30a34ae406620b5b25847fc17ed2b08949a.tar.gz gnumach-9d78d30a34ae406620b5b25847fc17ed2b08949a.tar.bz2 gnumach-9d78d30a34ae406620b5b25847fc17ed2b08949a.zip |
percpu active_thread using gs segment
TESTED: As per previous commit
Message-Id: <20230924052824.449219-4-damien@zamaudio.com>
Diffstat (limited to 'kern')
-rw-r--r-- | kern/ipc_sched.c | 2 | ||||
-rw-r--r-- | kern/machine.c | 2 | ||||
-rw-r--r-- | kern/sched_prim.c | 2 | ||||
-rw-r--r-- | kern/startup.c | 2 | ||||
-rw-r--r-- | kern/thread.c | 3 | ||||
-rw-r--r-- | kern/thread.h | 3 | ||||
-rw-r--r-- | kern/timer.c | 4 |
7 files changed, 8 insertions, 10 deletions
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. |