From nobody Fri Dec 19 20:17:15 2025 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 C0D7F328B56 for ; Fri, 7 Nov 2025 15:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762530019; cv=none; b=evBxltkjcv/uG+rB7WZfCBw0sFDlW3HE4XIhBPyq9dol7d0/A92uX5fDgK6bbVY+P45TEOhGRPPOaFWk5E0TFtJlfdOkt/3O5VFBo4lgL18ris0Y3Duk9yi5xbFC3Dmb+DXtMfBNUYI2qVHpEXSF4UnbK4Dzi1EIAqL+1dtzDSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762530019; c=relaxed/simple; bh=NBspa1M9xzcXUUTgbXNjvpUvNYxLGuDwsK4d7c3UuqY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=W/Y6tbrCskmJ5I724eM/JzBSQTTK7NQ43FB6xEWW/t9Wl7+yQWvNIqoNy/DJzsehqL4YN0hK/DhLath7lFj8gyWHdyXrwb0M+DHpiN9Jx/bK3gMs1Ub9OC+fFOXzh6bICeYiYoh7ZuVjYsj+R+dB2Kr9Kt88xXSvwZT9yRbNNE4= 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=YUBRM8SN; arc=none smtp.client-ip=209.85.128.45 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="YUBRM8SN" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-477619f8ae5so7625395e9.3 for ; Fri, 07 Nov 2025 07:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1762530015; x=1763134815; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rhXOhqg1sIDmdMzsCZzzAsthVHfSqnWAIntsnfsu5cM=; b=YUBRM8SNAYaK0gpnieK627FbHv3r/onK26Opg9seAnOpgGiLHEIx+GwdnrPO9OxdtF n9bQfKMaL9+4M4AZlIEvzNR11O2ZSaEu6+sYyE0sDYojm3ycUwSWUHhHuQ3o8HtdOFtE C5faBceOqg+I+ko7HINWXkoULwb1zv2+g9RotYtJ9VUNzeUWuB5Ayvh7/1VhIUmHj2ZJ DAWX2GrPhdTccANiPM2HCCDCow6y+pzxasmpSBNlFVPjJNwqQJDWPXsLi6T//LUGbJ6i IJKvkzwVI2GzXb9P26Nc/XlhHsgVakc0MB7RI/8zhlD2yYJrVlqM34Af1JZbyRH2NktZ xB3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762530015; x=1763134815; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rhXOhqg1sIDmdMzsCZzzAsthVHfSqnWAIntsnfsu5cM=; b=Gjf0ZtBJ0dlemKOHivUNjFaja0c2QHSmShBskiUXgsM9jYqeZg1FpPOU+RL4iSWn7q WN0rPjcygZNaUbsMyb08AjNkq6dm+Mxv76GplG3RlsCo+armFNnNZAdgdqzVetnw+8Cb Pac6aMfTVaT/uJmqPqfSSragwecGF8pRQcXTtH1j3JJlY3PAAXckGXKco48LNwWudd17 VDtQEfbtS0fQVT0VwDYEDNP8Ke6gl5o6pZRdNJRVQVxiIWLplxGo/jCkBhUOoO+tEHWv G9FXE331HWolFjstbmDxEdRNHBK3yAVzAWsocOzXIAzE5X58ZCk2pgK0jMSoE218wiOy aK7g== X-Gm-Message-State: AOJu0YzcN9x7gd9X4kVZQEotizI3AWmJG1uisZbWNJl3801RDSITRW0C 0K7IvZf3jo/duXng5zn+8mh64L+rb9vdrziwojsbF04e+ijbxegk7kSJjeF/k2XuRzJxyaDmAAv pYPal X-Gm-Gg: ASbGncuEbRXsz3llJrWqLGe8iMEoyYZEe28w7tOz8LAgo2/QZ5YaYfDXFhNC5xyxzrn 91j/rFeTCCIABpPwP2mMpjTTKP3g9+uoag0xIInFfsBtKKEzx9rLIO7jFMY4TCdgaJliMSBRgJh Z4vT+b/8ZMvyIP4XT5As8eVx/k30WN+o3LvNvWO2GE531LjDcanYYw31xkJ2lwgQBoQek0X2u8n TO4tP5uFQP/vFgjPEexL6zscqMjXQ0ON5OLXMkpdQ9px+Mcvtp9zucwkBhTzBAU7+c48zMRPJSP MFyd9HlljF72NvNrjuqGwwLa2PxldDVrZYUD/5BNYLMs1P9CV9e5mHrH5wDVNQqA6pQ0nTQJtQO 1DOduGRyPAiSCEApAZHHY0hdhuWNZr33vlBs5dg0RO56IVSOHCdLYHa9GMi0wq60KMvkxjRhvmr ObL2PdU7AvCMhDmhvuDarFhqw5 X-Google-Smtp-Source: AGHT+IFSx5eQ+BnvpINM9/8VhGI19WFqR+6DwHzA3h5TSyLVbX0IHAbZJD/pcebt4hPjLvWH8Ij7+w== X-Received: by 2002:a05:600c:46ce:b0:46f:b43a:aee1 with SMTP id 5b1f17b1804b1-4776bcff76emr28112475e9.38.1762530015224; Fri, 07 Nov 2025 07:40:15 -0800 (PST) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47763dc2b8asm49447385e9.2.2025.11.07.07.40.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Nov 2025 07:40:14 -0800 (PST) From: Marco Crivellari To: linux-kernel@vger.kernel.org, target-devel@vger.kernel.org, linux-scsi@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , "Martin K . Petersen" Subject: [PATCH] scsi: target: add WQ_PERCPU to alloc_workqueue users Date: Fri, 7 Nov 2025 16:40:08 +0100 Message-ID: <20251107154008.304127-1-marco.crivellari@suse.com> X-Mailer: git-send-email 2.51.1 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 enqueues 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 consistency 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 continues the effort to refactor workqueue APIs, which began with the introduction of new workqueues and a new alloc_workqueue flag in: commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq") commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag") This change adds a new WQ_PERCPU flag to explicitly request alloc_workqueue() to be per-cpu when WQ_UNBOUND has not been specified. 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. Once migration is complete, WQ_UNBOUND can be removed and unbound will become the implicit default. Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- drivers/target/target_core_transport.c | 4 ++-- drivers/target/target_core_xcopy.c | 2 +- drivers/target/tcm_fc/tfc_conf.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target= _core_transport.c index 0a76bdfe5528..ca571076c15b 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -126,12 +126,12 @@ int init_se_kmem_caches(void) } =20 target_completion_wq =3D alloc_workqueue("target_completion", - WQ_MEM_RECLAIM, 0); + WQ_MEM_RECLAIM | WQ_PERCPU, 0); if (!target_completion_wq) goto out_free_lba_map_mem_cache; =20 target_submission_wq =3D alloc_workqueue("target_submission", - WQ_MEM_RECLAIM, 0); + WQ_MEM_RECLAIM | WQ_PERCPU, 0); if (!target_submission_wq) goto out_free_completion_wq; =20 diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_cor= e_xcopy.c index 877ce58c0a70..93534a6e14b7 100644 --- a/drivers/target/target_core_xcopy.c +++ b/drivers/target/target_core_xcopy.c @@ -462,7 +462,7 @@ static const struct target_core_fabric_ops xcopy_pt_tfo= =3D { =20 int target_xcopy_setup_pt(void) { - xcopy_wq =3D alloc_workqueue("xcopy_wq", WQ_MEM_RECLAIM, 0); + xcopy_wq =3D alloc_workqueue("xcopy_wq", WQ_MEM_RECLAIM | WQ_PERCPU, 0); if (!xcopy_wq) { pr_err("Unable to allocate xcopy_wq\n"); return -ENOMEM; diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_c= onf.c index 639fc358ed0f..f686d95d3273 100644 --- a/drivers/target/tcm_fc/tfc_conf.c +++ b/drivers/target/tcm_fc/tfc_conf.c @@ -250,7 +250,7 @@ static struct se_portal_group *ft_add_tpg(struct se_wwn= *wwn, const char *name) tpg->lport_wwn =3D ft_wwn; INIT_LIST_HEAD(&tpg->lun_list); =20 - wq =3D alloc_workqueue("tcm_fc", 0, 1); + wq =3D alloc_workqueue("tcm_fc", WQ_PERCPU, 1); if (!wq) { kfree(tpg); return NULL; --=20 2.51.1