From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (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 CF6913F23C5 for ; Mon, 6 Jul 2026 08:12:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783325550; cv=none; b=QncexHuHCAoHdqKmhxBDeE2+V+5XZRtY1N7DlOAOBvTItuqfPO7y/yEE+AUc970mS/YJmX/e2CBmblQ4jyKv7oCd9MrTKT5jb8O7P+0gkELFSeebEiAKtDLsr7HNgsWcsaOzqiepLQRD5XqqKSLnMDuAqUqTdLw5az9ebUAeJJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783325550; c=relaxed/simple; bh=w8H6D883nxMB0od57quyAjmhPwbxorNVsVf/Z89ziYc=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=N4b559wlVBXA8v2gYCJAw0gKYo7mIOkUA8Q86imN4qg9c0PJa8m+UOVy2gJ8dZcRznhZVZaorF1Ej3bskv+1+u+GlUHivDSCRnZpHutKPpS08bz36gsjCK8aopI65Zr+F35o1dDj1boScnKI6TAnLV6hLLehQae+dL+BYpHgKD0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--richardycc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=af5Tg/Wp; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--richardycc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="af5Tg/Wp" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-c860544c077so7694603a12.3 for ; Mon, 06 Jul 2026 01:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783325544; x=1783930344; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=YTUcwDBT/FSZkcadsKiSFZz3W4ZAzpY+Pf+uj15ZIZg=; b=af5Tg/WppNM9I3cJ8h1UyS3hfUUnIpHlxirNmjIzIBRBu7XUL+PNqTDJIZY/FxjjJb TuhSk4V3hRTmdYhCRnY2Ys3Xzw3xkc9SqoFecBebzN1iQlIkOyilZ6VWDRjYZt7zeiWt kKCN7fG+UIrW5FyVgmmSywBLaz3r7KdtPAN4E6ZF9djQFxIDxP9u+ftWtpY+G1MIVmxL mKPrGiBMVfl2q5vz9TapVh4PJTtsuS2ll6iX2YVhUF59lh/EyStLtQYmnI64UZ3pxEn2 rzYMFans29xyR27GTlmlcA7xpFQvgQnzYfwaQ2MiWuuJpccCHfhQkUE5DzDT0BVY9XCK tszg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783325544; x=1783930344; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YTUcwDBT/FSZkcadsKiSFZz3W4ZAzpY+Pf+uj15ZIZg=; b=pJORvuPwiWSNJ28DP69y/qQJtPiWxrACxCS9Db8wS3j4kP5zIxs0YH5gRa1RtSJQtj A5Gyo0SESfsDmLUk6sbItoXkbAXYD78JrTKxj8KUf+6b21OtOGt0D217zzRVafUvSccq KiUXH1CSpNU45p6VjaiS0XeL4dLCdRSZ7i306L04NJ8AMoSOVQVYsscLo+ILOMaJhYe6 EY3OkYkDSVuPA+X3f3Cbjg/JOfDM7JN9cap/kcLrk106zIA195dqvZJKIhQaiEjU0CJt IsY1DqCsElGz6hWa1wsTXFw5ncA4mkaCb4uzELQ8G1JCfLFJyKJZcKR/42F/wKFKMFnY tX/A== X-Forwarded-Encrypted: i=1; AHgh+RpnJs+FSLcfCcgn7710NztNkAxUMfGcjmvT297VKhB2vr36heoN0Y+rQNXoKkDaRslKGbQpQHgh/eydbzU=@vger.kernel.org X-Gm-Message-State: AOJu0YwW1UdS6zzY5cz0Cv3aBq7/yMr3AV64a+8es8FW8XBcTP6BjoCG wt9H0pUB17uSqJ1iMdUEMfRswBT6EZ/TufBQQCct5tLMOGTxiCpT8Xxhtf+zeq0j/soYEgFpgPD 1oHDCYzQciVM6qAmguGzK X-Received: from pght24.prod.google.com ([2002:a63:eb18:0:b0:c99:aff5:7078]) (user=richardycc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:32a2:b0:3b3:241f:66c4 with SMTP id adf61e73a8af0-3c03e4512ebmr9943428637.28.1783325543600; Mon, 06 Jul 2026 01:12:23 -0700 (PDT) Date: Mon, 6 Jul 2026 08:12:18 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.rc2.803.g1fd1e6609c-goog Message-ID: <20260706081218.3438762-1-richardycc@google.com> Subject: [PATCH] mm: vmscan: abort proactive reclaim early when freezing From: Richard Chang To: Andrew Morton , Kairui Song , Qi Zheng , Shakeel Butt , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Johannes Weiner , David Hildenbrand , Michal Hocko , Lorenzo Stoakes Cc: Suren Baghdasaryan , "T . J . Mercier" , Martin Liu , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Richard Chang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Proactive reclaim (via memory.reclaim or node reclaim) checks for pending signals in its outer loop in user_proactive_reclaim(). However, the inner reclaim loops=E2=80=94scanning cgroups in shrink_many() and evicting folios= in try_to_shrink_lruvec() can run for a long time before returning to the outer loop, especially on systems with many cgroups or large memory sizes. This latency in responding to signals can block the freezer (both cgroup freezer and system suspend), leading to freezer timeouts. This issue was specifically observed on Android when attempting to freeze background cgroups while proactive reclaim was active. Add a signal_pending() check to should_abort_scan() for proactive reclaim paths. Since should_abort_scan() is called within the inner scanning and eviction loops, this allows proactive reclaim to abort early and return to the outer loop, ensuring the task can enter the refrigerator in a timely manner. This check is limited to proactive reclaim (sc->proactive) to avoid affecting reactive reclaim paths, and wrapped in unlikely() as it is a slow path. Signed-off-by: Richard Chang --- mm/vmscan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index 35c3bb15ae96..fb472e924fc7 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4929,6 +4929,9 @@ static bool should_abort_scan(struct lruvec *lruvec, = struct scan_control *sc) int i; enum zone_watermarks mark; =20 + if (unlikely(sc->proactive && signal_pending(current))) + return true; + if (sc->nr_reclaimed >=3D max(sc->nr_to_reclaim, compact_gap(sc->order))) return true; =20 --=20 2.55.0.rc2.803.g1fd1e6609c-goog