From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D9F7CD4F54 for ; Fri, 29 May 2026 21:29:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09A416B0005; Fri, 29 May 2026 17:29:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 072216B0088; Fri, 29 May 2026 17:29:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC9D96B008A; Fri, 29 May 2026 17:29:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DC2DD6B0005 for ; Fri, 29 May 2026 17:29:21 -0400 (EDT) Received: from smtpin22.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 77B031C03A9 for ; Fri, 29 May 2026 21:29:21 +0000 (UTC) X-FDA: 84821748522.22.3AE468D Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) by imf29.hostedemail.com (Postfix) with ESMTP id 85BF8120008 for ; Fri, 29 May 2026 21:29:19 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="Qs/GeC4J"; spf=pass (imf29.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.170 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1780090159; a=rsa-sha256; cv=none; b=fxvZkCtTQJokSFMCZxtSAyGLNie529Ynwojhrkl5MWIe3k6MRd2ZXEk5zHESBAb1aVnkWJ 0UKz385E6eIZXSrfkSyFx/oDwpo8mZY3GQWEvuVQXPG/PjULkh5yzc7xnLScc2cY4/CO9r XqiptY81CbdTXNVUTNOBVbfqT4HvJ8Q= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="Qs/GeC4J"; spf=pass (imf29.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.170 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1780090159; h=from:from:sender: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:dkim-signature; bh=JywH/3otXdM4lGyU+6UvJoj0eraUl9jHOX9YN/uPgf4=; b=XCnXg3zexX/jo3Rpdywc6gVfw2dOGvrxp1A5vPJnTxhM2olDBPdjALsYxf4tIo9xaKo8Ug oatX2BHBdh7Osfbxqun8ZhF8wSDqR36q3Fa8oe6OrsAnpiLkW2ZD+aoLFwjSlWhRABjzyQ Jmmmv8MBTQAqdn7/8+6JdUxr2c2NvPg= 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> 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 X-Rspam-User: X-Rspamd-Queue-Id: 85BF8120008 X-Rspamd-Server: rspam03 X-Stat-Signature: e41dh1mihwhd5z9n3gfaqwa9fojnkp7m X-HE-Tag: 1780090159-937820 X-HE-Meta: U2FsdGVkX1+T+N/d8hhrkcsOrRuXkmhYZyDsOXLrkkvbs8t2bAYnBmthzsSzRSxRrrTVKwKUdpKUTT3wVy0MRJC/thvwEirhsCvgh8I1qkvtFKlxOawnpBwit8CSO2wPKdaKNGVmHMMZ/kEl0G/gcaHTBFbKO1ws8ZE7yBkFK5KIaF7eoHAjIm9QGrPDfMjx8NKV0oaATaYRHtG+8sb/J0KnJ1rZjlvgwvUF99QUocEXNNeMropHH7knGCXyBTIBagahU4GYh61nfjzCQWFuHrGADa9jwD15c5rRA6uFjUvsfwI+uvLlW+m5AQn3F3OMgbD7IMCVzz5g9P5c79tvfZVTsYoNrCS77el1ip/RifwcaqRXpp183UikSmXuv+4dEYsV6P0jg7Z193By1unI8v22Wf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.org List-ID: List-Subscribe: List-Unsubscribe: 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.