Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754140AbbDHTNJ (ORCPT ); Wed, 8 Apr 2015 15:13:09 -0400 Received: from mail-am1on0073.outbound.protection.outlook.com ([157.56.112.73]:56337 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751921AbbDHTNE (ORCPT ); Wed, 8 Apr 2015 15:13:04 -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 v6 1/2] smpboot: allow excluding cpus from the smpboot threads Date: Wed, 8 Apr 2015 15:11:24 -0400 Message-ID: <1428520285-4609-1-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <20150408140108.GB13227@lerouge> References: <20150408140108.GB13227@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)(199003)(189002)(47776003)(92566002)(86152002)(19580395003)(85426001)(86362001)(48376002)(106466001)(50466002)(229853001)(104016003)(76176999)(46102003)(50986999)(19580405001)(2950100001)(50226001)(77156002)(105606002)(62966003)(33646002)(87936001)(36756003)(6806004)(42186005)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR02MB0779;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB0779; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5002010)(5005006);SRVR:HE1PR02MB0779;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB0779; X-Forefront-PRVS: 0540846A1D X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2015 19:12:58.6257 (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: HE1PR02MB0779 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2477 Lines: 74 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 --- v6: change from an "exclude" data pointer to a more generic valid_cpu() callback [Frederic] include/linux/smpboot.h | 3 +++ kernel/smpboot.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/linux/smpboot.h b/include/linux/smpboot.h index d600afb21926..4648a4576ae4 100644 --- a/include/linux/smpboot.h +++ b/include/linux/smpboot.h @@ -27,6 +27,8 @@ 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! + * @valid_cpu: Optional function, called when creating the threads, + * to limit the set of cpus on which threads are created. * @selfparking: Thread is not parked by the park function. * @thread_comm: The base name of the thread */ @@ -41,6 +43,7 @@ struct smp_hotplug_thread { void (*park)(unsigned int cpu); void (*unpark)(unsigned int cpu); void (*pre_unpark)(unsigned int cpu); + int (*valid_cpu)(unsigned int cpu); bool selfparking; const char *thread_comm; }; diff --git a/kernel/smpboot.c b/kernel/smpboot.c index c697f73d82d6..6ffc2dacb94a 100644 --- a/kernel/smpboot.c +++ b/kernel/smpboot.c @@ -173,6 +173,9 @@ __smpboot_create_thread(struct smp_hotplug_thread *ht, unsigned int cpu) if (tsk) return 0; + if (ht->valid_cpu && !ht->valid_cpu(cpu)) + return 0; + td = kzalloc_node(sizeof(*td), GFP_KERNEL, cpu_to_node(cpu)); if (!td) return -ENOMEM; @@ -221,9 +224,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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/