From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 B756A20DD51 for ; Fri, 3 Apr 2026 09:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775207390; cv=none; b=bYmCEKzOccaFNLu9yC1h5vgX2I05a4FCuokPRBTuNVLqaSNjJx3A5ZhRbEUt+cD/uQ3BdJa05b3oMylFGEUXQDtBA0F5wNi6U3eRyvHVX+IEqkqLQv8RwQ91CYKWq40F21lD6lVnGfZjzDb2/6uLfyaF5+buFSpU4wSk6Ssqpt8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775207390; c=relaxed/simple; bh=EhrUZU4V5PvDAEivpEvDdL6boJMss3s7VCiFr9cbTlI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z+WiQpCnxsFNH5iVbH2l6/KVLd0WbLPRxoqIG2rfGjWaavSG/u1pTULtA7DkNqQDXUa7RnpR4SFYBDlrw1C67KFr8DMMfoPEndCrWpMwUgyGFP7D6dOQGrbfsU4cx++vju/0e2wYkuALLmM1h3Bo5bIgZNPzINKPV1zx8ENFWU0= 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=m6j+DrJQ; arc=none smtp.client-ip=209.85.214.175 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="m6j+DrJQ" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2b2503753efso14230475ad.0 for ; Fri, 03 Apr 2026 02:09:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775207388; x=1775812188; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=sz9Wfwf4HE6//HLhFzHYY2ZdJLoQJfdOpKqVtfA7nik=; b=m6j+DrJQG/jfGWoxF+XvtdS0kiOhJroGOsrH20ydkM8U55+lepkwEmbxm/OZWKiPSa 1zs0TlQQnA4C9gVxVf1roXSYqvaq4TPaYyjpH9ZiQQrVVwY3auopLRNSObJ4smnA3Oki ChBLEl9z6O2TFa5EpyEzel4GGhbSbFQMyrPcdo/tQ3JQ39UWIQl+BYtmX2npSLF29pF8 mS1sKeIRJVbHrvMg7H9EzUnAKTcYI6y7NoUxmzJIIwsKtmzba7kcpzpYkNPoUx6BrDov YNLJAweED4UClgUWpJmwkWKv+6bpf88JJbLEsHWRpIS+PPwgb2U48iBa4HAyJguYzLzW U8XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775207388; x=1775812188; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sz9Wfwf4HE6//HLhFzHYY2ZdJLoQJfdOpKqVtfA7nik=; b=PsxmFKMLwZjpDEoJHETjRvPzRf3jI5uzuLEoXb8yftLRNxuAq+BcCEFuXWZolFMefB Ob4fw+YMHgEjfbRdpfNA8dBbv9NsHBOtNSBwbTIfYQKcNIAS3Lt/G8fJfPiB3qHxwVPW q0T6ioxB2mIixdW7vTm6wlLxI2lkAHIj+M4+EMX1X6qyiUORP9RCTnbCSAFYuIx6lUSx oP0yjVoZ4dmTjPYAXO4fj5g7xrPzCPu6NJmO0O06i+rxCCaHX3LGZg7JhLQ9UyjPO89p qoKFpkr/cgcq9+0QX2+lh37+890lcq77Q6KPifJ7MSyG1xet3Hc6TB9L018FBhZHVd9h g2Sw== X-Forwarded-Encrypted: i=1; AJvYcCWiHbHsTZhZi77oa3VAmZmpoIMoX2QaHxGUQ3d95bg/svUC8GszwtyCS2z6lsLEPI6a20v7DDb/A5CvHW0=@vger.kernel.org X-Gm-Message-State: AOJu0YwatSIo2F8d3h1pzit6gEI+n4k7Rzsi1vlSyhNHQ3uAvzxDtQ3S j1TqUBt4+lltYze9+3KW/hk77ULT71Rjjy3S9i+Bp3Ikt/HfHHvHHj4D X-Gm-Gg: AeBDiesaPYTSHBtTuKCtF4ygcVLmH3ZmI+cN14bf/Epzyu1QXR2iRGkHLoKFIg3I/xG aRB4KS+bSkISyYONkzeMuORLvtgXcZ42Y/UmjXz8/xkIoS9ktQgPOQYfmADGYhvJWJtRLa7ry0l np1ZPSxgdM+rRu7UhfoBCbJ3VtyqDmtNRxzJ2PICmiQ6FYg20Ol7hAQJmYGPGTAeIU/l01Gqm34 pI4whtFxzTpfl7Dn6egJVkU42Nb+KWDpiMDOFPStZlX8+Y3Yh+AN3SgyqFEMsYudtV502TtOTNI 5p8Lr0eWkMOtRrkNtiy3gqkNOCFQnogY9qNgTVZQRwow45I/QZ9vDfdiFF6UvbwiJzm4BElfX9G GmUUyns96Q0i+8UNYI3VADllWwtbfoiL9+/Zqg8X1w4gJ0sDexfA0E+AabHf7TR7i/NO60HLEXx F9DoNVaRfqsL59JstFBr4pcEzLKkAP7Xf1Q+BhXnv7TmbFg/8jpZyIi4dgw6tghnuqXqudUhzU4 mRdmnw= X-Received: by 2002:a17:903:f8d:b0:2b2:42da:25cb with SMTP id d9443c01a7336-2b281888ac2mr27934165ad.19.1775207388021; Fri, 03 Apr 2026 02:09:48 -0700 (PDT) Received: from KASONG-MC4 ([43.132.141.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b274979525sm64174565ad.45.2026.04.03.02.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Apr 2026 02:09:47 -0700 (PDT) Date: Fri, 3 Apr 2026 17:09:40 +0800 From: Kairui Song To: Barry Song Cc: kasong@tencent.com, linux-mm@kvack.org, Andrew Morton , Axel Rasmussen , Yuanchu Xie , Wei Xu , Johannes Weiner , David Hildenbrand , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , David Stevens , Chen Ridong , Leno Hou , Yafang Shao , Yu Zhao , Zicheng Wang , Kalesh Singh , Suren Baghdasaryan , Chris Li , Vernon Yang , linux-kernel@vger.kernel.org, Qi Zheng , Baolin Wang Subject: Re: [PATCH v3 06/14] mm/mglru: use a smaller batch for reclaim Message-ID: References: <20260403-mglru-reclaim-v3-0-a285efd6ff91@tencent.com> <20260403-mglru-reclaim-v3-6-a285efd6ff91@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: On Fri, Apr 03, 2026 at 03:50:37PM +0800, Barry Song wrote: > On Fri, Apr 3, 2026 at 2:53 AM Kairui Song via B4 Relay > wrote: > > > > From: Kairui Song > > > > With a fixed number to reclaim calculated at the beginning, making each > > following step smaller should reduce the lock contention and avoid > > over-aggressive reclaim of folios, as it will abort earlier when the > > number of folios to be reclaimed is reached. > > > > Reviewed-by: Axel Rasmussen > > Reviewed-by: Chen Ridong > > Reviewed-by: Baolin Wang > > Signed-off-by: Kairui Song > > --- > > mm/vmscan.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 643f9fc10214..9c28afb0219c 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -5008,7 +5008,7 @@ static bool try_to_shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc) > > break; > > } > > > > - nr_batch = min(nr_to_scan, MAX_LRU_BATCH); > > + nr_batch = min(nr_to_scan, MIN_LRU_BATCH); > > I’m fine with the smaller batch size, but I wonder if > MIN_LRU_BATCH is too small. Thanks for the review, Barry! It's quite reasonable value I think, for comparison classical LRU's batch size is SWAP_CLUSTER_MAX (32), even smaller than MIN_LRU_BATCH (64). I ran many different benchmarks on this which can be found in V2 / V1's cover letter (it getting too long so I didn't include these results in V3 but I did retest). The new value looked good from large server to small VMs. It's also a much more reasonable value for batch throttling and dirty writeback IMO. > > Just curious if we are calling get_nr_to_scan() more frequently > before we can abort the while (true) loop if reclamation > is not making good progress. > > Assume get_nr_to_scan() also has a cost. Not sure if a > value between MIN_LRU_BATCH and MAX_LRU_BATCH > would be better. We are calling that less frequently actually, in a previous commit it was moved out of the loop to act like a budget control. That's also where using a smaller batch start to makes more sense. The overhead of other function calls also seems trivial. I also wonder if we can unify or remove some SWAP_CLUSTER_MAX usage, that value might be no longer suitable in many places.