Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp105694rdf; Mon, 20 Nov 2023 18:19:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtd2PYpBHMeN5LDZkaFtNqkLjSj3+aytkKl39cCiz2cv4Ovi5W4BXIFlTqlv13yayGdXW6 X-Received: by 2002:a05:6a21:3995:b0:17a:e941:b0a3 with SMTP id ad21-20020a056a21399500b0017ae941b0a3mr13552429pzc.39.1700533165028; Mon, 20 Nov 2023 18:19:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700533165; cv=none; d=google.com; s=arc-20160816; b=n64z3fSUd1PqmUBo4ZzrZZAfnswZGWaiv2VjwYty+6sMKiIxD1F1NOzB8KEULx+S8u mi+FQlJ/PDDRjP6I5hj9mBsk+R408WuZ83xKt6UX/ra9beWpVUdcXn4jrbSmTeP0ca4G ZFJXJkqArV985Gv7wGTMS6sXaETX9HWkm27Adv6PTUCOAwv36dwyew5UiM17PVMdOXDE sx9REWMYhP3Uq7eGn/T5HTMwDQtPKCMS82UgdQS/gaMXVMWzqIFFJKrRreoxxEofRXrH kISTsNkLTyYQf947P8mZ361xsjQOBNjucRC2Q1f536GuU0YQxUnh+o+RX+CbplycwACB wK5w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=nedYr642nEg/r1pmego4Hp5PjxqjOd5QuDOx28RV/Z4=; fh=HaCS4W+yAqrwZ0SbdbGZJr9KoJhbnmOmnQbMcAln0sE=; b=KjelVy5Uy76wTSKBHLo6/HtojcMOUzJl22VkmlHneevxOTpWp0ohnAjTPIWWkV2dJ2 EXmEmVczq9emU4iHFgC+RxIj9qx8LKMtrmN+2qUzs1HZCDdbMcM7FnyXrj+mgT/Flaa+ 1/RIpcdSnetzhJ0NYCO2t2qyXPAxwT4+S31wffWKHAb2uVEJV/Zm4ZEvsvKaQCdjYXrF cOzZDV7REPTZfZTXbX1bS62zBNj5NSiZrlx57/KBS4FU53c4FwUcnvYypxlAMO7LpLeF nsWeGCWlnmQEuKa3KDK2cOgYHE/9wGN3J8ftHGPTFqe4Z6udn9gZhMLA89E7Yna7yR4m PP3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Yw/BknLf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id u17-20020a056a00125100b006c4d06bc29csi9427140pfi.302.2023.11.20.18.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 18:19:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Yw/BknLf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id DD73680B7C0D; Mon, 20 Nov 2023 18:19:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229679AbjKUCTH (ORCPT + 99 others); Mon, 20 Nov 2023 21:19:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbjKUCTG (ORCPT ); Mon, 20 Nov 2023 21:19:06 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD122AA for ; Mon, 20 Nov 2023 18:19:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700533142; 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; bh=nedYr642nEg/r1pmego4Hp5PjxqjOd5QuDOx28RV/Z4=; b=Yw/BknLfrkCGuQpLBWL7kVpcXkm9DkxeoXFCmIyKjqlXys7LcWxr58iQHa376+s1N2mjBU P7KDr7N+9nao3tyQ6K6cGIJC6rCz2aQaiJ1klnT1IxO1jRd/8n/B51itA/Vy2+PIjSBk3G g0rWfcfx1VcexrJPCLI993Bxks2pssQ= 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-586-iYHo0YeKP32831Ej1aXyEg-1; Mon, 20 Nov 2023 21:19:00 -0500 X-MC-Unique: iYHo0YeKP32831Ej1aXyEg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 9D36485A58C; Tue, 21 Nov 2023 02:18:59 +0000 (UTC) Received: from llong.com (unknown [10.22.8.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26E9E1C060B0; Tue, 21 Nov 2023 02:18:59 +0000 (UTC) From: Waiman Long To: Tejun Heo , Lai Jiangshan Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Waiman Long , kernel test robot Subject: [PATCH-cgroup] workqueue: Move workqueue_set_unbound_cpumask() and its helpers inside CONFIG_SYSFS Date: Mon, 20 Nov 2023 21:18:40 -0500 Message-Id: <20231121021840.10937-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Mon, 20 Nov 2023 18:19:22 -0800 (PST) Commit fe28f631fa94 ("workqueue: Add workqueue_unbound_exclude_cpumask() to exclude CPUs from wq_unbound_cpumask") makes workqueue_set_unbound_cpumask() static as it is not used elsewhere in the kernel. However, this triggers a kernel test robot warning about 'workqueue_set_unbound_cpumask' defined but not used when CONFIG_SYS isn't defined. It happens that workqueue_set_unbound_cpumask() is only called when CONFIG_SYS is defined. Move workqueue_set_unbound_cpumask() and its helpers inside the CONFIG_SYSFS compilation block to avoid the warning. There is no functional change. Fixes: fe28f631fa94 ("workqueue: Add workqueue_unbound_exclude_cpumask() to exclude CPUs from wq_unbound_cpumask") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202311130831.uh0AoCd1-lkp@intel.com/ Signed-off-by: Waiman Long --- kernel/workqueue.c | 102 ++++++++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index bd9d34eacd78..2fc585d3d6ca 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -4417,19 +4417,6 @@ static void apply_wqattrs_commit(struct apply_wqattrs_ctx *ctx) mutex_unlock(&ctx->wq->mutex); } -static void apply_wqattrs_lock(void) -{ - /* CPUs should stay stable across pwq creations and installations */ - cpus_read_lock(); - mutex_lock(&wq_pool_mutex); -} - -static void apply_wqattrs_unlock(void) -{ - mutex_unlock(&wq_pool_mutex); - cpus_read_unlock(); -} - static int apply_workqueue_attrs_locked(struct workqueue_struct *wq, const struct workqueue_attrs *attrs) { @@ -5833,44 +5820,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. - */ -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(); - cpumask_copy(wq_requested_unbound_cpumask, cpumask); - 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; -} - /** * workqueue_unbound_exclude_cpumask - Exclude given CPUs from unbound cpumask * @exclude_cpumask: the cpumask to be excluded from wq_unbound_cpumask @@ -6027,6 +5976,19 @@ static struct attribute *wq_sysfs_attrs[] = { }; ATTRIBUTE_GROUPS(wq_sysfs); +static void apply_wqattrs_lock(void) +{ + /* CPUs should stay stable across pwq creations and installations */ + cpus_read_lock(); + mutex_lock(&wq_pool_mutex); +} + +static void apply_wqattrs_unlock(void) +{ + mutex_unlock(&wq_pool_mutex); + cpus_read_unlock(); +} + static ssize_t wq_nice_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -6203,6 +6165,44 @@ 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(); + cpumask_copy(wq_requested_unbound_cpumask, cpumask); + 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_cpumask_show(struct device *dev, struct device_attribute *attr, char *buf, cpumask_var_t mask) { -- 2.39.3