From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B1514398F88 for ; Thu, 4 Dec 2025 11:55:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764849304; cv=none; b=Iqed+2jhqUBDyLkyH54WZlM6DtYDqw2D5Vj053mjculYAC0J74V01XAcVfTXLNLUoKVSV3cdJP/Bp6E8DjAFp4YFHrE5sCgQamOZFRB6qeryUyfFPIjgvX2ZuHKPa9caVeOkHlHswKY1FRPxq6PBeW/GuxmpnrKYx7N6UmmndWQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764849304; c=relaxed/simple; bh=v4OR7s2iAfpeKTApYIZ900a9qVzXp95UxXLFYkoRXs8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nuxobv1o2cyXGJV4IKx6pcffRh/prVz0ylnZpg73VlpDKCh6r3TEvAZRiHxwvsQaTFydCgZZrAykdj9OYy1XxMxWlMJbRE/04gZrSaapdRabA6kROtHR4k/WCgnYBcvwLbX3jfKTAyHVi1j49zxIu3MGDNb64ZQ4V027j+yr2+c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qSVT9OMS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qSVT9OMS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09FBEC4CEFB; Thu, 4 Dec 2025 11:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764849304; bh=v4OR7s2iAfpeKTApYIZ900a9qVzXp95UxXLFYkoRXs8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=qSVT9OMSfs7yyCsQPOsdN90XnNTtafjfUD/dmcMfCTu8c2/lzqD1FogceFgxXWzqr r203f3zuJK0foURONQHzxJY2jfHSaa5AoJChRe4r19+AoA9EnTfj6foTvHD81rZuYr +9WQJigb/TTGAv/7xHl4ji1cf24S+iuagvkePOMK308/MkKZZkTDd4wyyflPIau25X dYu0+XoM3toWaO6ttRBEFhHbAzSYaGblktewxJFBPQPKnwG/h9uUM5IOZm/d78tiKQ bk35ayeXFgwv0FBkufVLisWx3GU2X8p4Dr34J/GS+L/Fmlm5g5c4stAETD6d0Mn/kA LwCmKQbUjpj2A== Message-ID: <173a99ed-483e-44b4-9784-598464323a39@kernel.org> Date: Thu, 4 Dec 2025 12:54:56 +0100 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 -next] mm: vmscan: correct nr_requested tracing in scan_folios To: Chen Ridong , akpm@linux-foundation.org, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, hannes@cmpxchg.org, mhocko@kernel.org, zhengqi.arch@bytedance.com, shakeel.butt@linux.dev, lorenzo.stoakes@oracle.com, yuzhao@google.com, jaewon31.kim@samsung.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, lujialin4@huawei.com, chenridong@huawei.com References: <20251203094002.1745458-1-chenridong@huaweicloud.com> <98cbf348-ff21-4c90-af32-b8009c34e5fd@kernel.org> <75ce1699-2c5a-4aab-acee-cca5c6a1e37c@huaweicloud.com> From: "David Hildenbrand (Red Hat)" Content-Language: en-US In-Reply-To: <75ce1699-2c5a-4aab-acee-cca5c6a1e37c@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/4/25 01:46, Chen Ridong wrote: > > > On 2025/12/3 19:33, David Hildenbrand (Red Hat) wrote: >> On 12/3/25 10:40, Chen Ridong wrote: >>> From: Chen Ridong >>> >>> When enabling vmscan tracing, it is observed that nr_requested is always >>> 4096, which is confusing. >>> >>>          mm_vmscan_lru_isolate: classzone=3 order=0 nr_requested=4096 ... >>>          mm_vmscan_lru_isolate: classzone=3 order=0 nr_requested=4096 ... >>>          mm_vmscan_lru_isolate: classzone=3 order=0 nr_requested=4096 ... >>>          mm_vmscan_lru_isolate: classzone=3 order=0 nr_requested=4096 ... >>>          mm_vmscan_lru_isolate: classzone=3 order=0 nr_requested=4096 ... >>>          mm_vmscan_lru_isolate: classzone=3 order=0 nr_requested=4096 ... >>>          mm_vmscan_lru_isolate: classzone=3 order=0 nr_requested=4096 ... >>> >>> This is because it prints MAX_LRU_BATCH, which is meaningless as it's a >>> constant. To fix this, modify it to print nr_to_scan as isolate_lru_folios >>> does. >>> >>> Fixes: 8c2214fc9a47 ("mm: multi-gen LRU: reuse some legacy trace events") >>> Signed-off-by: Chen Ridong >>> --- >>>   mm/vmscan.c | 2 +- >>>   1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/mm/vmscan.c b/mm/vmscan.c >>> index fddd168a9737..8cfafd50a7a8 100644 >>> --- a/mm/vmscan.c >>> +++ b/mm/vmscan.c >>> @@ -4601,7 +4601,7 @@ static int scan_folios(unsigned long nr_to_scan, struct lruvec *lruvec, >>>       count_memcg_events(memcg, item, isolated); >>>       count_memcg_events(memcg, PGREFILL, sorted); >>>       __count_vm_events(PGSCAN_ANON + type, isolated); >>> -    trace_mm_vmscan_lru_isolate(sc->reclaim_idx, sc->order, MAX_LRU_BATCH, >>> +    trace_mm_vmscan_lru_isolate(sc->reclaim_idx, sc->order, nr_to_scan, >>>                   scanned, skipped, isolated, >> >> We do that in isolate_lru_folios(). >> >> Given that we do >> >>     int remaining = min(nr_to_scan, MAX_LRU_BATCH); >> >> and effectively cap it, I wonder if we would want to trace that capped valued instead of MAX_LRU_BATCH. >> > > I prefer tracing nr_to_scan, as it reflects the original target number of pages we intended to scan. But it's misleading, because we're also tracing "scanned, skipped, isolated", and one might wonder how it relates to nr_to_scan? > Even if nr_to_scan exceeds MAX_LRU_BATCH, we can still deduce that it was effectively capped by > examining the actual scanned, skipped, or isolated counts. However, if we trace min(nr_to_scan, > MAX_LRU_BATCH) instead, we would lose visibility into what the original nr_to_scan value was. Is that really required for the purpose we are tracing here? -- Cheers David