From nobody Wed Dec 17 10:21:29 2025 Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FD41150992 for ; Thu, 11 Jul 2024 08:33:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686785; cv=none; b=giarAHE8SMfkT8NpZHRgN7G+Z3zrWBTt/qtp0LoKNLtUPNj7uATRFJ5Hz/7/E9cOqsh8aA+is7ddZC9UrxducOvGoWHHdCYh3WWR25xi1MrtioTdBNZ6JsEORW1qGO94cEUPYaPAp9hOZvLBaaYNsPnAkCtCzMgmdPc85BcvW1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686785; c=relaxed/simple; bh=NruwJsFvwsSPkXYLJUwgKr+gFvQvXB2WWXCsPlIzVok=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o6tWcnesxdG6h5kRT94ELMAg0h9vyH/AaMluIwTtB9IPKD/mzj5m7ugnh2uQBj89kKiUH7gLa9b10mdJGcEKOfmr7W3DfRbqHu9EW9Cwsy/jB0nwfNXTPm3wLwhlSC0nScMBvb9qjCSvkJghXTlb7okmf/qwgP4WgE4PCOBJEaM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VOzHR25+; arc=none smtp.client-ip=209.85.166.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VOzHR25+" Received: by mail-il1-f174.google.com with SMTP id e9e14a558f8ab-3815eaa136eso2393175ab.0 for ; Thu, 11 Jul 2024 01:33:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720686783; x=1721291583; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I1wTEq4Zj0zkb0J+FzMN27F+Tf2xE8G5ye4De2za5ow=; b=VOzHR25+L0TY6OSCXYbWF+JB5VYI2LbPbGXiQJMsQgxiRCl1v7l0vmy5/4HYdLSjCp QYD1IZYFkzw+sj8j0LpCdoSJd1IIavWmdvzfjq3gipdq4NoKTUTuS9H2tcKfzyHTQAtN gNDrzlkLEf2Ouv8sDlO6sE426AQsGlzfdFbWUc0avUDEBPzBbCSY/z1uWBov16zjNX8e JPxwYMY1riNCyQYQACM8HJhw9sqN4AbEtLCoH9Wd3Er8JIZRZVolIv2L0QGYVo4fW3CF yjVhEv1x4JTKoddIvjw5q3JH+SOMtr+DpxrhEcZh701ejEGKQlRlapvIoLAjt2tmvwdZ lZGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720686783; x=1721291583; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I1wTEq4Zj0zkb0J+FzMN27F+Tf2xE8G5ye4De2za5ow=; b=jssFrq1nsezn80+iRb1KSDksrZcNIbUsnY4YNxa4W7Q7S1gsFCNSRkkixsJb9+JKMQ 8D5Ozk8/pkEHVtZ+cK7XnAd/q7OP5VYkCizp5MQGx8m5weW5ICF9au5eMLRKxWQsndVA 1k5JMVI+nv1ZDfXovYSW/6oznXAlU7jRzjns47ODx/pC2VcfYR5bKEjFC8GaWllt8oJE prPxy0Z09PbBqooJ7R4xoHbqCFB/m2ZuJtg+I8TalWjDtUHwkpU/VhQKAuqGxqqrVKiZ v7elkuYjarTBhGXKnewy4OYIKIEsZmMU1as3TJUqEZqk+5iQ1BGL0qZ1TrVh26gLcyEv 92Hw== X-Gm-Message-State: AOJu0Yxc1bAau/TUcZCe03oM+feAO8zTcnCyGb0ecqdk9vXsL4u6pFCz A3uB0hypKMrZJMkQkIN9p352R0qRO9P+Zg12WdNmulKRUz96TI3bB862Yw== X-Google-Smtp-Source: AGHT+IGidlC9pHkyhf3IQ8ixSjKuNzH9IdxH5up1iWrP0qK75V5ZBnOhGrLc2YyQAES6dlkoiVhrGQ== X-Received: by 2002:a05:6e02:170c:b0:382:325c:f7be with SMTP id e9e14a558f8ab-38a570fb1f2mr96676875ab.4.1720686783107; Thu, 11 Jul 2024 01:33:03 -0700 (PDT) Received: from localhost ([198.11.176.14]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b4397f32csm5267425b3a.146.2024.07.11.01.33.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2024 01:33:02 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Tejun Heo , Lai Jiangshan Subject: [PATCH 1/7] workqueue: Add wq_online_cpumask Date: Thu, 11 Jul 2024 16:35:41 +0800 Message-Id: <20240711083547.3981-2-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240711083547.3981-1-jiangshanlai@gmail.com> References: <20240711083547.3981-1-jiangshanlai@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Lai Jiangshan The new wq_online_mask mirrors the cpu_online_mask except during hotplugging; specifically, it differs between the hotplugging stages of workqueue_offline_cpu() and workqueue_online_cpu(), during which the transitioning CPU is not represented in the mask. Signed-off-by: Lai Jiangshan --- kernel/workqueue.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 5d362290c2e8..985ab9230fe0 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -444,6 +444,9 @@ static struct rcuwait manager_wait =3D __RCUWAIT_INITIA= LIZER(manager_wait); static LIST_HEAD(workqueues); /* PR: list of all workqueues */ static bool workqueue_freezing; /* PL: have wqs started freezing? */ =20 +/* PL: mirror the cpu_online_mask excluding the CPU in the midst of hotplu= gging */ +static cpumask_var_t wq_online_cpumask; + /* PL&A: allowable cpus for unbound wqs and work items */ static cpumask_var_t wq_unbound_cpumask; =20 @@ -6583,6 +6586,8 @@ int workqueue_online_cpu(unsigned int cpu) =20 mutex_lock(&wq_pool_mutex); =20 + cpumask_set_cpu(cpu, wq_online_cpumask); + for_each_pool(pool, pi) { /* BH pools aren't affected by hotplug */ if (pool->flags & POOL_BH) @@ -6629,6 +6634,9 @@ int workqueue_offline_cpu(unsigned int cpu) =20 /* update pod affinity of unbound workqueues */ mutex_lock(&wq_pool_mutex); + + cpumask_clear_cpu(cpu, wq_online_cpumask); + list_for_each_entry(wq, &workqueues, list) { struct workqueue_attrs *attrs =3D wq->unbound_attrs; =20 @@ -7650,10 +7658,12 @@ void __init workqueue_init_early(void) =20 BUILD_BUG_ON(__alignof__(struct pool_workqueue) < __alignof__(long long)); =20 + BUG_ON(!alloc_cpumask_var(&wq_online_cpumask, GFP_KERNEL)); BUG_ON(!alloc_cpumask_var(&wq_unbound_cpumask, GFP_KERNEL)); BUG_ON(!alloc_cpumask_var(&wq_requested_unbound_cpumask, GFP_KERNEL)); BUG_ON(!zalloc_cpumask_var(&wq_isolated_cpumask, GFP_KERNEL)); =20 + cpumask_copy(wq_online_cpumask, cpu_online_mask); cpumask_copy(wq_unbound_cpumask, cpu_possible_mask); restrict_unbound_cpumask("HK_TYPE_WQ", housekeeping_cpumask(HK_TYPE_WQ)); restrict_unbound_cpumask("HK_TYPE_DOMAIN", housekeeping_cpumask(HK_TYPE_D= OMAIN)); --=20 2.19.1.6.gb485710b From nobody Wed Dec 17 10:21:29 2025 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1C47156F3A for ; Thu, 11 Jul 2024 08:33:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686788; cv=none; b=jzfL5F0leatYdxbm2MUOVkqqhKOMt9B3y4kysqfvioU3hct587rN/OF6NUmhjVKqR9D67O5Zy49deLIwFlLEML9RmkfgbrvymnTg+bAK3fJ4xSXmNky+KZwPgaoZyw0htFsPKxJ1B+m2O6K7neTmQEa61BVLxDEK0wLeIXuW59s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686788; c=relaxed/simple; bh=PPqAOgxiHf80yuq2V7rEIjlkSvnolbs5gz7XAwBVk/o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OWLzk8ASEeknYAXY7TKAxHRS5qwhBE9wCbIFtlik/Ij590z/vDGjLJQeVKPddeBfIrIrHdTdgm/gaRL3bTx5col0u9ej8auYszfYmjxT2ZWVbET0NfbLaT47nfgNstHHJrlRvaUEF9+m+cym7cybcY3SRKmunI3ildAB49oGDSs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SP8I9exP; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SP8I9exP" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-70b42250526so529695b3a.1 for ; Thu, 11 Jul 2024 01:33:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720686786; x=1721291586; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tiOeWmbTexBi55Q/t6q7ngGXESICd795YG/HDDiGhpg=; b=SP8I9exP3kCUTHkdKlAmWXDWQrvUh5Q4xEQnqhVacR2aXQTVpnsqqE1trgMhEr88z2 vIR781gVOXpZy4jCk/ZAEBRPaMRHOJHovxI0OxzG6rsCnbaTQo/UFyIgmEW3sZfelEC2 reJflIRXtF87q5W9VGjVfAwb3mtxO/LYToEhoGXgkbY7fDL609GG6r0l1/P0+FHUB6m4 FzUP7zLKzMCgJPrUc+YROcfTUxY2z7wO5wbzS2rtfUkta4lGnibfZcWzGJmt8lkWAgQW m5YJRR2DrXsLJLRvxv4BhRBJctY11rFfqRYsBOBJlLYGeHbUtEf2VVwlsqIXrNA/4mhp sMKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720686786; x=1721291586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tiOeWmbTexBi55Q/t6q7ngGXESICd795YG/HDDiGhpg=; b=CnassYfkWfHHsINo8gjLlgx+JnVjhNBsIjHg2i5phP0b7kehEtMnvoVkUSpO9NeoTQ pNKdmV7I9V4481muclCVu8Y8t+zzM3fsfSr7T/SDOQdDSDkjVEftZjZFH75bbBBRLC2O xdbthDqDmRvNs1E4QKQ4n6mmsJhEcqKgWkC6wyrGpLVPQUXWRplN0bSQgvwcblQ0co5g niQ1IH2NL3A1dzP0FyAchz6ImzlwzAsZNgz0V64nVUX8DArvEaeYjAIOAdJLF+p37Laz eakaVb/j8yaP9I8zauk95iCrEfGEqKZcJPLKWHza8VeZHf9BpqFO/kSFgGupZEYj7MAi 1ZUA== X-Gm-Message-State: AOJu0YwKpJ/hLqA5eg98I5XBzlBTc6a9c2D1Z/o5IFE5DcRi8sXsQ8bw r1qD47VNAokhnZFOqe7zrKylPCLdEtKOGbKr95J51/NAMBjeDEMEPthS4w== X-Google-Smtp-Source: AGHT+IFJ5d72RsM7GIb9z5ohNAWlZT0KxHL4qtyQ/K4hKrraFzVIXRZb6XgwPoN9SqrMoL6cDL9xmw== X-Received: by 2002:a05:6a00:2292:b0:70b:2ede:7142 with SMTP id d2e1a72fcca58-70b436171c6mr9202424b3a.34.1720686785984; Thu, 11 Jul 2024 01:33:05 -0700 (PDT) Received: from localhost ([47.89.225.180]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b4389c0ffsm5260635b3a.16.2024.07.11.01.33.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2024 01:33:05 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Tejun Heo , Lai Jiangshan Subject: [PATCH 2/7] workqueue: Simplify wq_calc_pod_cpumask() with wq_online_cpumask Date: Thu, 11 Jul 2024 16:35:42 +0800 Message-Id: <20240711083547.3981-3-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240711083547.3981-1-jiangshanlai@gmail.com> References: <20240711083547.3981-1-jiangshanlai@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Lai Jiangshan Avoid relying on cpu_online_mask for wqattrs changes so that cpus_read_lock() can be removed from apply_wqattrs_lock(). And with wq_online_cpumask, attrs->__pod_cpumask doesn't need to be reused as a temporary storage to calculate if the pod have any online CPUs @attrs wants since @cpu_going_down is not in the wq_online_cpumask. Signed-off-by: Lai Jiangshan --- kernel/workqueue.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 985ab9230fe0..9f454a9c04c8 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5156,20 +5156,14 @@ static void wq_calc_pod_cpumask(struct workqueue_at= trs *attrs, int cpu, const struct wq_pod_type *pt =3D wqattrs_pod_type(attrs); int pod =3D pt->cpu_pod[cpu]; =20 - /* does @pod have any online CPUs @attrs wants? */ + /* calculate possible CPUs in @pod that @attrs wants */ cpumask_and(attrs->__pod_cpumask, pt->pod_cpus[pod], attrs->cpumask); - cpumask_and(attrs->__pod_cpumask, attrs->__pod_cpumask, cpu_online_mask); - if (cpu_going_down >=3D 0) - cpumask_clear_cpu(cpu_going_down, attrs->__pod_cpumask); - - if (cpumask_empty(attrs->__pod_cpumask)) { + /* does @pod have any online CPUs @attrs wants? */ + if (!cpumask_intersects(attrs->__pod_cpumask, wq_online_cpumask)) { cpumask_copy(attrs->__pod_cpumask, attrs->cpumask); return; } =20 - /* yeap, return possible CPUs in @pod that @attrs wants */ - cpumask_and(attrs->__pod_cpumask, attrs->cpumask, pt->pod_cpus[pod]); - if (cpumask_empty(attrs->__pod_cpumask)) pr_warn_once("WARNING: workqueue cpumask: online intersect > " "possible intersect\n"); --=20 2.19.1.6.gb485710b From nobody Wed Dec 17 10:21:29 2025 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCCAA158DC0 for ; Thu, 11 Jul 2024 08:33:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686792; cv=none; b=B8OYyrH3jw8A+qWNQp9bNbs0x0OYTZcB2PD7XxpLClt6rbpTWn2dibMqb52FK1vCrcfxfzHmLZkkXhcaMe8PKFr+KfwV7J1nfVsWIhDJN0TDryP47znv8MkWCX/2TNuwc8uHO96bnVsSIwaF/4uy0f2E8Q1OTLKOIO6fRCxa8Uk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686792; c=relaxed/simple; bh=J01Udbb+7haZ7zQxS66iwS9X/ZK3619tj5qzguCB6CU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LQ3irjTLjS4B3YzromemGCCOw4AA66Evvzp+RNEev6sJns3H1UtP6GPN08xfbCdiBcHlFrE94CK/NpS/ujB7YM3N6HoivKiAo57hzgCgsrE2v+GSQFISrwa37v7tsKiVIDBcNSpHj0r4qQKZVpWkK3CvBkjbJBzmD4ZP30dUmeE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CFORmsHk; arc=none smtp.client-ip=209.85.167.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CFORmsHk" Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3d9da46ca13so323737b6e.2 for ; Thu, 11 Jul 2024 01:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720686789; x=1721291589; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5ISdFRDOPdwq4hY2ipcyEEN+MSmkx59XM3IiNTOk+oE=; b=CFORmsHkPubASyR6mu7w1LWGAiV+X9+Wq+7tSvxWNa8huXYhcLEic4JX1wUOcbskXR LWqgdrhJX3SmBgGOu3pzFNPT6JJDB0fe5IZqGTteP2eEJZfFQTDf7TQkxrNdJsc+jaVc qC1pu6xZq046SuGzQYqdnEUDeNl8RnxzkXOnYy2iI8eRgknr2zMT3vIn6GlDY2JppUDe NpChl2FeZwZBfZS1D3oC0DiB7U7r7R6XLmaLx9MzsuYWmsjXgTlx+yrvotRkqNOJDhaO 4xKtWGM8NlYLh4PiYomp2MPsHGjUz7cLJPJM9JcXLEcn2ddX7TR9GnCD8mOgHilZvPvF FTwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720686789; x=1721291589; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5ISdFRDOPdwq4hY2ipcyEEN+MSmkx59XM3IiNTOk+oE=; b=RDxBKW8KZZk4h+4QFdDChNbmqeaTvzf0gFVdkdbuGn0PUzfuFdMeN8Eo+Rk9Pn+a46 ld9lS5VaeN2GtJ/2x1p4cawyyf1Xwf4uN1hEAYA/q0n2+7ACA6T/qnL07VxLIzSMX6IK zHLAYScoz3tJ/a9I87B/GgDc8R/n9zzMzRqhPvLseO082n8ppPCI6CicdpU1S4cwM7Da 5BeJwvUw9+6c5Bmu5xyxojb3BhfdqnBxJvnJvYDksiC5Sk/ixtBUNccVozAPT6FOibYJ m4EmSbPm3Ifdr8PAtjmX7IcDGaUIu8MtlqweP1vXISQGLE3xy3lRAe0GpkKvGKhdd+CW lhSQ== X-Gm-Message-State: AOJu0YzP4RX3k/tISkeZN3srygk+yFHWfUOOPzhq5wP9738+oGw7+LzL 8exQJ1knRGO8goDQJfimk5cZG9o2ZTFkSPKIrXuvBZL1DXWYxe32/7VWBg== X-Google-Smtp-Source: AGHT+IE6IG3nkzv3Jmcc67ZoMjvU3n062KXEQrt2L6eRR5pfjfi/wjkD6fm4M1YpFUmaZY+7anmNHw== X-Received: by 2002:a05:6808:2129:b0:3d9:26fe:298b with SMTP id 5614622812f47-3d93c056b7bmr8925065b6e.17.1720686789497; Thu, 11 Jul 2024 01:33:09 -0700 (PDT) Received: from localhost ([47.88.5.130]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-77d682b38e4sm3988188a12.77.2024.07.11.01.33.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2024 01:33:09 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Tejun Heo , Lai Jiangshan Subject: [PATCH 3/7] workqueue: Remove cpus_read_lock() from apply_wqattrs_lock() Date: Thu, 11 Jul 2024 16:35:43 +0800 Message-Id: <20240711083547.3981-4-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240711083547.3981-1-jiangshanlai@gmail.com> References: <20240711083547.3981-1-jiangshanlai@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Lai Jiangshan The pwq creations and installations have been reworked based on wq_online_cpumask rather than cpu_online_mask. So cpus_read_lock() is unneeded during wqattrs changes. Signed-off-by: Lai Jiangshan --- kernel/workqueue.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 9f454a9c04c8..64876d391e7c 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5123,15 +5123,12 @@ static struct pool_workqueue *alloc_unbound_pwq(str= uct workqueue_struct *wq, =20 static void apply_wqattrs_lock(void) { - /* CPUs should stay stable across pwq creations and installations */ - cpus_read_lock(); mutex_lock(&wq_pool_mutex); } =20 static void apply_wqattrs_unlock(void) { mutex_unlock(&wq_pool_mutex); - cpus_read_unlock(); } =20 /** --=20 2.19.1.6.gb485710b From nobody Wed Dec 17 10:21:29 2025 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBE7A1591E3 for ; Thu, 11 Jul 2024 08:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686795; cv=none; b=ILxMOStUDr3Zi45MmkvEZMIphQ359hQWqtaMTXKtZ308yrFGPuqZCX51IZvwsAiiYcNdNvw1lff8Brq6nWCzdMzElSe+LB/WAn4vD47tgub+9k5x3t6JVybcc8FGJaVSQwMSpqeyHpCbQXJpa3HROjCzAa4s5Mh94E9yHNmajts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686795; c=relaxed/simple; bh=vCOvyNzKA8bCtc0SbgBRetwo4tHTryBxKi0JZDvdgD0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HK7CYk4CoZtZsykCgfMZMFmOlJCfTFhDhyYEvoAzS8JiuuMYcHV92WUyKQLNyCBVfAXu9a5huakqNqWGsbBpXbpbuTVPZStV4OcqnqdARV06iXPCjSJzVD0wjXYEYxWlnaE2qbgRz13OWakdjLk1T/WHvZLKtOy+mCjCnCM6KMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TvjR1rlT; arc=none smtp.client-ip=209.85.215.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TvjR1rlT" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-75c3afd7a50so392120a12.2 for ; Thu, 11 Jul 2024 01:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720686793; x=1721291593; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A+0PQwW1AxmVF+MJISq1WtYnL1Jrp9uQlNNJlzSID7I=; b=TvjR1rlT5CTPkVavGFxwtHINKPlLpwicjV9tAmn8Fcw0jukDqz21T3nzbqacuJTmVk Y71WvXbxfk3SCsAS2QaroJw684CMrhUOYnLKvfA60qsQP0N2GQd9J5i88k0mv9ESh4GS ifNZ7Vff8IRjJ/7PcopZRUzZ4ZuzgaAARv1INWn+DFAuPaxJElou3XD5iqGN//X8eckx iGU9nDpCQJoRW71Xy4dFk6SBtG2Z6bzXcAvdaSYuw+KUfgLEzB4qT7KFLNFUujIEB38B hcD9Jfr+Xs6mfXkoYBLtC7gQvJkro3T6/v+FwBuxJLv5Bs8gzkw2Vffxqqc0OCK2oDD8 hNqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720686793; x=1721291593; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A+0PQwW1AxmVF+MJISq1WtYnL1Jrp9uQlNNJlzSID7I=; b=fsju0LhGS+831w+KqzDZKC7Rfv49d53dAy0HMBogdEVE8gsHdNopQNU4U2+/NmFg7N Jnp3nJ3I8RlE7vDI/1tN7YZjxbzg7/eBK6YYQfXDkYOyO/RBWWKW36bbZ5Xw9N/u3p+4 6TgU6w80TLF2lcNq7zxIxA8DUe1Wt/iH9pbFV0fyB8c00T4tnJGa+152zAte1P0+0wd+ P/Q8QgC5WtKlGP+cU55sujZdO1ioVksRadXLIeZcj6ZU6p9S1CmWAFhIVCsgQusl8XAz Lx/3sSc3Ysn8zsGCRR8joGMfNUsH0XApbQ1UqDk3KPCG/fEJ1BDO5RAjnwQ1DadYVUZF hZYA== X-Gm-Message-State: AOJu0YzLINhjrjV5D774EvFVomlVdxa16QUO9HamjS3tOwfMwACx8Hb5 gVPpFTJzeUDEp0NCOdWMcEsNYc6Y9MKGYpoVkcLN2R6CZ15YlL1lE4ikuA== X-Google-Smtp-Source: AGHT+IG8hAJPGIC/WU9yx3qiosr2RJRlyhoox18PiRS1uw+U0/MzUu5tCtRznOzLFyCPwO3L4Ntz8A== X-Received: by 2002:a05:6a20:729a:b0:1c0:ef24:4125 with SMTP id adf61e73a8af0-1c29821e49dmr8930873637.26.1720686792559; Thu, 11 Jul 2024 01:33:12 -0700 (PDT) Received: from localhost ([198.11.176.14]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fbb6a123e0sm45443365ad.26.2024.07.11.01.33.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2024 01:33:12 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Tejun Heo , Lai Jiangshan Subject: [PATCH 4/7] workqueue: Remove the unneeded cpumask empty check in wq_calc_pod_cpumask() Date: Thu, 11 Jul 2024 16:35:44 +0800 Message-Id: <20240711083547.3981-5-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240711083547.3981-1-jiangshanlai@gmail.com> References: <20240711083547.3981-1-jiangshanlai@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Lai Jiangshan The cpumask empty check in wq_calc_pod_cpumask() has long been useless. It just works purely as documents which states that the cpumask is not possible empty after the function returns. Now the code above is even more explicit that the cpumask is not empty, so the document-only empty check can be removed. Signed-off-by: Lai Jiangshan --- kernel/workqueue.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 64876d391e7c..01d5ea1af60a 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5160,10 +5160,6 @@ static void wq_calc_pod_cpumask(struct workqueue_att= rs *attrs, int cpu, cpumask_copy(attrs->__pod_cpumask, attrs->cpumask); return; } - - if (cpumask_empty(attrs->__pod_cpumask)) - pr_warn_once("WARNING: workqueue cpumask: online intersect > " - "possible intersect\n"); } =20 /* install @pwq into @wq and return the old pwq, @cpu < 0 for dfl_pwq */ --=20 2.19.1.6.gb485710b From nobody Wed Dec 17 10:21:29 2025 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3BFE15A84E for ; Thu, 11 Jul 2024 08:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686798; cv=none; b=Z1REiF+XmAlF9/vgRSGXGd9AzHnZR2zfH+/Ukr2PFJQXIbTk4YVIG66Dge44ECIkKvOEPkGu3SqehR7Oz6u31/ZCHamipphC2x5FsW6PX8ALRMpP7/nP8FyN6Tk2VezcTQnN78TM/K5c84AtthFAPJX+fVenOYEtsE0N3dFCGg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686798; c=relaxed/simple; bh=5p7mKlZBB7cq2x9ObgxrB+VmIQA8vPWZ1rxsNvkxwGo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FeNQmDjdLMlUfpJPxrMnVd3KBSwo5gIy+KcDJX1e+nb1vuNfGLNnSi8oLPk2cIcbw4EkzQlBy1nIf9J/VIeP8Nd8UrOzCnwayfaFHbuBS+corse/ta5aV8r3XVaR0YfRbgiqRDZvJNBjM49xoj9PZ9FvsAm6yl/Pv6PolUoLH1I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=k71gBFmM; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k71gBFmM" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-70b13791a5eso593897b3a.1 for ; Thu, 11 Jul 2024 01:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720686796; x=1721291596; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t85OV781BymUmEWmSM0A7uB3A8jTq9hfBdV8Et0tDX8=; b=k71gBFmMsyGhygt/2Vjin2SGJLqBIn23h62iBJ0/LsyyRmWcHZTBmElay9GW7K/ZI5 AJK3C06p5IpWrM44DM3/QShby94w33Jy0vn7MLuX6BHIAPJEaotVBzO55g/0//YZZZCj CNS8H2xDFdrRnuZ0Sr8py9Caj2wPhiICPjvpX+VfdqiOlo30FNMXVBLV8h0hh0SoZOm/ HlGap5qjS3vCWjSIRznQmyYuqMou0qeQaDO9BTn9U7eQouoH+qJyfIiYHgK087gL0IzM RFzJpt5x9XMyUQExVpzZBg+zMdd9E88rMA0phwMn+LPjmv2AeT4VxLESKDiidRe/BDY1 BGxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720686796; x=1721291596; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t85OV781BymUmEWmSM0A7uB3A8jTq9hfBdV8Et0tDX8=; b=azKOaytindHIzQCKBX4MxoRDogGJ3+kPHlHRuSJu5Tx0xuiDbvQapwrC0xfUGWAYTg o7Nyflq19uZtw9/dazndbi9CnV8DCI2jKSLwzRbYNzb4T/EJMHbp8r1GSYT2OoiZQov0 PPAMA1GNQiE6QO9oU5xhuCv/BN3KaiAFgV4ccapj85NmZfxzoAJC7vR0X85yxgJsrg2c eTVtqWueexQAIN7YAh6XMiMi/7R50hLzmWu301p5YgPGG6WzeMRBW2CzhC0yBRGgKiOA zfsdCRZbaDWePIO/GAxjl9LFQtLREckyiF9PLhDRZe6IM1fl0Yu57EaPzgMYGhNCHbiy tjdA== X-Gm-Message-State: AOJu0YwBbA7vCesxvDB9Cx2E6Ix/erN8Y2RBNQCVIOTkTcNpFrBfZA9d Teu7VH4Pp5EbihbgPfZXJ9Mf5fbkd7FAixTK1WCLcHwuLmOPYuNfddoTQQ== X-Google-Smtp-Source: AGHT+IG7bTnGernIehdExOsL0JOIK+sJMIY45PHo7562RtA/o7O4dAKT19bP+tzPg40VyC21PG4tPg== X-Received: by 2002:a05:6a00:21cb:b0:705:9bd8:4f57 with SMTP id d2e1a72fcca58-70b434f57cemr9507129b3a.7.1720686795732; Thu, 11 Jul 2024 01:33:15 -0700 (PDT) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70b439673c7sm5094039b3a.131.2024.07.11.01.33.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2024 01:33:15 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Tejun Heo , Lai Jiangshan Subject: [PATCH 5/7] workqueue: Remove the argument @cpu_going_down from wq_calc_pod_cpumask() Date: Thu, 11 Jul 2024 16:35:45 +0800 Message-Id: <20240711083547.3981-6-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240711083547.3981-1-jiangshanlai@gmail.com> References: <20240711083547.3981-1-jiangshanlai@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Lai Jiangshan wq_calc_pod_cpumask() uses wq_online_cpumask, which excludes the cpu going down, so the argument cpu_going_down is unused and can be removed. Signed-off-by: Lai Jiangshan --- kernel/workqueue.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 01d5ea1af60a..97ddccf8cd0e 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5135,10 +5135,8 @@ static void apply_wqattrs_unlock(void) * wq_calc_pod_cpumask - calculate a wq_attrs' cpumask for a pod * @attrs: the wq_attrs of the default pwq of the target workqueue * @cpu: the target CPU - * @cpu_going_down: if >=3D 0, the CPU to consider as offline * - * Calculate the cpumask a workqueue with @attrs should use on @pod. If - * @cpu_going_down is >=3D 0, that cpu is considered offline during calcul= ation. + * Calculate the cpumask a workqueue with @attrs should use on @pod. * The result is stored in @attrs->__pod_cpumask. * * If pod affinity is not enabled, @attrs->cpumask is always used. If enab= led @@ -5147,8 +5145,7 @@ static void apply_wqattrs_unlock(void) * * The caller is responsible for ensuring that the cpumask of @pod stays s= table. */ -static void wq_calc_pod_cpumask(struct workqueue_attrs *attrs, int cpu, - int cpu_going_down) +static void wq_calc_pod_cpumask(struct workqueue_attrs *attrs, int cpu) { const struct wq_pod_type *pt =3D wqattrs_pod_type(attrs); int pod =3D pt->cpu_pod[cpu]; @@ -5244,7 +5241,7 @@ apply_wqattrs_prepare(struct workqueue_struct *wq, ctx->dfl_pwq->refcnt++; ctx->pwq_tbl[cpu] =3D ctx->dfl_pwq; } else { - wq_calc_pod_cpumask(new_attrs, cpu, -1); + wq_calc_pod_cpumask(new_attrs, cpu); ctx->pwq_tbl[cpu] =3D alloc_unbound_pwq(wq, new_attrs); if (!ctx->pwq_tbl[cpu]) goto out_free; @@ -5378,7 +5375,6 @@ int apply_workqueue_attrs(struct workqueue_struct *wq, static void wq_update_pod(struct workqueue_struct *wq, int cpu, int hotplug_cpu, bool online) { - int off_cpu =3D online ? -1 : hotplug_cpu; struct pool_workqueue *old_pwq =3D NULL, *pwq; struct workqueue_attrs *target_attrs; =20 @@ -5398,7 +5394,7 @@ static void wq_update_pod(struct workqueue_struct *wq= , int cpu, wqattrs_actualize_cpumask(target_attrs, wq_unbound_cpumask); =20 /* nothing to do if the target cpumask matches the current pwq */ - wq_calc_pod_cpumask(target_attrs, cpu, off_cpu); + wq_calc_pod_cpumask(target_attrs, cpu); if (wqattrs_equal(target_attrs, unbound_pwq(wq, cpu)->pool->attrs)) return; =20 --=20 2.19.1.6.gb485710b From nobody Wed Dec 17 10:21:29 2025 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91A6615AAD9 for ; Thu, 11 Jul 2024 08:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686801; cv=none; b=nY9q6K0WzBmWX+/I+B4nPcCvxgnbawVJnSsvn408ToOgW2fm6wwCxvjHW1+ritYTzdWZSO7XVJBUO7wc0djvaWdaLF3jQh6vT0LO8dl5gkII6M2XJlkB0in58GiDjSl+LLidvhli7k/a9xh+cwlbpY8av8z1yDQqTrYu5CJC4WA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686801; c=relaxed/simple; bh=bi9MADgbkJVRRxAO//LTHOzkofDKoVl/DPisCjpaYBE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ifBIKQVEauPijqloNnm/CL5Dh9NP/1nL2I2ekLn6Vv5nB2P47rPNVOrRVUPsVlpJ88MRhGHGP2e6bPSBbnt6a0SLm0jvwc1kiZS99MS2foB06g6Vny/JuYmDa11ztycrUUSlIBkn9lJcNUpnE6FVI/YpXWi1ogWRlIhsdT3D9ho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gn2nuoPc; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gn2nuoPc" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1fa55dbf2e7so3573825ad.2 for ; Thu, 11 Jul 2024 01:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720686799; x=1721291599; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1ykf6J3ZBviVn4CTmkU3CZJmImASCyvUuhcoe9tkolI=; b=gn2nuoPctsVNXrcPZylvxfYHdyr8U0ypbBoHtMYuS+zufvnrP+0RuPonULMFzyuBYK gpRIk9AlVigb4XBvfdsULMTVcqcE6hItzAH2VrbACRQ4efJTKuxvCi2ejTO6UOfcCqtz JVcrBP1mgDljrRILlm83TpsMS0z7eGrsdVObVvsSZ8aonKLzf3b8NDX/cwu/DMvT/4xS 3k1iOfHs0PhyVgZsVH7Xi9GbHqUaPJG0jCWmmUUckx/xJdYqTsb6TlxR+zkBRWCBs6q6 vjsACLf9Mfjom1y3BVIV/wL6KfR4XlcCQ3lt70gONGxZq+A4mSGuDUSZrUZIWrLhaV9e niTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720686799; x=1721291599; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1ykf6J3ZBviVn4CTmkU3CZJmImASCyvUuhcoe9tkolI=; b=wtuMcityjnTcnyjO9+9WQu6heL6BfX67qPGsX5r3NXncTQyBNFEVg4wQ0lw+5H7eT9 tRXwbXuiBcxej5ELMjxOAffh4vxaAy8lx0dGieH7Vvwnr2z7K5Gr37w6Nn5UnlLlhVN+ +gItfooU1FGUYgYJ8p91SxEOx+gVA/dbdouvGjwB72KsKMcHLdBLi8wd1j58kVq58I4+ GJuCGxIZ0RVB8AiAkbSyEHi/JG6Q/OxrBJvpAxkMEY5YCZv/HWgAdp7p2G1H2n8erwKO Y9TusT32oJJCNaW29xBEkdhhvZEtiHF3Lr4lqowRNJOA9C07o8X4R5Tc3ecYQyJ0BKki ux0w== X-Gm-Message-State: AOJu0YwowVW1qfa6hoYieYNQQPvIE5fJaqytgHttLaQ9i/WXMWhIK5Y0 iQSW08QzJo5m+bqZiTN+qNolwoJPcqQpCjD4h2N/QkYywU/qRywnrxVY2Q== X-Google-Smtp-Source: AGHT+IHzWdd6Rce2GYPczC1+47lqb61tOHD3BRb7uzO/IZL2eQZT7twBKQ23VaGWonU/TalJj2dpNQ== X-Received: by 2002:a17:902:dacb:b0:1fb:284b:b39a with SMTP id d9443c01a7336-1fbb6d044a5mr72528715ad.21.1720686798654; Thu, 11 Jul 2024 01:33:18 -0700 (PDT) Received: from localhost ([47.89.225.180]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fbb6a2a2d2sm45553405ad.91.2024.07.11.01.33.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2024 01:33:18 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Tejun Heo , Lai Jiangshan Subject: [PATCH 6/7] workqueue: Remove the arguments @hotplug_cpu and @online from wq_update_pod() Date: Thu, 11 Jul 2024 16:35:46 +0800 Message-Id: <20240711083547.3981-7-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240711083547.3981-1-jiangshanlai@gmail.com> References: <20240711083547.3981-1-jiangshanlai@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Lai Jiangshan The arguments @hotplug_cpu and @online are not used in wq_update_pod() since the functions called by wq_update_pod() don't need them. Signed-off-by: Lai Jiangshan --- kernel/workqueue.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 97ddccf8cd0e..21e1c5787ba4 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5354,8 +5354,6 @@ int apply_workqueue_attrs(struct workqueue_struct *wq, * wq_update_pod - update pod affinity of a wq for CPU hot[un]plug * @wq: the target workqueue * @cpu: the CPU to update pool association for - * @hotplug_cpu: the CPU coming up or going down - * @online: whether @cpu is coming up or going down * * This function is to be called from %CPU_DOWN_PREPARE, %CPU_ONLINE and * %CPU_DOWN_FAILED. @cpu is being hot[un]plugged, update pod affinity of @@ -5372,8 +5370,7 @@ int apply_workqueue_attrs(struct workqueue_struct *wq, * CPU_DOWN. If a workqueue user wants strict affinity, it's the user's * responsibility to flush the work item from CPU_DOWN_PREPARE. */ -static void wq_update_pod(struct workqueue_struct *wq, int cpu, - int hotplug_cpu, bool online) +static void wq_update_pod(struct workqueue_struct *wq, int cpu) { struct pool_workqueue *old_pwq =3D NULL, *pwq; struct workqueue_attrs *target_attrs; @@ -6593,7 +6590,7 @@ int workqueue_online_cpu(unsigned int cpu) int tcpu; =20 for_each_cpu(tcpu, pt->pod_cpus[pt->cpu_pod[cpu]]) - wq_update_pod(wq, tcpu, cpu, true); + wq_update_pod(wq, tcpu); =20 mutex_lock(&wq->mutex); wq_update_node_max_active(wq, -1); @@ -6628,7 +6625,7 @@ int workqueue_offline_cpu(unsigned int cpu) int tcpu; =20 for_each_cpu(tcpu, pt->pod_cpus[pt->cpu_pod[cpu]]) - wq_update_pod(wq, tcpu, cpu, false); + wq_update_pod(wq, tcpu); =20 mutex_lock(&wq->mutex); wq_update_node_max_active(wq, cpu); @@ -6917,7 +6914,7 @@ static int wq_affn_dfl_set(const char *val, const str= uct kernel_param *kp) =20 list_for_each_entry(wq, &workqueues, list) { for_each_online_cpu(cpu) { - wq_update_pod(wq, cpu, cpu, true); + wq_update_pod(wq, cpu); } } =20 @@ -7928,7 +7925,7 @@ void __init workqueue_init_topology(void) */ list_for_each_entry(wq, &workqueues, list) { for_each_online_cpu(cpu) - wq_update_pod(wq, cpu, cpu, true); + wq_update_pod(wq, cpu); if (wq->flags & WQ_UNBOUND) { mutex_lock(&wq->mutex); wq_update_node_max_active(wq, -1); --=20 2.19.1.6.gb485710b From nobody Wed Dec 17 10:21:29 2025 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02F0D15B0F2 for ; Thu, 11 Jul 2024 08:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686804; cv=none; b=QgeL/OaozpYnjVkyHH0iip2x+8M2NQ8DsMHTHhayMNBECyQRJhyAYTCIOUjQTz4tAa9qtzEJFZh7E1tz3zcmEpPeDAWOghlbM8GhTyA6phN17AtABCKQcTjrAZr157PCyNpSvfYcG+diRge3ST62OINHqbDjxuJSRvmd1OyrEt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720686804; c=relaxed/simple; bh=UL9Ym4ghZ4P1hcNZ1sjBqaf439ohb1DqkcuArs85SvQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oVvCdGPf56PD2sncgzMFrN48BJP1Q65jpEZNRfqwFwYImyrUdDW5rzL8/q1CQcMSinOu0ehAUAiKpzFsU3Gcjm5tfBYPO2hkvyTK2EH7yvkwv7ShefgE/kzOwrQCxe/yzlbzsVy7sy1byzwV/7OyYpWo6eSD7W52lhmu1QBblK8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NAR/n9np; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NAR/n9np" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2c98b080012so512988a91.1 for ; Thu, 11 Jul 2024 01:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720686802; x=1721291602; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uoB9n8vWkkLxgD9IA4qyD2Mvc7kqrqH6g6qZFUEn6Lc=; b=NAR/n9np0f8m6KDqIVFJCRpPQ8zjGAiFkgRdqgxPLs9hvy2tzUXmRpRLdx8G+jMjrh Lf8d2dRJJksEySBmLcnR6G4Da3Mn4hRmAV4Qfdrk7J4LLOuIVr5cQClBGLB3PnYkIcty PuTYKzyXQIFJlLvP0ewkSjeFUk5JU7VD81W2PXC4A1z34vGEZLTq5p6kxA+VRcrgc4SC //ph4qnJxFzUIMBmVTTOa3cxSjj0/MOwIa9rW7mkZ4fgw+n0n8omaqx6jytoMW2JECez c9F1Ti0qNwhFamJpSs9ed/QII3b1BtosM3WoeMUXo1fNyH+79Zhmgy2OWXR+z2PeprcL 4b5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720686802; x=1721291602; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uoB9n8vWkkLxgD9IA4qyD2Mvc7kqrqH6g6qZFUEn6Lc=; b=Jj5PQ3cUQU/OItwkNXQc/h96giYvUaNub62z5sdkjRulqnV/kLrwZpqW+ZUkqq4vZi jAXHB7j4ni5pM9DUoUznHOCWHdLA4DpT3/zeqVG2m9ofjpIJw7Hh++EI9T5Da+oVtEjE VGYL4N0nQ0dpSZ/Uo64KlKu3O16LAcxl0GeB87qk4qHDvjNoLJ+Ylc4YP1JKvTtj4Z7C ObB6x+GCCs8hS5qyYYOnPy+nYSnZCZbkI6SKivRkeHUchtZKMyEiFu5LnMc50uTpx0WT JXLYKP2Wqb842PAJP1thYwoldauDfe4qy5nFwqZqRPj0QgPhjdUbGd6Xv7VcwbxRA2sa JUnQ== X-Gm-Message-State: AOJu0Ywa6Ue9O4ornaxvMyX0XxUrm5RWn16EJ3ldJlgplDLP3MxBR4e9 BRXw26w9KcUfdX4NA7UnWi6uQQsBUDcBO3AhnFnv6SzjMldVs1TRNo6MYg== X-Google-Smtp-Source: AGHT+IE7xvCB435LadnhZhGsV045GEhu8HN53Oi5VkJ2sDh0SmOIv7YsJ//ii+BHlWvAoEL1M6b1hA== X-Received: by 2002:a17:90a:db58:b0:2c9:8d5d:d175 with SMTP id 98e67ed59e1d1-2ca35d59cedmr5880020a91.48.1720686801934; Thu, 11 Jul 2024 01:33:21 -0700 (PDT) Received: from localhost ([47.254.32.37]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c9e47983d4sm9165752a91.30.2024.07.11.01.33.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2024 01:33:21 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Tejun Heo , Lai Jiangshan Subject: [PATCH 7/7] workqueue: Rename wq_update_pod() to unbound_wq_update_pwq() Date: Thu, 11 Jul 2024 16:35:47 +0800 Message-Id: <20240711083547.3981-8-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240711083547.3981-1-jiangshanlai@gmail.com> References: <20240711083547.3981-1-jiangshanlai@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Lai Jiangshan What wq_update_pod() does is just to update the pwq of the specific cpu. Rename it and update the comments. Signed-off-by: Lai Jiangshan --- Avoiding to call unbound_wq_update_pwq() in wq_affn_dfl_set() is in my todo list. So the comments assuming unbound_wq_update_pwq() only to be called in cpu hotplug path is unchanged. kernel/workqueue.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 21e1c5787ba4..cd6f2950ef6c 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -433,7 +433,7 @@ static struct wq_pod_type wq_pod_types[WQ_AFFN_NR_TYPES= ]; static enum wq_affn_scope wq_affn_dfl =3D WQ_AFFN_CACHE; =20 /* buf for wq_update_unbound_pod_attrs(), protected by CPU hotplug exclusi= on */ -static struct workqueue_attrs *wq_update_pod_attrs_buf; +static struct workqueue_attrs *unbound_wq_update_pwq_attrs_buf; =20 static DEFINE_MUTEX(wq_pool_mutex); /* protects pools and workqueues list = */ static DEFINE_MUTEX(wq_pool_attach_mutex); /* protects worker attach/detac= h */ @@ -5351,13 +5351,12 @@ int apply_workqueue_attrs(struct workqueue_struct *= wq, } =20 /** - * wq_update_pod - update pod affinity of a wq for CPU hot[un]plug + * unbound_wq_update_pwq - update a pwq slot for CPU hot[un]plug * @wq: the target workqueue - * @cpu: the CPU to update pool association for + * @cpu: the CPU to update the pwq slot for * * This function is to be called from %CPU_DOWN_PREPARE, %CPU_ONLINE and - * %CPU_DOWN_FAILED. @cpu is being hot[un]plugged, update pod affinity of - * @wq accordingly. + * %CPU_DOWN_FAILED. @cpu is in the same pod of the CPU being hot[un]plug= ged. * * * If pod affinity can't be adjusted due to memory allocation failure, it = falls @@ -5370,7 +5369,7 @@ int apply_workqueue_attrs(struct workqueue_struct *wq, * CPU_DOWN. If a workqueue user wants strict affinity, it's the user's * responsibility to flush the work item from CPU_DOWN_PREPARE. */ -static void wq_update_pod(struct workqueue_struct *wq, int cpu) +static void unbound_wq_update_pwq(struct workqueue_struct *wq, int cpu) { struct pool_workqueue *old_pwq =3D NULL, *pwq; struct workqueue_attrs *target_attrs; @@ -5385,7 +5384,7 @@ static void wq_update_pod(struct workqueue_struct *wq= , int cpu) * Let's use a preallocated one. The following buf is protected by * CPU hotplug exclusion. */ - target_attrs =3D wq_update_pod_attrs_buf; + target_attrs =3D unbound_wq_update_pwq_attrs_buf; =20 copy_workqueue_attrs(target_attrs, wq->unbound_attrs); wqattrs_actualize_cpumask(target_attrs, wq_unbound_cpumask); @@ -6590,7 +6589,7 @@ int workqueue_online_cpu(unsigned int cpu) int tcpu; =20 for_each_cpu(tcpu, pt->pod_cpus[pt->cpu_pod[cpu]]) - wq_update_pod(wq, tcpu); + unbound_wq_update_pwq(wq, tcpu); =20 mutex_lock(&wq->mutex); wq_update_node_max_active(wq, -1); @@ -6625,7 +6624,7 @@ int workqueue_offline_cpu(unsigned int cpu) int tcpu; =20 for_each_cpu(tcpu, pt->pod_cpus[pt->cpu_pod[cpu]]) - wq_update_pod(wq, tcpu); + unbound_wq_update_pwq(wq, tcpu); =20 mutex_lock(&wq->mutex); wq_update_node_max_active(wq, cpu); @@ -6913,9 +6912,8 @@ static int wq_affn_dfl_set(const char *val, const str= uct kernel_param *kp) wq_affn_dfl =3D affn; =20 list_for_each_entry(wq, &workqueues, list) { - for_each_online_cpu(cpu) { - wq_update_pod(wq, cpu); - } + for_each_online_cpu(cpu) + unbound_wq_update_pwq(wq, cpu); } =20 mutex_unlock(&wq_pool_mutex); @@ -7654,8 +7652,8 @@ void __init workqueue_init_early(void) =20 pwq_cache =3D KMEM_CACHE(pool_workqueue, SLAB_PANIC); =20 - wq_update_pod_attrs_buf =3D alloc_workqueue_attrs(); - BUG_ON(!wq_update_pod_attrs_buf); + unbound_wq_update_pwq_attrs_buf =3D alloc_workqueue_attrs(); + BUG_ON(!unbound_wq_update_pwq_attrs_buf); =20 /* * If nohz_full is enabled, set power efficient workqueue as unbound. @@ -7920,12 +7918,12 @@ void __init workqueue_init_topology(void) =20 /* * Workqueues allocated earlier would have all CPUs sharing the default - * worker pool. Explicitly call wq_update_pod() on all workqueue and CPU - * combinations to apply per-pod sharing. + * worker pool. Explicitly call unbound_wq_update_pwq() on all workqueue + * and CPU combinations to apply per-pod sharing. */ list_for_each_entry(wq, &workqueues, list) { for_each_online_cpu(cpu) - wq_update_pod(wq, cpu); + unbound_wq_update_pwq(wq, cpu); if (wq->flags & WQ_UNBOUND) { mutex_lock(&wq->mutex); wq_update_node_max_active(wq, -1); --=20 2.19.1.6.gb485710b