git: kernel - Fix very annoying lockup (SMP)
dillon at crater.dragonflybsd.org
Tue Jan 11 14:42:36 PST 2011
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date: Tue Jan 11 14:36:24 2011 -0800
kernel - Fix very annoying lockup (SMP)
* Fix an extremely annoying lockup that took a week+ to find. The cpusync
code is rather fragile and any for (;;) or while (1) style loops in the
kernel can trip it up and cause a deadlock. These loops are careful to
call lwkt_process_ipiq() to ensure that cpusync processing occurs.
However, there is a race in the LWKT thread migration code where a thread
deschedules itself on one cpu and schedules itself on another via a remote
ipi. The target cpu expects the thread's TDF_RUNNING state to clear and
will loop until that happens.
An IPI could sneak itself into the deschedule/lwkt_switch() path and
deadlock against a cpusync, preventing the thread from leaving the
The solution is to ensure that lwkt_process_ipiq() is *NOT* run in
the lwkt_switch() path if the calling thread has descheduled itself.
* The original bug could be reproduced by running blogbench in one window
and a while (1) ps axl shell script in another.
* Add DEBUG_PUSH_INFO(msg)/DEBUG_POP_INFO() macros which record (msg)
in the globaldata structure as a debugging aid.
* Remove unused platform/pc64/x86_64/systimer.c file. The entire contents
of this file was #ifdef'd out and its functionality is handled elsewhere
by the lapic timer code.
* #if 0 out numerous debugging bits but don't remove the code because it
is extremely useful for finding lockup conditions.
Summary of changes:
sys/kern/kern_ktr.c | 4 +
sys/kern/lwkt_ipiq.c | 52 ++++++++++++++++
sys/kern/lwkt_thread.c | 48 ++++++++++-----
sys/platform/pc32/apic/mpapic.c | 4 +
sys/platform/pc32/i386/pmap.c | 2 +
sys/platform/pc32/i386/pmap_inval.c | 2 +
sys/platform/pc64/apic/mpapic.c | 54 +++++++++++++---
sys/platform/pc64/conf/files | 1 -
sys/platform/pc64/x86_64/pmap.c | 2 +
sys/platform/pc64/x86_64/pmap_inval.c | 2 +
sys/platform/pc64/x86_64/systimer.c | 109 ---------------------------------
sys/sys/globaldata.h | 26 ++++++++-
12 files changed, 168 insertions(+), 138 deletions(-)
delete mode 100644 sys/platform/pc64/x86_64/systimer.c
DragonFly BSD source repository
More information about the Commits