From nobody Tue Dec 2 01:48:38 2025 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.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 603A42E6CDE for ; Fri, 21 Nov 2025 14:53:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763736825; cv=none; b=cjw8ICpz5dYy7Cyl1QMauqw/i9QPdne0htQzCOQSjpI6bGLv2UW5R5c34NIM8/Zpexvl201ubw88L5oQVok/9mcz0kipESIAtk7DWjD1rf/skCsywe0qe+A+oTHR4pLyUj5xozYP4MlUwYTsITNnOlww2nEtKM6hhOQgWN7ISOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763736825; c=relaxed/simple; bh=4AluHisqWo8poypxlftnMHX4uSJuo2VGr086g1FiszM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y1Xjj2LVv5lFjfyOzrtKozZciAVhv4+UdYRhCj2XeymwbB1uV8rSykLfO0NHqcOm9FBJP2U4vCTjCUqgVqy248zzrXi03LiOshDYnWadaPqgdPcsDJoUbDliERGtZDHub50gUfl9ooglGiNHhqinMqAomsAMLq9vHVe7IaqJdLU= 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=JgFCpBpI; arc=none smtp.client-ip=209.85.214.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="JgFCpBpI" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-29844c68068so22782545ad.2 for ; Fri, 21 Nov 2025 06:53:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763736822; x=1764341622; 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=CtR9meOzOWHKnJZaBZzQ9II1g+OHQE4AnIqOa3Hn1OY=; b=JgFCpBpIdeFC6SbiP6P4r2lxRwUL0pCWbZE2peQkkZ+TeThF1+v+asFuKb2WXq6R/8 06pIqfWpUdT9aPw0CWD/59kPMIkf3oAElxKuZnDZDEj/xpuO0HWJbWj60uovA5UYGDgi Clxdc/EWWPjb1Z9SWxqUIj1ko3H+h78DanNF06kHCYlHEU7hj0zj2ddh/E30h2Es5Ko8 7Bues/kf40WXw9mQhcHv18vO4dQahteTczNy8erSXex9kNA2AX9x/uYHRzpUXjvxlx6t TUzplnWRopINwI4KxaRDA68RnJUA1khq4bQiRWFfAnG47UvZAvZ8uEmQWTLUIWqM2qKS 9oXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763736822; x=1764341622; 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=CtR9meOzOWHKnJZaBZzQ9II1g+OHQE4AnIqOa3Hn1OY=; b=i9I42Xrf9GzKYYJVolBpGjbCoo9850aCu8iMqYR92hEEK82h0RaBNHikPaSgZZUo9v +IvIxvNe8LJxUVhH9cD/OnbT+yxoXPrFWD0QcNQfpqLBxQ/NVOu7iBDn0s5nyQVqM+9R NpZIYd5oeuZ6hReajpktLeroMC46B9A8OTDoNDKaTpkY2V1CmylSZ5Cg5+EIwSUOefSO izl9jW1+2L4OGdmhbYRJrYCkqpYsjYy4LtRZniSJhz9k+lKIwFfpSgVDtGSqOKAcF0HN 6wEIgwpc9CyWIQYYLZdDVSFJIQ9RPLm8507PPBlS2QP9bhkrd27LOjMEjimgX0QbK6iB 0ZRA== X-Gm-Message-State: AOJu0Yxz8ou6FoBEP84jFu4abXwY/PX42Fw3GBeZf3wMZTT2lCd/DpLc f2149KyerhyFGw1fYymyHDfXdqQLDcfrlMgPfCz4MKQNx+QLerivOmdLf1CcXr5z X-Gm-Gg: ASbGnctu4CedOamdQ80dZVEy9DadQpfTDTUNuDoVzvd+3mi3XxtTIPxdlL0Iag/Km7w J+DRnT9YLK8RPEhyP4D+E2jybgrT5gQCtBdg/1LpYpW/V1KdoKiaMLXmVrfz5Ov0r5/ceilKSQv Uu0Lv3XGqKFw1yLtSEEI0KNV+S24J9X1aun5Y8mKPvPDdb7yxHlVkMoAK5U4hXoHm5oHYgJbq5Q jndEVkzblYDZeoV026CpebvoBkpJdjc9sT1mHq2A//LMw5Es9wgdU3JY01gFGeum6pTxDjhtlZm k80P2tDWzOU4UIRaBRgfg7Cair0g9c70ZTnd6YtB1HMqB3L7culPDxKzsvt+eGM6SAAGx6Q9ASG M2XkAN3h2NpqHZwhdGncOGXyf9lOodUBVhzej5AP74clhsJdtr5YY8LVpHpN7J+tdiP9F60veO8 7klXwAuLdnApQ= X-Google-Smtp-Source: AGHT+IF7tBHo/VRGa1ZvSvdUHpsnCMd+LWcZytsFK3yUE3RX1Jny/JlTPb2Iz2BHSDLlPO+qIvbt2Q== X-Received: by 2002:a17:90b:5588:b0:341:8ac6:2244 with SMTP id 98e67ed59e1d1-34733e7677amr2755582a91.9.1763736822414; Fri, 21 Nov 2025 06:53:42 -0800 (PST) Received: from localhost ([240b:4000:bb:1700:7b36:494d:5625:5a1]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34727be2fa7sm5809443a91.6.2025.11.21.06.53.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Nov 2025 06:53:42 -0800 (PST) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Tejun Heo , ying chen , Lai Jiangshan , Lai Jiangshan Subject: [PATCH V3 4/7] workqueue: Loop over in rescuer until all its work is done Date: Fri, 21 Nov 2025 22:57:17 +0800 Message-Id: <20251121145720.342467-5-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20251121145720.342467-1-jiangshanlai@gmail.com> References: <20251121145720.342467-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 Simplify the rescuer work by looping directly in the rescuer rather than adding the pwq back to the maydays list. This also helps when max_requests is 1 or small but pwq->inactive_works has a large number of pending work items. This might hurt fairness among PWQs and the rescuer could end up being stuck on one PWQ indefinitely, but the rescuer's objective is to make forward progress rather than ensure fairness. Fairness can be further improved in future by assigning work items to the rescuer one by one. Signed-off-by: Lai Jiangshan --- kernel/workqueue.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 943fa27e272b..3032235a131e 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3526,31 +3526,9 @@ static int rescuer_thread(void *__rescuer) =20 WARN_ON_ONCE(!list_empty(&rescuer->scheduled)); =20 - if (assign_rescuer_work(pwq, rescuer)) { + while (assign_rescuer_work(pwq, rescuer)) process_scheduled_works(rescuer); =20 - /* - * The above execution of rescued work items could - * have created more to rescue through - * pwq_activate_first_inactive() or chained - * queueing. Let's put @pwq back on mayday list so - * that such back-to-back work items, which may be - * being used to relieve memory pressure, don't - * incur MAYDAY_INTERVAL delay inbetween. - */ - if (pwq->nr_active && need_to_create_worker(pool)) { - raw_spin_lock(&wq_mayday_lock); - /* - * Queue iff somebody else hasn't queued it already. - */ - if (list_empty(&pwq->mayday_node)) { - get_pwq(pwq); - list_add_tail(&pwq->mayday_node, &wq->maydays); - } - raw_spin_unlock(&wq_mayday_lock); - } - } - /* * Leave this pool. Notify regular workers; otherwise, we end up * with 0 concurrency and stalling the execution. --=20 2.19.1.6.gb485710b