diff options
author | davidxu <davidxu@FreeBSD.org> | 2006-12-20 04:40:39 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2006-12-20 04:40:39 +0000 |
commit | 5a984630fa31489671b035bd30308b299b2e2b50 (patch) | |
tree | 4b0b515b8835b611b65186836ed5b1502ed713d9 /sys/ia64 | |
parent | a2c03bf6cb1ee55d23a34b899999fb7fb95310a3 (diff) | |
download | FreeBSD-src-5a984630fa31489671b035bd30308b299b2e2b50.zip FreeBSD-src-5a984630fa31489671b035bd30308b299b2e2b50.tar.gz |
Add a lwpid field into per-cpu structure, the lwpid represents current
running thread's id on each cpu. This allow us to add in-kernel adaptive
spin for user level mutex. While spinning in user space is possible,
without correct thread running state exported from kernel, it hardly
can be implemented efficiently without wasting cpu cycles, however
exporting thread running state unlikely will be implemented soon as
it has to design and stablize interfaces. This implementation is
transparent to user space, it can be disabled dynamically. With this
change, mutex ping-pong program's performance is improved massively on
SMP machine. performance of mysql super-smack select benchmark is increased
about 7% on Intel dual dual-core2 Xeon machine, it indicates on systems
which have bunch of cpus and system-call overhead is low (athlon64, opteron,
and core-2 are known to be fast), the adaptive spin does help performance.
Added sysctls:
kern.threads.umtx_dflt_spins
if the sysctl value is non-zero, a zero umutex.m_spincount will
cause the sysctl value to be used a spin cycle count.
kern.threads.umtx_max_spins
the sysctl sets upper limit of spin cycle count.
Tested on: Athlon64 X2 3800+, Dual Xeon 5130
Diffstat (limited to 'sys/ia64')
-rw-r--r-- | sys/ia64/ia64/machdep.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index 7c2e1f5..9fe44a1 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -371,6 +371,7 @@ cpu_switch(struct thread *old, struct thread *new) oldpcb->pcb_current_pmap = pmap_switch(newpcb->pcb_current_pmap); PCPU_SET(curthread, new); + PCPU_SET(curtid, new->td_tid); #ifdef COMPAT_IA32 ia32_restorectx(newpcb); #endif @@ -391,6 +392,7 @@ cpu_throw(struct thread *old __unused, struct thread *new) newpcb = new->td_pcb; (void)pmap_switch(newpcb->pcb_current_pmap); PCPU_SET(curthread, new); + PCPU_SET(curtid, new->td_tid); #ifdef COMPAT_IA32 ia32_restorectx(newpcb); #endif @@ -609,6 +611,7 @@ ia64_init(void) ia64_set_k4((u_int64_t)pcpup); pcpu_init(pcpup, 0, sizeof(pcpu0)); PCPU_SET(curthread, &thread0); + PCPU_SET(curtid, thread0.td_tid); /* * Initialize the console before we print anything out. |