From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752570AbbCaT0Q (ORCPT ); Tue, 31 Mar 2015 15:26:16 -0400 Received: from mail-db3on0092.outbound.protection.outlook.com ([157.55.234.92]:37369 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751072AbbCaT0P (ORCPT ); Tue, 31 Mar 2015 15:26:15 -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: Tejun Heo , "Peter Zijlstra (Intel)" , Frederic Weisbecker , "Paul E. McKenney" , "Rafael J. Wysocki" , Martin Schwidefsky , CC: Chris Metcalf Subject: [PATCH] workqueue: avoid nohz_full cores Date: Tue, 31 Mar 2015 15:25:59 -0400 Message-ID: <1427829959-3023-1-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 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)(229853001)(77156002)(62966003)(87936001)(50466002)(50226001)(42186005)(86362001)(92566002)(19580395003)(48376002)(85426001)(106466001)(50986999)(33646002)(15975445007)(46102003)(47776003)(36756003)(19580405001)(86152002)(6806004)(105606002)(104016003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM2PR02MB0529;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:AM2PR02MB0529; 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:AM2PR02MB0529;BCL:0;PCL:0;RULEID:;SRVR:AM2PR02MB0529; X-Forefront-PRVS: 0532BF6DC2 X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2015 19:26:10.7848 (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: AM2PR02MB0529 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Metcalf When queuing work, we should avoid queuing it on the local cpu if we are using WORK_CPU_UNBOUND and the local cpu is nohz_full, since the workqueue will mean a later interrupt of the nohz_full process that presumably would prefer continuing to have 100% of the core without interrupts. Likewise, remove the nohz_full cores from unbound workqueues. If all the cores are nohz_full, we leave them in. Signed-off-by: Chris Metcalf --- Note that this patch depends on my earlier commit, not yet pulled into Linus' tree, that added the tick_nohz_full_clear_cpus() API: https://lkml.org/lkml/2015/3/24/956 include/linux/tick.h | 9 +++++++++ kernel/workqueue.c | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/linux/tick.h b/include/linux/tick.h index 29456c443970..119ed00c96d5 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -224,6 +224,15 @@ static inline bool is_housekeeping_cpu(int cpu) return true; } +static inline int prefer_housekeeping_cpu(int cpu) +{ +#ifdef CONFIG_NO_HZ_FULL + if (tick_nohz_full_cpu(cpu)) + return cpumask_next(-1, housekeeping_mask); +#endif + return cpu; +} + static inline void housekeeping_affine(struct task_struct *t) { #ifdef CONFIG_NO_HZ_FULL diff --git a/kernel/workqueue.c b/kernel/workqueue.c index f28849394791..ebe5ce3ae42d 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -48,6 +48,7 @@ #include #include #include +#include #include "workqueue_internal.h" @@ -1303,7 +1304,7 @@ static void __queue_work(int cpu, struct workqueue_struct *wq, return; retry: if (req_cpu == WORK_CPU_UNBOUND) - cpu = raw_smp_processor_id(); + cpu = prefer_housekeeping_cpu(raw_smp_processor_id()); /* pwq which will be used unless @work is executing elsewhere */ if (!(wq->flags & WQ_UNBOUND)) @@ -3782,6 +3783,7 @@ int apply_workqueue_attrs(struct workqueue_struct *wq, /* make a copy of @attrs and sanitize it */ copy_workqueue_attrs(new_attrs, attrs); cpumask_and(new_attrs->cpumask, new_attrs->cpumask, cpu_possible_mask); + tick_nohz_full_clear_cpus(new_attrs->cpumask); /* * We may create multiple pwqs with differing cpumasks. Make a @@ -3810,6 +3812,12 @@ int apply_workqueue_attrs(struct workqueue_struct *wq, for_each_node(node) { if (wq_calc_node_cpumask(attrs, node, -1, tmp_attrs->cpumask)) { +#ifdef CONFIG_NO_HZ_FULL + tick_nohz_full_clear_cpus(tmp_attrs->cpumask); + if (cpumask_empty(tmp_attrs->cpumask)) + cpumask_copy(tmp_attrs->cpumask, + new_attrs->cpumask); +#endif pwq_tbl[node] = alloc_unbound_pwq(wq, tmp_attrs); if (!pwq_tbl[node]) goto enomem_pwq; -- 2.1.2