From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) (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 A12AD3749FE for ; Wed, 12 Aug 2026 10:17:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786529837; cv=none; b=eXSfs6B92kUhAmqMC9R+oCLfW7EDmfKw7zejv1+Fn4DeZQGXp9haqOnIvOSYcQl44L2/ZGfLaxTPgT8Y+7WpT3DPBRHvVC1Asg0kIqzUiq7zuqqQHlQGGXwBRHDChKxiWH+At/GZqIRoqCyU4+Rb/b4tozcH8kCkDzPHtjL2U6E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786529837; c=relaxed/simple; bh=FHR3oZUuT66K2DDkMdIcbUIHKbHgwvHYkzDra3rggWs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=T30YKdsMvrbigB+JZsooxi15Aq1STq1Xp5STYZx415jArS1L7Y3J0A2NXTRky8XPusP2GUrLBSNS/7n5m9xTc1ujeCGfrbc5NdcU0WIqAHYmpJId+Dlga9sWJeG5j+9j1EDXVs3o6ugEuN3Pzahi2WXMNOO5VPi3uPogwWua5i0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=VbegVJvC; arc=none smtp.client-ip=115.124.30.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="VbegVJvC" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1786529830; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=4HoO1GzcddlvJMkEk1X4eHDN/y9zqCqi6gXl6/6zpk0=; b=VbegVJvCNbaq8myykKQsc4ESl4EGvP5GOqiXf0z6RicYQ4ntlxRf/ky+JqEsRehlk+YTJbfnx48sDk5IRDlTHxoWEPRSF5jvbnQMlAgkpcn5tXVnO2vHRxwSUH3V5jknCWSVoSseKVpYAVngCiwP4f3FeizHxAVFoZt6K21zAQM= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam011083073210;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0X8rG74f_1786529828; Received: from 30.74.144.118(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X8rG74f_1786529828 cluster:ay36) by smtp.aliyun-inc.com; Wed, 12 Aug 2026 18:17:09 +0800 Message-ID: Date: Wed, 12 Aug 2026 18:17:08 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm/mglru: Fix young counter undercount for large folios To: Hui Zhu , Andrew Morton , Johannes Weiner , David Hildenbrand , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hui Zhu References: <20260812065933.103627-1-hui.zhu@linux.dev> From: Baolin Wang In-Reply-To: <20260812065933.103627-1-hui.zhu@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 8/12/26 2:59 PM, Hui Zhu wrote: > From: Hui Zhu > > In lru_gen_look_around(), the young counter tracks the number of young > PTEs. The original folio's contribution is represented by the initial > value of young: test_and_clear_young_ptes_notify() is called on it at > function entry, and the function returns early if it is not young. In > the subsequent loop, the original folio is skipped (its accessed bits > were already cleared), so it is not double-counted. > > However, young is initialized to 1 regardless of the folio size. When > the original folio is a large folio with nr PTEs, its young count is > underestimated by nr - 1. This inconsistency can cause > suitable_to_scan() to return false, preventing the PMD from being added > to the bloom filter and reducing aging accuracy for mTHP workloads. > > Initialize young to nr so the original folio is accounted the same way > as other young folios in the loop (young += nr). > > Signed-off-by: Hui Zhu > --- Good catch. Please also add the Fixes tag: Fixes: 56e5b60b2114 ("mm: support batched checking of the young flag for MGLRU") With that, Reviewed-by: Baolin Wang > mm/vmscan.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index bc324e37c5f1..264017850a55 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -4192,7 +4192,7 @@ bool lru_gen_look_around(struct page_vma_mapped_walk *pvmw, unsigned int nr) > unsigned long end; > struct lru_gen_mm_walk *walk; > struct folio *last = NULL; > - int young = 1; > + int young = nr; > pte_t *pte = pvmw->pte; > unsigned long addr = pvmw->address; > struct vm_area_struct *vma = pvmw->vma;