Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2735538rdb; Wed, 15 Nov 2023 09:04:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoQTLfVSTWPHi6hnh2ef3b50b4ML7eO9lqyx0neTDVh6eEbGxASypMyzTh4db4buMDHbgL X-Received: by 2002:a9d:4d08:0:b0:6ca:c677:4568 with SMTP id n8-20020a9d4d08000000b006cac6774568mr6075192otf.10.1700067868564; Wed, 15 Nov 2023 09:04:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700067868; cv=none; d=google.com; s=arc-20160816; b=gZGr/xrdmF8G6un91wlKrqVP3fJUyFybUz3MG9NcIVui1ZyCKkM07qa5679kHUXuZu /JZgpcOhm+gdqhDE/WgSGgQJEd7xycmFUE7tDB/Sd6RYQRtkBtN7hdvYXEQefnVSCuKc FSKinKRX+KKWriQtN8TO+JE+kXOlGngSS4eobWNab6Vx43N82YFjYqJ8Y70j8nqCpqwj IvCokEZSnQQSVBPl+BvenuT1PTk/EGLeSROrPtKXDMm3HL+r/fberaFruekf7sCUnNFJ 5ScUMHY27WA3ADOuz57D8k9rWnmw3PrArtv39gxwxkeN0fcOm12I0b6VieP6jNsRriXJ Y/XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Pt/uc3/sS3+KPK27UtScw6ZAU1P5p5ewZLM2SZmBAtw=; fh=bNpy/TkeoCLOfJdH8gD+DRrlc5TtbiBfs9F9HtSKd4A=; b=Mz8VzGpxIDaTTEC5BQjs1wkocpOT0aHc9/z5rn3m/VOfLkDCSt/qBjDrIZHve2bhja qVjQdTtxABiYi9GA7n+yf3neefWCl7N308J891/CUK0n7Mo84f4+gbU3JQg9Uen61rqs U4qOrCbQLemhf9nr2kfRSWL7sT/vVY/aOQhDTCcDBRTHn8lSh2ERoQ+AnjcZbRxvAKZo fyBmEZj1tpByZplZYX5u0WggkYiW7iEIk1PptZsqarysYT9FKEWbqIQ8pArgauiX2UFb HxZtSW3lAmjqUILC7zvLAXd10dWuVcswO//wJwB2gJ3i3/DP1I8K2BO4o6WyYVapw0/p g5vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EUDdafqJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id v16-20020a9d6050000000b006c7cb390410si3738094otj.358.2023.11.15.09.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 09:04:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EUDdafqJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F0E1F8217ED5; Wed, 15 Nov 2023 09:04:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232326AbjKOREZ (ORCPT + 99 others); Wed, 15 Nov 2023 12:04:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232109AbjKOREY (ORCPT ); Wed, 15 Nov 2023 12:04:24 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 935AD197 for ; Wed, 15 Nov 2023 09:04:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700067859; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pt/uc3/sS3+KPK27UtScw6ZAU1P5p5ewZLM2SZmBAtw=; b=EUDdafqJjF03NkFqWcQPau3rzuLWP7BR34/dygDpIAuE3jfizWYSr4SMyFTdOj+VUBYneK c8fFzGW1kXhB2pGnA25/T7U2EVvevKOnz+Twes9/Lh6M3QJ4kbMom0acAQGncHRcPABCuT UsEAGVOhSf631BrOCE4l7JxzbE5n2CQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-411-oDVOxx06MfCUcXt8xdUJZg-1; Wed, 15 Nov 2023 12:04:15 -0500 X-MC-Unique: oDVOxx06MfCUcXt8xdUJZg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ABD0385A58C; Wed, 15 Nov 2023 17:04:14 +0000 (UTC) Received: from llong.com (unknown [10.22.9.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B6201121306; Wed, 15 Nov 2023 17:04:14 +0000 (UTC) From: Waiman Long To: Tejun Heo , Zefan Li , Johannes Weiner , Jonathan Corbet , Lai Jiangshan , Shuah Khan Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Peter Hunt , Frederic Weisbecker , Waiman Long Subject: [PATCH v3 1/5] workqueue: Make workqueue_set_unbound_cpumask() static Date: Wed, 15 Nov 2023 12:03:55 -0500 Message-Id: <20231115170359.163299-2-longman@redhat.com> In-Reply-To: <20231115170359.163299-1-longman@redhat.com> References: <20231115170359.163299-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 09:04:27 -0800 (PST) The workqueue_set_unbound_cpumask() function is only used inside workqueue.c with CONFIG_SYSFS. Make it static and move it down to within the ifdef CONFIG_SYSFS block. Also mark workqueue_apply_unbound_cpumask() as __maybe_unused for now as it will be used by another function introduced in a later commit. There is no functional change. Signed-off-by: Waiman Long --- include/linux/workqueue.h | 1 - kernel/workqueue.c | 76 +++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 24b1e5070f4d..cf49b467bd57 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -491,7 +491,6 @@ struct workqueue_attrs *alloc_workqueue_attrs(void); void free_workqueue_attrs(struct workqueue_attrs *attrs); int apply_workqueue_attrs(struct workqueue_struct *wq, const struct workqueue_attrs *attrs); -int workqueue_set_unbound_cpumask(cpumask_var_t cpumask); extern bool queue_work_on(int cpu, struct workqueue_struct *wq, struct work_struct *work); diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 6e578f576a6f..8996cdba8f07 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5784,7 +5784,7 @@ void thaw_workqueues(void) } #endif /* CONFIG_FREEZER */ -static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask) +static int __maybe_unused workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask) { LIST_HEAD(ctxs); int ret = 0; @@ -5827,43 +5827,6 @@ static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask) return ret; } -/** - * workqueue_set_unbound_cpumask - Set the low-level unbound cpumask - * @cpumask: the cpumask to set - * - * The low-level workqueues cpumask is a global cpumask that limits - * the affinity of all unbound workqueues. This function check the @cpumask - * and apply it to all unbound workqueues and updates all pwqs of them. - * - * Return: 0 - Success - * -EINVAL - Invalid @cpumask - * -ENOMEM - Failed to allocate memory for attrs or pwqs. - */ -int workqueue_set_unbound_cpumask(cpumask_var_t cpumask) -{ - int ret = -EINVAL; - - /* - * Not excluding isolated cpus on purpose. - * If the user wishes to include them, we allow that. - */ - cpumask_and(cpumask, cpumask, cpu_possible_mask); - if (!cpumask_empty(cpumask)) { - apply_wqattrs_lock(); - if (cpumask_equal(cpumask, wq_unbound_cpumask)) { - ret = 0; - goto out_unlock; - } - - ret = workqueue_apply_unbound_cpumask(cpumask); - -out_unlock: - apply_wqattrs_unlock(); - } - - return ret; -} - static int parse_affn_scope(const char *val) { int i; @@ -6158,6 +6121,43 @@ static struct bus_type wq_subsys = { .dev_groups = wq_sysfs_groups, }; +/** + * workqueue_set_unbound_cpumask - Set the low-level unbound cpumask + * @cpumask: the cpumask to set + * + * The low-level workqueues cpumask is a global cpumask that limits + * the affinity of all unbound workqueues. This function check the @cpumask + * and apply it to all unbound workqueues and updates all pwqs of them. + * + * Return: 0 - Success + * -EINVAL - Invalid @cpumask + * -ENOMEM - Failed to allocate memory for attrs or pwqs. + */ +static int workqueue_set_unbound_cpumask(cpumask_var_t cpumask) +{ + int ret = -EINVAL; + + /* + * Not excluding isolated cpus on purpose. + * If the user wishes to include them, we allow that. + */ + cpumask_and(cpumask, cpumask, cpu_possible_mask); + if (!cpumask_empty(cpumask)) { + apply_wqattrs_lock(); + if (cpumask_equal(cpumask, wq_unbound_cpumask)) { + ret = 0; + goto out_unlock; + } + + ret = workqueue_apply_unbound_cpumask(cpumask); + +out_unlock: + apply_wqattrs_unlock(); + } + + return ret; +} + static ssize_t wq_unbound_cpumask_show(struct device *dev, struct device_attribute *attr, char *buf) { -- 2.39.3