Before converting network timeouts to run in a thread context they were
executed in a soft-interrupt handler.  This design implied that timeouts
were serialized.

The current "softclock" thread runs on CPU0 to limit border effects due
to the conversion from soft-interrupt to thread context.  However we
should raise the IPL level of this thread to ensure no other timeout can
run in the middle of another one.

Diff below does that, ok?

Index: kern/kern_timeout.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_timeout.c,v
retrieving revision 1.70
diff -u -p -r1.70 kern_timeout.c
--- kern/kern_timeout.c 3 Jan 2020 20:11:11 -0000       1.70
+++ kern/kern_timeout.c 11 Jan 2020 16:33:40 -0000
@@ -554,6 +554,7 @@ softclock_thread(void *arg)
        struct cpu_info *ci;
        struct sleep_state sls;
        struct timeout *to;
+       int s;
 
        KERNEL_ASSERT_LOCKED();
 
@@ -565,6 +566,7 @@ softclock_thread(void *arg)
        KASSERT(ci != NULL);
        sched_peg_curproc(ci);
 
+       s = splsoftclock();
        for (;;) {
                sleep_setup(&sls, &timeout_proc, PSWP, "bored");
                sleep_finish(&sls, CIRCQ_EMPTY(&timeout_proc));
@@ -579,6 +581,7 @@ softclock_thread(void *arg)
                tostat.tos_thread_wakeups++;
                mtx_leave(&timeout_mutex);
        }
+       splx(s);
 }
 
 #ifndef SMALL_KERNEL

Reply via email to