From nobody Tue Dec 2 01:03:32 2025 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 E3DEE298CDE for ; Tue, 25 Nov 2025 06:32:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764052342; cv=none; b=cHAq0+Wyse27eV4caG1bZQecSwGfJaxJHoQTfYLyoSJtaSmCSOFyAwuFhdwusPdwEyQhm7PwBPDS5/ozmGVda8cuJvJ1rh2b3gn/aY2HaHkCwhM8nIc4dDlThUkFRIU4og55RXW59EVukp5sCUVEba+J1w8f+hSk4u73GsYk9ZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764052342; c=relaxed/simple; bh=kzsApZ8k7L9zdQootOUd+LETAxNM7N9sI8AEUxviAsw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sBmOIV2BkAK0bVSrKF+OXOPgLhUksxduQzQJ+ehgJXCFsbKu1yk1Pq+dFrgp623ueDrzn/hNvhpy/WnYuKSjciY05qr/DEUDW3zuzrX9BbaV8FRlYtNwqX6GuC78pzbh+d1UarZNimoYg+S4NtAuC2zqUFYWId14TIEcbYWngf0= 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=cW9Yaq6u; arc=none smtp.client-ip=209.85.210.174 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="cW9Yaq6u" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7a9c64dfa8aso3979324b3a.3 for ; Mon, 24 Nov 2025 22:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764052340; x=1764657140; 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=c/8nTaqZzY56h+wYOzS7tOWNX+nlZk/rLssu/KjYUAY=; b=cW9Yaq6uvtTp3+xXxJN6RcQhymlMshDi+WC8gORs8+owKAh5H9z3zQcHMBnB4GGfmX fdOKUJ9CFbTi7RHz/5LCOU883PweAvyvCxZCAAnDqOlnoKPS2raUQ1wfC45tlKq05Svs 1gyRSHJFIY+X7I2jQgoBm0jydRiFOrZ3JP90hH+YKhPFK59jAdYGhdIycBRUK/mn83n7 OTGgH5OUCTFniRcQOgfCnrgUt1aNawiv3C1Ty/VwvFrz6ROCMJRMYad5Sca+vrlyBYOC pM2syZbPX3XDMJx6p/8I9zJfEE+6mIhzTRtQl4hhnUANN8bPgFPLpVX7sZr2IM5w39bE 9yxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764052340; x=1764657140; 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=c/8nTaqZzY56h+wYOzS7tOWNX+nlZk/rLssu/KjYUAY=; b=oAqaxvABO9h2Ca7K/98BDhfjfclMIqwE3yLl4eSRNjEbYlbo5uxnNPnB9nikJf/Z/N +AHDXfkK5/rEWrJ6F15xbkUJSVuyHpuTBQBPgRjrKnU7WLcg2C2cyaHd3FqYVYcwEbLZ hJEJoJay7tjH6KbEv8M5c5kVbG9xswS5F2fSDh2dc/IezCmxg64Nxl5oy4b1uyXG7X7O gK7tEpGEYtaMPqkEKAL9hFdIRt2k/+VUo0f03wiVbHQw+pNMuyTOPWIgAsW1VMuKm9j7 3bwnGIT5cnaHzqH0nUG91vjRnl9sSQtrG9Ze/xdTS/jxB21NntUaO9PJt0Rp8bRxOIUz Z/eg== X-Gm-Message-State: AOJu0YxAEpQATZtx3j3AGBLPH5p3vIAZDodTZS4tQu2lab/F8HILMOm7 xFziePNrjsrrdRorYFkRDQZw5H+PSMM4D4wynNA/cavO261t1OBfvatdObVU2Gbq X-Gm-Gg: ASbGncv8ETWP8B8Rsoy3TaiZSsTpwrWU3PRtV+88QcwvMwCZvFh5z2xFF7fUaBSj4rS rUzX+IeBMDSBwoI1zB8OYhYJ3PuY9IOlMsESK2PVRYgGw4LfIBSVxgpsH2tpcxwHwgSabmtVzLO hHMLFQmqtUtj0GUfcY4N5qxNEfhxtTqAdHvOooBw1Gn5xt7izp4/Bi6+7CbBYJOyjn19fGu18eh n/LZPBhV6IkLdFlygBuI5KujiBcMj1B6bcQIIj81DhrPQCYREtHE70LXvFPelEcbYgEaj+IS9os PsLuG2IJ3dakK4ixUZTTGRi5GxhjaGP8b6VW5V++Sj5S2VPZSMaVd0sL2hk2aeyoND1TKV3IptF 9c7ddGmdv0S/j2SRgZw9e+0ktX2g6IwmAeDfppe1rCojrH217HRl124VuYRRn0btay1W8N7TSci y1Kvnktf/U+ds= X-Google-Smtp-Source: AGHT+IG8Aj1LNsOBYeqbsFiew9Kaim6+3OzL1fGJPrX0hh3JPJ8Nn+KzfiRnmui+CrDnCW8oeLq9WQ== X-Received: by 2002:a05:7022:7f11:b0:11b:9386:a38b with SMTP id a92af1059eb24-11cbba87ea7mr899017c88.46.1764052339740; Mon, 24 Nov 2025 22:32:19 -0800 (PST) Received: from localhost ([240b:4004:a2:7900:ecf3:dec8:8c1e:4f6]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11c93de6d5csm53578599c88.4.2025.11.24.22.32.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Nov 2025 22:32:19 -0800 (PST) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Tejun Heo , ying chen , Lai Jiangshan , Lai Jiangshan Subject: [PATCH V4 1/4] workqueue: Loop over in rescuer until all its work is done Date: Tue, 25 Nov 2025 14:36:14 +0800 Message-Id: <20251125063617.671199-2-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20251125063617.671199-1-jiangshanlai@gmail.com> References: <20251125063617.671199-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 and this is a temporary change to ease the transition. 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 2654fbd481a1..02386e6eb409 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3520,31 +3520,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