Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern There's a locking order issue with the scheduler an...



details:   https://anonhg.NetBSD.org/src/rev/32dee1be2cad
branches:  trunk
changeset: 542406:32dee1be2cad
user:      pk <pk%NetBSD.org@localhost>
date:      Mon Jan 27 22:38:24 2003 +0000

description:
There's a locking order issue with the scheduler and the callwheel locks
as ltsleep() may call callout_reset() with the scheduler lock held.
So, prevent interrupts that may take the scheduler lock while holding
the callwheel lock.

diffstat:

 sys/kern/kern_clock.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (57 lines):

diff -r 75c256aa0ca7 -r 32dee1be2cad sys/kern/kern_clock.c
--- a/sys/kern/kern_clock.c     Mon Jan 27 22:31:12 2003 +0000
+++ b/sys/kern/kern_clock.c     Mon Jan 27 22:38:24 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_clock.c,v 1.82 2003/01/18 10:06:24 thorpej Exp $  */
+/*     $NetBSD: kern_clock.c,v 1.83 2003/01/27 22:38:24 pk Exp $       */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.82 2003/01/18 10:06:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.83 2003/01/27 22:38:24 pk Exp $");
 
 #include "opt_callout.h"
 #include "opt_ntp.h"
@@ -390,7 +390,7 @@
 
 #define        CALLWHEEL_LOCK(s)                                               \
 do {                                                                   \
-       s = splclock();                                                 \
+       s = splsched();                                                 \
        simple_lock(&callwheel_slock);                                  \
 } while (/*CONSTCOND*/ 0)
 
@@ -527,6 +527,7 @@
        extern long timedelta;
        struct cpu_info *ci = curcpu();
        struct ptimer *pt;
+       int s;
 #ifdef NTP
        int time_update;
        int ltemp;
@@ -890,10 +891,10 @@
         * Process callouts at a very low cpu priority, so we don't keep the
         * relatively high clock interrupt priority any longer than necessary.
         */
-       simple_lock(&callwheel_slock);  /* already at splclock() */
+       CALLWHEEL_LOCK(s);
        hardclock_ticks++;
        if (! TAILQ_EMPTY(&callwheel[hardclock_ticks & callwheelmask].cq_q)) {
-               simple_unlock(&callwheel_slock);
+               CALLWHEEL_UNLOCK(s);
                if (CLKF_BASEPRI(frame)) {
                        /*
                         * Save the overhead of a software interrupt;
@@ -919,7 +920,7 @@
                   (softclock_ticks + 1) == hardclock_ticks) {
                softclock_ticks++;
        }
-       simple_unlock(&callwheel_slock);
+       CALLWHEEL_UNLOCK(s);
 }
 
 /*



Home | Main Index | Thread Index | Old Index