Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Feb 2014 16:28:18 -0800
From:      Adrian Chadd <adrian@freebsd.org>
To:        "freebsd-arch@freebsd.org" <freebsd-arch@freebsd.org>, freebsd-current <freebsd-current@freebsd.org>,  Jeffrey Faden <jeffreyatw@gmail.com>, John Baldwin <jhb@freebsd.org>
Subject:   [rfc] bind per-cpu timeout threads to each CPU
Message-ID:  <CAJ-VmokMQnUS_Yjva0n_j7bbc0yj6SdAmM6df4z2K60aaxGbvQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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)
@@ -355,6 +355,7 @@
        char name[MAXCOMLEN];
 #ifdef SMP
        int cpu;
+       struct intr_event *ie;
 #endif

        cc = CC_CPU(timeout_cpu);
@@ -362,6 +363,11 @@
        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)
@@ -370,9 +376,15 @@
                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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-VmokMQnUS_Yjva0n_j7bbc0yj6SdAmM6df4z2K60aaxGbvQ>