From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796135326; b=cLEAiSxJxWHsI7s9SkHBG9oVOz+2pw0I10vQYjV48grFRA286BYrxtsMwCqQI6A7BSTL EFD5KeH5C7/dkCeBpAp7W12kbfbxCz789j+WJ6rk5v8mb7BgmVn1IZnNTx2JvFFLnQkxq vRtflflr07mZf2ZgzYt8AdyTas+ZkGc1NSNPxUHvkQ6wf8ZRtb4A98weizR9dH6HGadD1 CuUd5rAjdWRL76kfh3WsYfr+O2NGQRYQEnnDZg5fRBbmocR27o5lq/f9TguD+MP7eRw8w FT7iUhb1Jn1cDuChyrcekaB6o/te0NGtdqBXoY48BBUfI0jykAs1y2GrwHQaYgExrcQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796135326; h=Received:DKIM-Signature:Date:Message-ID:From:To:Cc:Subject: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=vCXBMC5uIvHjFe5TwV9CKLUUTdjKTDmGQVmd3QQxMgc=; b=Pdvh82n3g6gVhsS1gyJupDek1NqnCqNGLdi0SN2NjWXdIF4nKYx2VqxO3GuIxC+YsqlS xOeylKi6qA6P4g6BrQ6sJvmjGBNlzGdWyCNG30dwxaHoi+xvDY1Mu7qeORcpg/SEIQJoX JjRQnLUACl0ikB//1gQHMlXf7s7jNEqdetEyX98HzC5xGWIU8YmAbJgWQmfiBlKFJPhhL TLWYkZtXwP2MCUSU89Sy9nisdkeGrFTt+F/Y6G0vp8zMd3dECwyEdGsmDJSq/8fFfvmLn cHWWI8oSoI9eyqdgmlWLZJ+5BiRMLcUI24OMhmmLDEd5Rwp9Z02t6kdgS3CMngx8dEg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="VYRlJ/Hx"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E04D606A31A for ; Tue, 1 Dec 2026 14:28:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VYRlJ/Hx Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADBA71F000C1; Tue, 1 Dec 2026 14:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796135325; bh=vCXBMC5uIvHjFe5TwV9CKLUUTdjKTDmGQVmd3QQxMgc=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=VYRlJ/HxghVkq5AG8uAWgGkSiNq/ajhhZjkq7aeSqyzAmnzOftRofq42Q5qxNeu2h E7uSMYAha80G/H0RKN0cID8XVIgtpTs5nV5pktde5k54mXfD5VcI5KxXAy4hADFxl7 OvyWoBSa3LwQUn1wpP3IMjTd+3tPl3MsvcuX04cpgkfxYn1I1GOa6D4mDJNFIvnRgM jogIPZFiJ8YbM4aHz3+6DAU2CdyKp0cNcV1nIwcT2hO3eLdLlVBPUDoOHxkQqtGp6o wzdf/OWNxG9g+zUIKosp6jPX7HBiiLF2sG6no0Q97JVt8C2BKwpDZvXMx9kLtny2Ow e2ckkJ7J0Dkkg== Date: Tue, 01 Dec 2026 04:28:44 -1000 Message-ID: <8e5de3f34b131c469ca307486b9c9969@kernel.org> From: Tejun Heo To: Marco Crivellari Cc: linux-kernel@vger.kernel.org, Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Michal Hocko , Breno Leitao Subject: Re: [PATCH RFC 2/3] workqueue: Offload WQ_PREFER_PERCPU work from isolated CPUs In-Reply-To: References: <20261126152458.742942-1-marco.crivellari@suse.com> <20261126152458.742942-3-marco.crivellari@suse.com> <61d55bd46d48bcf8ca03aa7ce517d000@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello, Marco. On Tue, Dec 01, 2026 at 11:28:31AM +0100, Marco Crivellari wrote: > Yes, that makes sense. So maybe we can use WQ_AFFN_CPU with strict affinity. > Even without CM, users may prefer better locality when the CPU isn't isolated. I wasn't suggesting WQ_AFFN_CPU. My point was that the description and comments give locality as the only reason, and WQ_AFFN_CPU already covers that. PREFER_PERCPU is for users which benefit from concurrency management but don't depend on percpu for correctness. Can you update the description and comments to say that? That's also why I'm not sure about switching the pwqs of isolated CPUs to unbound pools. Work items queued there lose concurrency management. How about staying on the percpu pools and picking a different CPU when queueing? When a work item is queued with WORK_CPU_UNBOUND on a CPU which isn't in wq_unbound_cpumask, __queue_work() can pick a CPU in the mask and use its percpu pwq, similar to what wq_select_unbound_cpu() does for unbound workqueues. All work items stay concurrency managed and no pwq has to be switched when the isolation changes. For picking the CPU, maybe round-robin among the CPUs of the same NUMA node which are in wq_unbound_cpumask, and fall back to the whole mask when the node has none? queue_work_on() with a specific CPU should stay on that CPU. > The Workqueue marked with WQ_PREFER_PERCPU is also WQ_PERCPU. If the CPU > is isolated, this workqueue is backed by an unbound pool, and > node_nr_active[] isn't > allocated there. So the "if" above wouldn't have been taken, which would call: ... > With your suggested approach, this is no longer an issue anyhow. > I will drop Patch 2 for the next version. With the pwqs staying on percpu pools, is_percpu_pool() keeps working there. This is also where the discussion with Breno was heading: https://lore.kernel.org/r/ec6c22eddc8ce0b1ef2434ed62acd560@kernel.org PERCPU becomes its own scope and a WQ_PERCPU workqueue can't leave it. A WQ_PREFER_PERCPU workqueue starts in the scope, follows the unbound cpumask when selecting the queueing CPU, and can be switched to other scopes. So this patch would be the queueing CPU selection part, and moving a workqueue to an unbound scope can go through the scope change path. I haven't tried any of this and these are suggestions. If you find a better way while implementing, please go with that. Thanks. -- tejun