From owner-freebsd-arch@FreeBSD.ORG Wed Feb 19 00:28:19 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 458F0A0F; Wed, 19 Feb 2014 00:28:19 +0000 (UTC) Received: from mail-qa0-x22b.google.com (mail-qa0-x22b.google.com [IPv6:2607:f8b0:400d:c00::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D6B4017FB; Wed, 19 Feb 2014 00:28:18 +0000 (UTC) Received: by mail-qa0-f43.google.com with SMTP id o15so24393269qap.2 for ; Tue, 18 Feb 2014 16:28:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=86PlWIGv2Q3HVdOUfhOJMWPOi6e60AbiMQ7Pg3k8ZAY=; b=P4I9B9gWB0J2AnA9h8HGSdA7QDgvPMV+Ps4zlIuN9Cbel96CyOFvcK5xWwnrRhqaHb HcOmIUVABa9l6k1qa3kTkYPpiwoNRNC0cNChyqdi2L2ZqZJgbphK0PqkOZdOmXaqkcKK PdczxEMtvPzC7RI3vekD7bX0FNPbDU5SVhqbkXDMFowQftYWwMWZHey/jWWXuUDoE42u XmS517O6uFOa3anYRfhCJjyaZOKoPj0mRg4bVJSziQqTE74+7VaQi+K+IgSD6kz+fy5Q v8bCuPcykb7jgpVehqKXUQ45W1i5Zd5AlwpoZIGP48L0d53HbZ1QtpebQkZmB+L6ULFt Ct3Q== MIME-Version: 1.0 X-Received: by 10.140.44.119 with SMTP id f110mr45202963qga.31.1392769698073; Tue, 18 Feb 2014 16:28:18 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.224.16.10 with HTTP; Tue, 18 Feb 2014 16:28:18 -0800 (PST) Date: Tue, 18 Feb 2014 16:28:18 -0800 X-Google-Sender-Auth: Jyth5QnZ-sb0Y0Ok-iUW5LUUVPQ Message-ID: Subject: [rfc] bind per-cpu timeout threads to each CPU From: Adrian Chadd To: "freebsd-arch@freebsd.org" , freebsd-current , Jeffrey Faden , John Baldwin Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Feb 2014 00:28:19 -0000 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