Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19103057rwd; Wed, 28 Jun 2023 05:14:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5pc8TBR6ZWB8oBO9EHYdwstL1sc1nIrjD1aNyTvJpRDLu0KsZzrkatFaWwW3AYJoms3bHP X-Received: by 2002:a05:6a20:7f82:b0:11a:efaa:eb43 with SMTP id d2-20020a056a207f8200b0011aefaaeb43mr35678073pzj.3.1687954486627; Wed, 28 Jun 2023 05:14:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687954486; cv=none; d=google.com; s=arc-20160816; b=oLmEW8OCxA4P94KzXMRv5lWSi2WCP2zkMPmmyqmqX3nipjWTIiQYNf8MRO3z4eJ9Rc 8NYOKcd3SJDztg3hxp+KGEBoQBtA/i3QOTQN9N0F4bAFsC+2tk5cLVra6xjER4sqN+5n bSPW/clr8l2r4wK+J2lAiF/WOJRM+UPqXO3nT5wHetKWxRZVMd9WPiuXMb/4SmHs15j/ MP3Bgjmia1ad0gjzqsGkuimtCoR6BidH69xfk7k8fVb2dFErY8sflOp3lGGTwI64c287 En3xQS2nXRXF4wO1SvNvAKz5xlQD8PJVfSNfMBGdstPaGfQjlLRJHR5D6vPHaB2xJUJw S1Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:mail-followup-to:message-id:subject:cc:to:from:date; bh=yFWzJlUgvLAL85ZW5mNmmq/8Mng99maOzPjJboHtzvw=; fh=l6hQ8Ktq5sTbJGKKY3IhENoWfcbYVAFeEFpo7msuRBg=; b=AjRilLd6KM0OTTnQ8xlIbEx3mSktcJl4chnc9OcGY7VllddHKypJgKqXJu6deOlyXY iJUrEp+2ydy/k6QFYWgPseLH0ZxoW4isCf0BsebuQqcN8gfJiC7rb50S1WNKnrgVyIOH oqcTUmnXEPoFAewwKlhGvMJLrRurl9ytm6jqz0hm5Zd+WB46+I6leG0p9ilab6YAu2AI FTmI860n0yi2nz1sp2n9XLsK2vbddQj9NM9lP8sWtFqgLc5ghN7kqshmaWs19GuFfHbu LHSnNMzDNJeLDa/aHN06iHEP0GYOKtdpUB2Otun/Vtwkuy0tkY4tQJSRXXU26NSp4sfH YzZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw24-20020a056a00451800b00666e8e573a4si7728683pfb.241.2023.06.28.05.14.34; Wed, 28 Jun 2023 05:14:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231672AbjF1LTE (ORCPT + 99 others); Wed, 28 Jun 2023 07:19:04 -0400 Received: from mx5.didiglobal.com ([111.202.70.122]:48772 "HELO mx5.didiglobal.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S230498AbjF1LSq (ORCPT ); Wed, 28 Jun 2023 07:18:46 -0400 Received: from mail.didiglobal.com (unknown [10.79.65.12]) by mx5.didiglobal.com (Maildata Gateway V2.8) with ESMTPS id 59374B002422E; Wed, 28 Jun 2023 19:18:42 +0800 (CST) Received: from didi-ThinkCentre-M930t-N000 (10.79.64.101) by ZJY02-ACTMBX-02.didichuxing.com (10.79.65.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 28 Jun 2023 19:18:41 +0800 Date: Wed, 28 Jun 2023 19:18:34 +0800 X-MD-Sfrom: tiozhang@didiglobal.com X-MD-SrcIP: 10.79.65.12 From: tiozhang To: CC: , , , , , , , , Subject: [PATCH v4] workqueue: add cmdline parameter `workqueue.unbound_cpus` to further constrain wq_unbound_cpumask at boot time Message-ID: <20230628111722.GA31661@didi-ThinkCentre-M930t-N000> Mail-Followup-To: tj@kernel.org, rdunlap@infradead.org, frederic@kernel.org, jiangshanlai@gmail.com, linux-kernel@vger.kernel.org, zyhtheonly@gmail.com, zyhtheonly@yeah.net, zwp10758@gmail.com, fuyuanli@didiglobal.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [10.79.64.101] X-ClientProxiedBy: ZJY01-PUBMBX-01.didichuxing.com (10.79.64.32) To ZJY02-ACTMBX-02.didichuxing.com (10.79.65.12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Motivation of doing this is to better improve boot times for devices when we want to prevent our workqueue works from running on some specific CPUs, e,g, some CPUs are busy with interrupts. Signed-off-by: tiozhang --- .../admin-guide/kernel-parameters.txt | 7 +++++++ kernel/workqueue.c | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index a465d5242774..a88b133ab09b 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6780,6 +6780,13 @@ disables both lockup detectors. Default is 10 seconds. + workqueue.unbound_cpus= + [KNL,SMP] Specify to constrain one or some CPUs + to use in unbound workqueues. + Format: + By default, all online CPUs are available for + unbound workqueues. + workqueue.watchdog_thresh= If CONFIG_WQ_WATCHDOG is configured, workqueue can warn stall conditions and dump internal state to diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 7cd5f5e7e0a1..29e8254edd63 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -329,6 +329,9 @@ static bool workqueue_freezing; /* PL: have wqs started freezing? */ /* PL: allowable cpus for unbound wqs and work items */ static cpumask_var_t wq_unbound_cpumask; +/* for further constrain wq_unbound_cpumask by cmdline parameter*/ +static struct cpumask wq_cmdline_cpumask __initdata; + /* CPU where unbound work was last round robin scheduled from this CPU */ static DEFINE_PER_CPU(int, wq_rr_cpu_last); @@ -6006,6 +6009,9 @@ void __init workqueue_init_early(void) cpumask_copy(wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_WQ)); cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, housekeeping_cpumask(HK_TYPE_DOMAIN)); + if (!cpumask_empty(&wq_cmdline_cpumask)) + cpumask_and(wq_unbound_cpumask, wq_unbound_cpumask, &wq_cmdline_cpumask); + pwq_cache = KMEM_CACHE(pool_workqueue, SLAB_PANIC); /* initialize CPU pools */ @@ -6129,3 +6135,17 @@ void __init workqueue_init(void) */ void __warn_flushing_systemwide_wq(void) { } EXPORT_SYMBOL(__warn_flushing_systemwide_wq); + +static int __init workqueue_unbound_cpus_setup(char *str) +{ + int ret; + + ret = cpulist_parse(str, &wq_cmdline_cpumask); + if (ret < 0) { + cpumask_clear(&wq_cmdline_cpumask); + pr_warn("workqueue.unbound_cpus: incorrect CPU range\n"); + } + + return ret; +} +__setup("workqueue.unbound_cpus=", workqueue_unbound_cpus_setup); -- 2.17.1