From mboxrd@z Thu Jan 1 00:00:00 1970 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 CFDE72874F5 for ; Mon, 17 Nov 2025 03:05:33 +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=1763348735; cv=none; b=O5MF+8Xxb0SPUdwhKVWVTdAx5nukWt4w8OMvobQ0zB8cohcdHA8Kjz2ZMlhb3/9iMesaJnw/9phlFmR5qJibG9How+7Fqqkx8xeglIZrwb6vGrGrvREPf9kTG/+QwaPezFpT4IXqmMnvaIy3tdBD6FwVyDTwyQHuFvPK9uGlLJE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763348735; c=relaxed/simple; bh=Wmx+/+YTPY5GBVtrrPnfkVcXooy75sUXnCkr3iH/58U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jPadIWpoRfE1A9H8F1iW5WvN/9fzP/wNYjDulWL5ayy3OpZfoGklulMz+G/ZNR/JYHiiURo1bs/uQx2WHWiVepuqbBETQLLUu0zCT8fdmgnpa1BAVwusTk4T0SF/TWBDYwqfNgweC+dfhvMAsCHz4cqC95NzE4rtXZAG9rTALrI= 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=MQbtf+4z; 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="MQbtf+4z" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2953e415b27so39357695ad.2 for ; Sun, 16 Nov 2025 19:05:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763348733; x=1763953533; 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=x6mU11YY1mzaFcdkYBhBqXDAK90i8/hik5fAizChpqc=; b=MQbtf+4zBL15S2ZHmBkWPlJkGoN6RezwvxJgN6WPp1oVDP8LODeRk8rili4S3+r8G7 2jkPX5x2JlyRaOIQIOMXDbhE3603fOWvYIwOI4ApiX2ue56Vlk65gVFWf83Kzf4PSCsu 0Bs6YPJ8MphXG1chCTH4vE93yXfPwSosUZInH6isIljA0mrgu3f21lY1EAkyHx3r3y3p bqLP/oxnegsrp44s57c1L/4DBQNi1RnsyTUKcR97ynp0rsyFZAJOz04wq+ytmf5y1pTh ragIVe3dxyz9CFj8+vOLH0D5Fk9WMKkmHV9fxL0/1o7h1kYtPZ3XjTQ5V30tx+aPrsTB Hb9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763348733; x=1763953533; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=x6mU11YY1mzaFcdkYBhBqXDAK90i8/hik5fAizChpqc=; b=BEE9c30bsqd98pUx5RWFhn8ZuBtVHAQAlng9AuADGXUq/BmILKkJwGZyIKTBA2njnl Wdo3qrjDvhAt+sozhteIySGDRWNM+ZXqgDRQYPLVmSJ0ZJ4FUkACq/KXIYW16O1odxpT B04Lpswuw83f+RwMggj7U8Y8frF8yXcbiNCXGkFT/MEtuTtBQUy3GOEuit3nnNcw9VkP q6p2huA6hZUv8/I/L4KYJrxKzBGpVd7BQ2ZOyteQLtchC81i7f1GvtQ2awI1tfhIlkkH PAG43gE8kNyZhSqHASRJehiLQXvOKf7tajQ4oN9ltTFdsmDfhIcPHnFByjd/Xg2zfklB Lwag== X-Gm-Message-State: AOJu0YyulPOwC1LRntz6PQl0rutandtWSd1k2AzLiZZNT4DATXaN/8YF frgyozG/GXZ3lRGOVBIgk+cPZpglysB1HpH6G2yA5Bf+uGu4T2blFTEvRufZr5jh X-Gm-Gg: ASbGnctEFaA6Dngi2Gw9QAicCrjFPc2AztMRs95gDhfUWZG+T7E/9tLeEuWKdXmG3sC KMxzv22BtOZtF5gkXFJYcxNmEn2CsfPjkWtlwd9kbwvioK9RbmgtrX9LUM87kz05zA5Ss87+x/E HD0Rg3+SCPZD+JFqFxEDPAAtyCQWMm/wUgTY8f3P88bMzBa0fzKNrs3vyCIMdAc0VYAtUN9vYPb /1TzE9PBpTD2mVgHaoOMrJxPXZInrAS6hNEtjW3zc+8v2DhhdLf4F6Bv9gh1H5jgnmWiaTk4jcm pLOHuu9aKuCy/lcVg0gg1FOPAwHClCcYsFDpAZj1NW7Mx0n3PRq50br34isCo1QwDlFqQGnvai9 /fF4D7vjT5tSA4gbtuYht4dAtMCnruhoBcbDuS08C7vNmAwiQBSQRGXW46i6QP8uKavrys2Grew == X-Google-Smtp-Source: AGHT+IGtW2nMXf7GIOzJW7y7k7kjln0+UT+NOr9PrNBJV6bGS461Q4Bl7fPtjApH0Li+qDCvRbr9mA== X-Received: by 2002:a17:903:41c7:b0:298:344:1229 with SMTP id d9443c01a7336-2986a76b5cfmr128899635ad.55.1763348732888; Sun, 16 Nov 2025 19:05:32 -0800 (PST) Received: from localhost ([8.219.87.167]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2985c2bed5asm122007615ad.88.2025.11.16.19.05.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Nov 2025 19:05:32 -0800 (PST) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Juri Lelli , Waiman Long , Tejun Heo , Lai Jiangshan Subject: [PATCH 3/3] workqueue: Init rescuer's affinities as wq_unbound_cpumask Date: Mon, 17 Nov 2025 11:09:13 +0800 Message-Id: <20251117030913.3084-4-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20251117030913.3084-1-jiangshanlai@gmail.com> References: <20251117030913.3084-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: 8bit From: Lai Jiangshan The affinity to set to the rescuers should be consistent in all paths when a rescuer is in detached state. The affinity could be either wq_unbound_cpumask or unbound_effective_cpumask(wq). Related paths: rescuer's worker_detach_from_pool() update wq_unbound_cpumask update wq's cpumask init_rescuer() Both affinities are Ok as long as they are consistent in all paths. In the commit 449b31ad2937 ("workqueue: Init rescuer's affinities as the wq's effective cpumask") makes init_rescuer use unbound_effective_cpumask(wq) which is consistent with then apply_wqattrs_commit(). But using unbound_effective_cpumask(wq) requres much more code to maintain the consistency, and it doesn't make much sense since the affinity is only effective when the rescuer is not processing works. wq_unbound_cpumask is more favorable. So apply_wqattrs_commit() and the path of "updating wq's cpumask" had been changed to not update the rescuer's affinity, and both the paths of "updating wq_unbound_cpumask" and "rescuer's worker_detach_from_pool()" had been changed to use wq_unbound_cpumask. Now, make init_rescuer() use wq_unbound_cpumask for rescuer's affinity and make all the paths consistent. Cc: Juri Lelli Cc: Waiman Long Signed-off-by: Lai Jiangshan --- kernel/workqueue.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index ccf03a0ff122..acec76a22ce4 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5644,10 +5644,13 @@ static int init_rescuer(struct workqueue_struct *wq) } wq->rescuer = rescuer; - if (wq->flags & WQ_UNBOUND) - kthread_bind_mask(rescuer->task, unbound_effective_cpumask(wq)); + + /* initial cpumask is consistent with the detached rescuer and unbind_worker() */ + if (cpumask_intersects(wq_unbound_cpumask, cpu_active_mask)) + kthread_bind_mask(rescuer->task, wq_unbound_cpumask); else kthread_bind_mask(rescuer->task, cpu_possible_mask); + wake_up_process(rescuer->task); return 0; -- 2.19.1.6.gb485710b