From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752187AbbDCQJe (ORCPT ); Fri, 3 Apr 2015 12:09:34 -0400 Received: from mail-db3on0072.outbound.protection.outlook.com ([157.55.234.72]:48532 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750751AbbDCQJb (ORCPT ); Fri, 3 Apr 2015 12:09:31 -0400 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; ezchip.com; dkim=none (message not signed) header.d=none; From: To: Frederic Weisbecker , Don Zickus , Ingo Molnar , Andrew Morton , Andrew Jones , chai wen , Ulrich Obergfell , Fabian Frederick , Aaron Tomlin , Ben Zhang , "Christoph Lameter" , Gilad Ben-Yossef , "Steven Rostedt" , , "Jonathan Corbet" , , Thomas Gleixner , Peter Zijlstra CC: Chris Metcalf Subject: [PATCH v4 1/2] smpboot: allow excluding cpus from the smpboot threads Date: Fri, 3 Apr 2015 12:08:54 -0400 Message-ID: <1428077335-4314-1-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <20150402184506.GI175361@redhat.com> References: <1427741465-15747-1-git-send-email-cmetcalf@ezchip.com> <20150331072502.GA16754@gmail.com> <551AE7D4.3020608@ezchip.com> <20150402133502.GA175361@redhat.com> <551D48F9.6090101@ezchip.com> <20150402141527.GD175361@redhat.com> <20150402153827.GC10357@lerouge> <551D6373.2030000@ezchip.com> <20150402164845.GD10357@lerouge> <20150402164845.GD10357@lerouge> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:12.216.194.146;CTRY:US;IPV:NLI;EFV:NLI;BMV:1;SFV:NSPM;SFS:(10009020)(6009001)(339900001)(189002)(199003)(104016003)(62966003)(42186005)(2950100001)(77156002)(36756003)(229853001)(86152002)(85426001)(6806004)(46102003)(105606002)(86362001)(19580395003)(19580405001)(47776003)(33646002)(50466002)(50986999)(76176999)(106466001)(48376002)(50226001)(87936001)(92566002)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR02MB0781;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR02MB0781; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(5002010);SRVR:VI1PR02MB0781;BCL:0;PCL:0;RULEID:;SRVR:VI1PR02MB0781; X-Forefront-PRVS: 05352A48BE X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2015 16:09:26.2007 (UTC) X-MS-Exchange-CrossTenant-Id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0fc16e0a-3cd3-4092-8b2f-0a42cff122c3;Ip=[12.216.194.146];Helo=[ld-1.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR02MB0781 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Metcalf This change allows some cores to be excluded from running the smp_hotplug_thread tasks. The motivating example for this is the watchdog threads, which by default we don't want to run on any enabled nohz_full cores. Signed-off-by: Chris Metcalf --- Relative to the quick diff I emailed out yesterday (sorry missed adding Thomas to that one), this change uses a notion of "exclude_mask" for smp_hotplug_thread. I think this is a better fit in general to the idea that smp_hotplug_thread should run everywhere (including on any newly-onlined cpus), EXCEPT for cores that have been specifically tagged as reserved for some reason. Obviously for nohz_full we have the nohz_full boot argument to use for this at the moment. Thomas, Peter, how does this look to you? include/linux/smpboot.h | 2 ++ kernel/smpboot.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/linux/smpboot.h b/include/linux/smpboot.h index 13e929679550..0631964525f7 100644 --- a/include/linux/smpboot.h +++ b/include/linux/smpboot.h @@ -27,6 +27,7 @@ struct smpboot_thread_data; * @pre_unpark: Optional unpark function, called before the thread is * unparked (cpu online). This is not guaranteed to be * called on the target cpu of the thread. Careful! + * @exclude_mask: Optional cpumask, specifying cores to exclude. * @selfparking: Thread is not parked by the park function. * @thread_comm: The base name of the thread */ @@ -41,6 +42,7 @@ struct smp_hotplug_thread { void (*park)(unsigned int cpu); void (*unpark)(unsigned int cpu); void (*pre_unpark)(unsigned int cpu); + cpumask_t *exclude_mask; bool selfparking; const char *thread_comm; }; diff --git a/kernel/smpboot.c b/kernel/smpboot.c index 40190f28db35..7df326ed80eb 100644 --- a/kernel/smpboot.c +++ b/kernel/smpboot.c @@ -172,6 +172,9 @@ __smpboot_create_thread(struct smp_hotplug_thread *ht, unsigned int cpu) if (tsk) return 0; + if (ht->exclude_mask && cpumask_test_cpu(cpu, ht->exclude_mask)) + return 0; + td = kzalloc_node(sizeof(*td), GFP_KERNEL, cpu_to_node(cpu)); if (!td) return -ENOMEM; @@ -220,9 +223,11 @@ static void smpboot_unpark_thread(struct smp_hotplug_thread *ht, unsigned int cp { struct task_struct *tsk = *per_cpu_ptr(ht->store, cpu); - if (ht->pre_unpark) - ht->pre_unpark(cpu); - kthread_unpark(tsk); + if (tsk) { + if (ht->pre_unpark) + ht->pre_unpark(cpu); + kthread_unpark(tsk); + } } void smpboot_unpark_threads(unsigned int cpu) -- 2.1.2