From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E25181A08AF for ; Tue, 7 Jul 2026 02:20:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783390853; cv=none; b=rXzZYIS6UXEXdrc+co9ueF+Bo2m948qEd2CLK8nIvscSKI/oiTOklnb6PXH3UpEhXlkT1vBS6ihk4sL/d0ON7WBmB6GdFxbTpLAOjhFvYLiVC9adupnQlVIWS4WSiaZxDjkEZVfMsQlP9+SPyj34ES+T6KatZaRK+C0Nar25K8k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783390853; c=relaxed/simple; bh=a6yOd5MHuifzhOscW6dOsPyeJZx930/UYiIInT1xros=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ti9FtrnSUwwNMEliGsCL7hvidTLW9NLuRsmSsJ+0DkEdsS8M5Rm5Fwj9b4Dq8mb2VAKdtZ6n7hXVrVq1xwp5p0QXdO5RMKoxyl0voBUNJSv1wb485Zofr5OvaGdg1uQWTI6Be53bQAqLlK+8BisyMPTnH/x36NETpQAUkfMYKkY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KCEfBuSV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KCEfBuSV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBE951F000E9; Tue, 7 Jul 2026 02:20:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783390852; bh=xosg6/+k33dLwMJJrHbAyu6uGR9fsXM6wffwFdaii/o=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=KCEfBuSVz6P2oEpTaJQx86SF3LRLHMwOshO+F40I464fgDrvexALO5NQAwULi5JXH aLJ7IZFVochK86XKQ089uoU0xYNjydNNkhjlMEHMtfMo3LelDYe3+W4OqJniPzlZAl 1jK161ZjiMXJAX1RI06XVtJlQIvO16HwJdBuPxbRfgC2cWd5SRxQ7o37dGJtVHJQVk CTir5t2JUcbRRN8a97DIZ8l662PGISd6NLgKCP81i/efEPz1/L+NLpoa5SDZZ4ARSx OK/bhx6THWL4pzH0c9UuYw39G0//W8lzibYSCNgzqkp83tIZ+ozOzo+W/0X8AAUOYg YOoicMKgwdyDw== Date: Tue, 7 Jul 2026 02:20:50 +0000 From: Yosry Ahmed To: Richard Chang Cc: Andrew Morton , Kairui Song , Qi Zheng , Shakeel Butt , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Johannes Weiner , David Hildenbrand , Michal Hocko , Lorenzo Stoakes , Suren Baghdasaryan , "T . J . Mercier" , Martin Liu , Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: vmscan: abort proactive reclaim early when freezing Message-ID: References: <20260706081218.3438762-1-richardycc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260706081218.3438762-1-richardycc@google.com> On Mon, Jul 06, 2026 at 08:12:18AM +0000, Richard Chang wrote: > 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—scanning 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. Do we still need the check in the outer loop? > > 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; > > + if (unlikely(sc->proactive && signal_pending(current))) > + return true; > + > if (sc->nr_reclaimed >= max(sc->nr_to_reclaim, compact_gap(sc->order))) > return true; > > -- > 2.55.0.rc2.803.g1fd1e6609c-goog > >