[rfc] bind per-cpu timeout threads to each CPU

From: Adrian Chadd <adrian_at_freebsd.org>
Date: Tue, 18 Feb 2014 16:28:18 -0800
Hi,

This patch binds the per-CPU timeout swi threads to the CPU they're on.

The scheduler may decide that a preempted kernel thread that's still
runnable and this can happen during things like per-CPU TCP timers
firing.

Thanks,

Index: sys/kern/kern_timeout.c
===================================================================
--- sys/kern/kern_timeout.c     (revision 261910)
+++ sys/kern/kern_timeout.c     (working copy)
_at__at_ -355,6 +355,7 _at__at_
        char name[MAXCOMLEN];
 #ifdef SMP
        int cpu;
+       struct intr_event *ie;
 #endif

        cc = CC_CPU(timeout_cpu);
_at__at_ -362,6 +363,11 _at__at_
        if (swi_add(&clk_intr_event, name, softclock, cc, SWI_CLOCK,
            INTR_MPSAFE, &cc->cc_cookie))
                panic("died while creating standard software ithreads");
+       if (intr_event_bind(clk_intr_event, timeout_cpu) != 0) {
+               printf("%s: timeout clock couldn't be pinned to cpu %d\n",
+                   __func__,
+                   timeout_cpu);
+       }
 #ifdef SMP
        CPU_FOREACH(cpu) {
                if (cpu == timeout_cpu)
_at__at_ -370,9 +376,15 _at__at_
                cc->cc_callout = NULL;  /* Only cpu0 handles timeout(9). */
                callout_cpu_init(cc);
                snprintf(name, sizeof(name), "clock (%d)", cpu);
-               if (swi_add(NULL, name, softclock, cc, SWI_CLOCK,
+               ie = NULL;
+               if (swi_add(&ie, name, softclock, cc, SWI_CLOCK,
                    INTR_MPSAFE, &cc->cc_cookie))
                        panic("died while creating standard software ithreads");
+               if (intr_event_bind(ie, cpu) != 0) {
+                       printf("%s: per-cpu clock couldn't be pinned
to cpu %d\n",
+                           __func__,
+                           cpu);
+               }
        }
 #endif
 }


-a
Received on Tue Feb 18 2014 - 23:28:19 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:47 UTC