From nobody Tue Sep 9 21:32:26 2025 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 44CCA27E040 for ; Fri, 5 Sep 2025 08:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757062334; cv=none; b=RmhjnhUVdjK4rpOEfyt3LqHeiKghTa9oMKeCBOIg7ttgIzja+AsS1Isb+9R70ETp/SHoaO/KkS7h8LaL1LdNF0U+dVSMSUkzgYGyJqZvy1BvvIsArYm6ysgzsXfyFM3jLcQvy6ZK8mFljnmmgQuPqz3nvWOl825LQvxrU1Fx7TM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757062334; c=relaxed/simple; bh=JvX7TqkBXPSB8OitMgWG1eESIdw6g3S6GklBekHhnLw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y9sJtLGc7d5kRqAbLl0tdELKzluPMcQ5FHYs1D1MvvlId6a1FhhQ+XX5GDjn+h7TGDIBokvBUPL7jPebD2k9mbfe3vDBcO7pVYG0i+OWdzqDhYiKrnt/Wgs+n4FctipUWM7LHULICKfErUSqoZVRk3iv6au2rbZ/jTFxiwAxAUc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=RJK9eNQ8; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="RJK9eNQ8" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-45b8b8d45b3so17892285e9.1 for ; Fri, 05 Sep 2025 01:52:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757062330; x=1757667130; 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=r4OYQnEDg2MM33An1P1417ylBBWSz1KWKHVVwtk+B0Y=; b=RJK9eNQ8NtG1DjQt93AMB4WCTuw0VWhar18lbJMEpGdvB0Eh3efS8NpMuxj+p9GuXq gcnQT0VBtfXHR2SL15funqBpFaWXP9uxrpIEbvE5seSAkhxDHQuO/R9mHZmxHHhbqmOQ sHyhotVjGHjDTykHs/FBSrFkqJqxGr0rf7X3BXC/WdkW/EVccFleQxwZ42yDy6p78PQQ dj1YMFZR68KGAeDILcxknWjlHh1o8ZdthqnT/tuQcTY+imHKG3xR2PlS5okQ01Lxqchs rnhFso7L2Pe86x7xeDBrS6VExKfqZx8CG/n0klM1/aq/BDvGpbpNqh9K4LQFtK+iGwQF 3kPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757062330; x=1757667130; 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=r4OYQnEDg2MM33An1P1417ylBBWSz1KWKHVVwtk+B0Y=; b=A7sKk4SnqFKpiuBXPZ60lg9bqNE/HIhZLIwCUsZUp5ZT0CSjT7MH134v/jl0SUG6Iy HdbU6UvIZWgZLPmk1iCAWLzvnUiiBDF6nfu3KxuIkKv82y76v8x4hN3L3qtSjRT99Js7 yyWC7aYgYLS07I3Jm+YU/85++pofJboyPbVJ7D4dMJnkVku2N6cww0iE9i8MlPAStb8K ElF/3MStLhGWg7/4bp2niDRpBpSU/eJGkaaGbnGap8Bf5KBBC9Iyh/PWeAkxlr2dOm08 OnknbpT/OrvqhI+c6fQ5h4ddU5Y6yUIWqxmJ6IU4Ob68nkiZmArK7GAB0JdwAil6c4D5 lDsQ== X-Gm-Message-State: AOJu0Yw2o8d87fbhPyevJt6o5QNA7iwdmbBdMwksB7vSC0VJcWqKl47N D/Ph4fwHUw1gvjpy2/qK8yYUWESU+KwC3/PRPWR4i7vTBX7b0bqrqzoHqJn+eUVpLUJ8skcejGS H0HoQ X-Gm-Gg: ASbGncsDpHlkMtJsNtn6tBDdPV7oi4PgSOIw/HF+PH7lEWaaRsph2pqIm18f1fzN2t+ 7mZ0QcGDGt5nGvQGc/2YQIRqg9NecOkXQQgqeyrOEfo2U8x+6K+ndS9s1RBAjw92ihH93B9iuAB KjXL6mORtUM8QEchxvaXyqOpo0Ils7oJHxOq9giol3YJeTf+5YW/9/2M6VNX3qMi28gZW815izk U+DCphRrnl5ggdd8nUu6lfxf8rSn3Iy1t21zp9hDZeHfp6M4Jsr1pON4m3pvCC+JWA1IZoGZpsW bquGHe4wL6augtuZIFMl25JQiDQf9JcqouDOnNVOG6bIDaQXdSIJSNSQzSRXLVinRNwsZQ0AXwR tlgxPy7y6WuXgDG/jrMhs+aTlE8j5Y2fNbexBFFPzVJxTJEq60kgaaVHo+Q== X-Google-Smtp-Source: AGHT+IEqBd4ds0RW6PXStRIDBwTEDhSLakCtAA3K8GPmgNvMAMaafWSh2e4vyXdrFtjFO7ZutFqBzg== X-Received: by 2002:a05:600c:4f8f:b0:456:f1e:205c with SMTP id 5b1f17b1804b1-45b85550704mr189754635e9.4.1757062330275; Fri, 05 Sep 2025 01:52:10 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b940bbc0dsm166359115e9.2.2025.09.05.01.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 01:52:09 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Jens Axboe Subject: [PATCH 1/3] drivers/block: replace use of system_wq with system_percpu_wq Date: Fri, 5 Sep 2025 10:51:39 +0200 Message-ID: <20250905085141.93357-2-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905085141.93357-1-marco.crivellari@suse.com> References: <20250905085141.93357-1-marco.crivellari@suse.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" Currently if a user enqueue a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND. This lack of consistentcy cannot be addressed without refactoring the API. system_unbound_wq should be the default workqueue so as not to enforce locality constraints for random work whenever it's not required. Adding system_dfl_wq to encourage its use when unbound work should be used. queue_work() / queue_delayed_work() / mod_delayed_work() will now use the new unbound wq: whether the user still use the old wq a warn will be printed along with a wq redirect to the new one. The old system_unbound_wq will be kept for a few release cycles. Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- drivers/block/nbd.c | 2 +- drivers/block/sunvdc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 7bdc7eb808ea..7738fce177fa 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -311,7 +311,7 @@ static void nbd_mark_nsock_dead(struct nbd_device *nbd,= struct nbd_sock *nsock, if (args) { INIT_WORK(&args->work, nbd_dead_link_work); args->index =3D nbd->index; - queue_work(system_wq, &args->work); + queue_work(system_percpu_wq, &args->work); } } if (!nsock->dead) { diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index b5727dea15bd..442546b05df8 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c @@ -1187,7 +1187,7 @@ static void vdc_ldc_reset(struct vdc_port *port) } =20 if (port->ldc_timeout) - mod_delayed_work(system_wq, &port->ldc_reset_timer_work, + mod_delayed_work(system_percpu_wq, &port->ldc_reset_timer_work, round_jiffies(jiffies + HZ * port->ldc_timeout)); mod_timer(&port->vio.timer, round_jiffies(jiffies + HZ)); return; --=20 2.51.0 From nobody Tue Sep 9 21:32:26 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 0D25227EFF1 for ; Fri, 5 Sep 2025 08:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757062335; cv=none; b=C05x8HbWaMZtSmtFLk/voTgMIPV7DbNfa4ATYAbA3bDAuXuHwHCKD8DYlEAvKF16CHnib/tiBdmBEdXIt6RjrjbPfbIe3dNlwK9ZHWfuSHj6h8Os7O/Pd5BqxrRQSgHJ+QI5njw50nqPVUjWqERAk6BBBWQOTbVSGP361HcuLew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757062335; c=relaxed/simple; bh=++ys8qf1mVFh7eaJ0LPRH0noW+e/5qWo081uJ6QywX4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OyIGCw4QxGMfEU6ewIV70BK5OThiELPt294WfZfnE4IJCJr7fdHl+gUjja9u3UU71PnO7DFPj2vKwETgR8uqoRY3U7tBZijwo8Pi/HN4AtSg+JkI6vv9MpDhSs75bYfC2wBRiU5endntbmEnSLkrSzY0h+Ls5a+DfdJOXz0r8Dg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=J/1X21Hv; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="J/1X21Hv" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-45dd7b15a64so4016345e9.0 for ; Fri, 05 Sep 2025 01:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757062331; x=1757667131; 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=6o4r2c6Wzzp+J29SS3YZXj6FxIBq7GTFCT9Pn6IdrUA=; b=J/1X21Hv9aeS3pK1XqRWVYzLZUylMw79x3kM7hwjj4PKyLuexMappeM6E6+biSXjoP sd6c3rfJZnLntDYkXdCxUskuyPCTD+25RNzIK7VNCtKEzXehW9wnE506YLyhj49CT2Oa OK73kobcTr32n3pe3Uaeew6C8hnEHqc/cZZX1bkCkl3q0VATh4QHbnuAYmnr+t+OZAyI xv98opbmchHpz+KDBgQWL3Yml3saNw9a+rhkkTcaMqN8n/+RqSX0ka1jKv/i7K+0SQ0I QGPzW3xhhVks2OnSnSfG38Y2bMGy9ajRa8+CIQLkjSask0aAHxbcdk+FH9R4CDajwgKb WIpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757062331; x=1757667131; 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=6o4r2c6Wzzp+J29SS3YZXj6FxIBq7GTFCT9Pn6IdrUA=; b=dtAG+QPAZwucW5RkfUopDBmKvZW/e54a8HPsNZhZmU5KzARw1xnUpb2aTWURQe0iD5 IqEyhY6zl9fyIMKgij7iKi9Ut6Kl1GTE9qbG+O17jKip+9GOzbPcjsiLKPMizy3EnT+l SB6rQ9h8mG/ZA8wdOR4+YZnyxnnlYTPQdlxoyutE8A7u7vqnumqY5g4/LH52qgf6lEDe pebse+fpzqyDwFozBeiTsOxXJzOLnfEQBNcLAu3mtflX7NAGxZxeX8xFBFvxBjLd0/5U LZWm7qLvS40vZ7/AV+DyTICfw7p6sVI+EwppT74OCNF+RhiViwLpPRtBRNwh1Y4DQCs8 mR9w== X-Gm-Message-State: AOJu0YxnnN+RexdlS3QTpmaWCN1Mk2KLrDyT0zGJ29KjNLQIv+/Q7Hel vl34pos0a0LG2MkaHa7pqQ+aMJzTChn1P+SRMGbbM68Kx1aZYQtbqFVwcWaSL6YSoDihcjMQXIq af+I0 X-Gm-Gg: ASbGncuTOLznuqmnzqP5dIreRz2jnBwaolkUOziHiPQQZUKNSpAgPt8aBNta0O9Lix2 tIAJgI+KxCEGasQ0LverxBuOuFBPqoDTeGsTsq01Oa9QkGtIvINLeNjPNL1Pe834Hgq8R0JlNYp /R0MJAgzY4ixFA7OtO3tL8BVRfZiWxMgRmk8g2f/2VghViebgOnqUOJzozREo4fvpn9LZr39R2X z/z/Y9q66y9TNLOHUmYh5PAWW0YUcKK66lbHmbI3y34YkvBxWP0H3/I5JmQvTJ8NSl3r6UODkcF BGDLgxGbIOhOFo0dHR/ePPO6f123Y00ej/fS4SpSkdor0+3oPw/tBGpnait7tgqRSL4SlWLJP1A KhHNiD9QfCGTX6e512EFMNcTJCNPDRjiv8q7t6gPf8f97GCwROLsc3qF/3A== X-Google-Smtp-Source: AGHT+IGzUSTZ0dDnwg+i9qkis6hQBvZ5e7JyYMSkRPsAT6NSK9nycRZK+BwlgAZJyKeWJKn15q8TDw== X-Received: by 2002:a05:600c:3b01:b0:45d:d202:77f0 with SMTP id 5b1f17b1804b1-45dd5b3c05fmr20914855e9.5.1757062331095; Fri, 05 Sep 2025 01:52:11 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b940bbc0dsm166359115e9.2.2025.09.05.01.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 01:52:10 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Jens Axboe Subject: [PATCH 2/3] drivers/block: replace use of system_unbound_wq with system_dfl_wq Date: Fri, 5 Sep 2025 10:51:40 +0200 Message-ID: <20250905085141.93357-3-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905085141.93357-1-marco.crivellari@suse.com> References: <20250905085141.93357-1-marco.crivellari@suse.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" Currently if a user enqueue a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND. This lack of consistentcy cannot be addressed without refactoring the API. system_unbound_wq should be the default workqueue so as not to enforce locality constraints for random work whenever it's not required. Adding system_dfl_wq to encourage its use when unbound work should be used. queue_work() / queue_delayed_work() / mod_delayed_work() will now use the new unbound wq: whether the user still use the old wq a warn will be printed along with a wq redirect to the new one. The old system_unbound_wq will be kept for a few release cycles. Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- drivers/block/zram/zram_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index fda7d8624889..c7e0fa29a572 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -975,7 +975,7 @@ static int read_from_bdev_sync(struct zram *zram, struc= t page *page, work.entry =3D entry; =20 INIT_WORK_ONSTACK(&work.work, zram_sync_read); - queue_work(system_unbound_wq, &work.work); + queue_work(system_dfl_wq, &work.work); flush_work(&work.work); destroy_work_on_stack(&work.work); =20 --=20 2.51.0 From nobody Tue Sep 9 21:32:26 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 F3713281356 for ; Fri, 5 Sep 2025 08:52:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757062336; cv=none; b=fHNFyyJLSkvr3lAGakFXDxkyAT+JAGpTwhrX5CkYyN8JOhndTIcUuTWSjEJ3/hI7P3ltaJ7rBJLvohhjB3TeoRWEMtN73KzhgPubkY+2VATI5se9d8VVmsG8ek0Wy3zJ7hxtZRHwh9KuCEPnYWAjndGu780ejvpWYHYs7n+O3Qk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757062336; c=relaxed/simple; bh=DF/iEzWHIQwESB2SDSgXYrot5syuW7SMnlKhZF3RVYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DsmgVAnVOxDbBYC5LDBsvork1XWDA0QYMvXJuim3yUEND3eoHH/gwILItFliSXA4dQYi1MLW3dYPOTudILmdINRvTuXYNyymXCWPXczNDmw6/c4MN1mRhuh8PHI5wa7AV2D87qXq9Ky+HXN5mjFPuZf5uDnIFQB/Li8xP1UV27A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Z74N/31q; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Z74N/31q" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-45cb5e1adf7so14944275e9.0 for ; Fri, 05 Sep 2025 01:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1757062332; x=1757667132; 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=9mgapDPHuM0mgof/uZH7wCRcMetT8aod2+Badkbrp1o=; b=Z74N/31qYKQjWAV+cE7YhKB9H6JM2rXegGNk3T14tSwjo3iCOEM+y7XmssXafgg7n7 QliGaWAxNS/nxl8KjP4hiB+ySKVwNY0a41JR+Te7EWtGhePE4i+5O+EL505kCVcShigS hRpEbkwbRD9j76uvVNRUUWGO7mDCn5pZxE8TObZo/Z6ppn7k0HiJaBmjPRh6dYe3xtcY mwKKVlN7bnegKjH8cflzXhfi46jxGOssRnXcN4p2DbABPFyzmEaE7OtKuviHEufgN1g/ vtBCgTHs6hBf7NZRSD2Rdya9cpX8LTreLYc9+oCl99QDamGR3Yi5fSzTNMDNGsqQR7/Z ZeFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757062332; x=1757667132; 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=9mgapDPHuM0mgof/uZH7wCRcMetT8aod2+Badkbrp1o=; b=m3SFjQPRclXKj5rGL80T7MwwTshyP9QzDQBReA716c1Rdn0r5YCeWCTtdchO1Z6nFI RoOq4ZCwtpyoj2AyNhjlVFmg6uCGY5SNWIjBWD5DmQs2m+sN7HlXHcm8RIjMfXriWxLB V8lkDiQvLJGoQQ6BOPBqQI4seO2Y4GSDAMComzGYrJ7ypZXX/niwpkyeRVXQJLeNZS+t yClq/Q6LbddJjuyueo1clphHXCS1rOphtmDVm4t/0zAgLpkxtWYPlIKSqkOBfidteE8d pH9ztZ3l+W5ueJLq11RpA8Cp+iOLJCJiKjTM79JvVmkq4AuHOY6sz4P7BbEsa7OS40Tx OZAA== X-Gm-Message-State: AOJu0YzXhfUZdLNPeGe2VSDU0ZWxePDlcuGks4ZQ91YM14CDlU3PKR4F p+pN4mqSJVGdkfczdzyXfmgnU9Izv8mmia9Dq6knnnpFu38yNgZBHje2dT9XRD0uEv4JRjyUuO2 a8f/4 X-Gm-Gg: ASbGncvU7Qz6bwwcchWYPqINSneak4aEy9FtK7r3aQpI1UXmXrKrL/XWZd2zes4PdES xCpT+RPgxLsiz9ixxSi7gLG3sysUvPUsuSUgEGJLfOfSumH69HxE9tyl7pXqO58mDl7UkJRzaH3 QupWNlCyRo8jUFr8QfjhWDjR5NHPelsEdq9W5JCRtsoRUIrOS2hQLkUk1qA9RXzYKsh6eVogxj9 i38LeYcECX2Aa3jj3zgsRjYJbfRbdGHHVQVAi03dIoYyCw4vuqDCOHH609z+rxyAbe6wUJy+LDV iGfh4C0IC7OjCC8wSdv1UhVYFok2w32EvKNZx6v7IUMfn7IBuAFNSpIAK1t9qUsoCbkenYzbcCQ vKeHDCX2jZ8RWXv21nVUW5+pWt/ZkKMjULDkYTb6rl2g08c8= X-Google-Smtp-Source: AGHT+IHFQYNFVYiIXssiaSNUtqeFtGmKO8sqK1MzfGdIBLqddINzipVIOD+1qcAfN7bHYh9ABu5QFw== X-Received: by 2002:a05:600c:c48f:b0:45b:7c4c:cfbf with SMTP id 5b1f17b1804b1-45b855709d3mr171510145e9.23.1757062332004; Fri, 05 Sep 2025 01:52:12 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b940bbc0dsm166359115e9.2.2025.09.05.01.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Sep 2025 01:52:11 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Jens Axboe Subject: [PATCH 3/3] drivers/block: WQ_PERCPU added to alloc_workqueue users Date: Fri, 5 Sep 2025 10:51:41 +0200 Message-ID: <20250905085141.93357-4-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250905085141.93357-1-marco.crivellari@suse.com> References: <20250905085141.93357-1-marco.crivellari@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Currently if a user enqueue a work item using schedule_delayed_work() the used wq is "system_wq" (per-cpu wq) while queue_delayed_work() use WORK_CPU_UNBOUND (used when a cpu is not specified). The same applies to schedule_work() that is using system_wq and queue_work(), that makes use again of WORK_CPU_UNBOUND. This lack of consistentcy cannot be addressed without refactoring the API. alloc_workqueue() treats all queues as per-CPU by default, while unbound workqueues must opt-in via WQ_UNBOUND. This default is suboptimal: most workloads benefit from unbound queues, allowing the scheduler to place worker threads where they=E2=80=99re needed= and reducing noise when CPUs are isolated. This default is suboptimal: most workloads benefit from unbound queues, allowing the scheduler to place worker threads where they=E2=80=99re needed= and reducing noise when CPUs are isolated. This patch adds a new WQ_PERCPU flag to explicitly request the use of the per-CPU behavior. Both flags coexist for one release cycle to allow callers to transition their calls. Once migration is complete, WQ_UNBOUND can be removed and unbound will become the implicit default. With the introduction of the WQ_PERCPU flag (equivalent to !WQ_UNBOUND), any alloc_workqueue() caller that doesn=E2=80=99t explicitly specify WQ_UNB= OUND must now use WQ_PERCPU. All existing users have been updated accordingly. Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- drivers/block/aoe/aoemain.c | 2 +- drivers/block/rbd.c | 2 +- drivers/block/rnbd/rnbd-clt.c | 2 +- drivers/block/sunvdc.c | 2 +- drivers/block/virtio_blk.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/block/aoe/aoemain.c b/drivers/block/aoe/aoemain.c index cdf6e4041bb9..3b21750038ee 100644 --- a/drivers/block/aoe/aoemain.c +++ b/drivers/block/aoe/aoemain.c @@ -44,7 +44,7 @@ aoe_init(void) { int ret; =20 - aoe_wq =3D alloc_workqueue("aoe_wq", 0, 0); + aoe_wq =3D alloc_workqueue("aoe_wq", WQ_PERCPU, 0); if (!aoe_wq) return -ENOMEM; =20 diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index faafd7ff43d6..af0e21149dbc 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -7389,7 +7389,7 @@ static int __init rbd_init(void) * The number of active work items is limited by the number of * rbd devices * queue depth, so leave @max_active at default. */ - rbd_wq =3D alloc_workqueue(RBD_DRV_NAME, WQ_MEM_RECLAIM, 0); + rbd_wq =3D alloc_workqueue(RBD_DRV_NAME, WQ_MEM_RECLAIM | WQ_PERCPU, 0); if (!rbd_wq) { rc =3D -ENOMEM; goto err_out_slab; diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c index 15627417f12e..b3a0470f9e80 100644 --- a/drivers/block/rnbd/rnbd-clt.c +++ b/drivers/block/rnbd/rnbd-clt.c @@ -1809,7 +1809,7 @@ static int __init rnbd_client_init(void) unregister_blkdev(rnbd_client_major, "rnbd"); return err; } - rnbd_clt_wq =3D alloc_workqueue("rnbd_clt_wq", 0, 0); + rnbd_clt_wq =3D alloc_workqueue("rnbd_clt_wq", WQ_PERCPU, 0); if (!rnbd_clt_wq) { pr_err("Failed to load module, alloc_workqueue failed.\n"); rnbd_clt_destroy_sysfs_files(); diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c index 442546b05df8..851763e5dd18 100644 --- a/drivers/block/sunvdc.c +++ b/drivers/block/sunvdc.c @@ -1215,7 +1215,7 @@ static int __init vdc_init(void) { int err; =20 - sunvdc_wq =3D alloc_workqueue("sunvdc", 0, 0); + sunvdc_wq =3D alloc_workqueue("sunvdc", WQ_PERCPU, 0); if (!sunvdc_wq) return -ENOMEM; =20 diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 7cffea01d868..a5a48f976a20 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -1683,7 +1683,7 @@ static int __init virtio_blk_init(void) { int error; =20 - virtblk_wq =3D alloc_workqueue("virtio-blk", 0, 0); + virtblk_wq =3D alloc_workqueue("virtio-blk", WQ_PERCPU, 0); if (!virtblk_wq) return -ENOMEM; =20 --=20 2.51.0