From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (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 366193B5847 for ; Fri, 29 May 2026 21:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780090161; cv=none; b=NuSwIyqVTUh8wKPqDkQIAAZcvS4/UbtxTaXFK1dp1+Hvg29WHZ2rdk3+aHBE+XF8A0/rnofMJ8MUc5FueK4ICTWvN37pj1B9sLGEIoJYUCcirzdrLP+/i5RCs4jsN1LIAavaX3INfs/lEMi1MLls64MMtA0b9CjUPA3zlONjnhI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780090161; c=relaxed/simple; bh=LlPoglQJ5uQFGoqeXr668WpaKfit3NsdGgX9WYy9s7Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=doPly7WA9aDBWmTdi9atIIzZmgIr/bHRs32qtqBQ/2MXp5ufxuWzuDFRr7kwMINi2LgfGtNRVLmGGXXQK7lWY/G6BgRTBjB44vm+7FrBcPHumgG6vYfqx+SRqVCqdD2E8gFCHbQXgqiORBX9N6O9YIEHZMQMJ8qvMz08GZ5TCLA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Qs/GeC4J; arc=none smtp.client-ip=95.215.58.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Qs/GeC4J" Date: Fri, 29 May 2026 14:29:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1780090157; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JywH/3otXdM4lGyU+6UvJoj0eraUl9jHOX9YN/uPgf4=; b=Qs/GeC4JcxgJ+DiZ/fwuqRIk0L6jEEntFkyGxQUh81YDcysn1RvUVWpULR5+YQ1oxvpWxH Ycwr7h9W7aPgdGFNBrPPcWKHcvUvytW/ca77pWi+IlepBdX+8XfJEO9Y4oyRxDNOWoTbRL gRq5HJqKi1tbtKAfk+zT8dkw09KdKRg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Kairui Song Cc: linux-mm@kvack.org, Andrew Morton , Axel Rasmussen , Yuanchu Xie , Wei Xu , Johannes Weiner , David Hildenbrand , Michal Hocko , Lorenzo Stoakes , Barry Song , David Stevens , Chen Ridong , Leno Hou , Yafang Shao , Yu Zhao , Zicheng Wang , Baolin Wang , Kalesh Singh , Suren Baghdasaryan , Chris Li , Vernon Yang , linux-kernel@vger.kernel.org, Qi Zheng Subject: Re: [PATCH v7 03/15] mm/mglru: relocate the LRU scan batch limit to callers Message-ID: References: <20260428-mglru-reclaim-v7-0-02fabb92dc43@tencent.com> <20260428-mglru-reclaim-v7-3-02fabb92dc43@tencent.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: X-Migadu-Flow: FLOW_OUT On Fri, May 29, 2026 at 02:01:43PM +0800, Kairui Song wrote: > On Fri, May 29, 2026 at 1:40 PM Shakeel Butt wrote: > > > > On Tue, Apr 28, 2026 at 02:06:54AM +0800, Kairui Song via B4 Relay wrote: > > > From: Kairui Song > > > > > > Same as active / inactive LRU, MGLRU isolates and scans folios in batches. > > > The batch split is done hidden deep in the helper, which makes the code > > > harder to follow. The helper's arguments are also confusing since callers > > > usually request more folios than the batch size, so the helper almost > > > never processes the full requested amount. > > > > > > Move the batch splitting into the top loop to make it cleaner, there > > > should be no behavior change. > > > > > > Reviewed-by: Axel Rasmussen > > > Reviewed-by: Baolin Wang > > > Reviewed-by: Barry Song > > > Reviewed-by: Chen Ridong > > > Signed-off-by: Kairui Song > > > --- > > > mm/vmscan.c | 16 +++++++++------- > > > 1 file changed, 9 insertions(+), 7 deletions(-) > > > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > > index 7f011ff4c478..a011733a6392 100644 > > > --- a/mm/vmscan.c > > > +++ b/mm/vmscan.c > > > @@ -4695,10 +4695,10 @@ static int scan_folios(unsigned long nr_to_scan, struct lruvec *lruvec, > > > int scanned = 0; > > > int isolated = 0; > > > int skipped = 0; > > > - int scan_batch = min(nr_to_scan, MAX_LRU_BATCH); > > > - int remaining = scan_batch; > > > + unsigned long remaining = nr_to_scan; > > > struct lru_gen_folio *lrugen = &lruvec->lrugen; > > > > > > + VM_WARN_ON_ONCE(nr_to_scan > MAX_LRU_BATCH); > > > > Do we really need a warning here? Also why are we limiting it to MAX_LRU_BATCH? > > For memcg/proactive reclaim, we can get larger number. What will break if we > > remove this limitation? > > Hi, > Isolating a large chunk of folios off the list is usually a bad idea, > livelock is one concern, besides, concurrent reclaimer won't see them > anymore, and LRU operations on them will be skipped (eg. roration). > Under heavy pressure, this could lead to premature OOM because some > reclaimers will see the LRU as empty. or accuracy loss. Oh this is the isolation count/limit. CLRU isolates SWAP_CLUSTER_MAX folios at a time. Any reason why MGLRU does 4096 (on 64-bit machine)? Later we should evaluate what would be the right isolation count and use same for both unless there is some inherent reason behind the difference. > > There is a LRU isolate throttle for CLRU, which is missing for MGLRU, I am not a fan of that specific (too_many_isolated) throttling. In the long term we should properly throttle the number of direct reclaimers.