From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91E27606A322 for ; Thu, 3 Dec 2026 09:08:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=AIGIH9Xb Received: by kanga.kvack.org (Postfix) id 62A8B6B00EF; Thu, 3 Dec 2026 04:08:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DB706B05B1; Thu, 3 Dec 2026 04:08:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F1B66B05B2; Thu, 3 Dec 2026 04:08:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C79256B00EF for ; Thu, 3 Dec 2026 04:08:39 -0500 (EST) Received: from smtpin20.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5B82CA0629 for ; Thu, 3 Dec 2026 09:08:39 +0000 (UTC) X-FDA: 85502096358.20.E86DAA2 Received: from mta1.migadu.com (out-72.mta1.migadu.com [95.215.58.72]) by imf05.hostedemail.com (Postfix) with ESMTP id EDC78100007 for ; Thu, 3 Dec 2026 09:08:36 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=AIGIH9Xb; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf05.hostedemail.com: domain of qi.zheng@linux.dev designates 95.215.58.72 as permitted sender) smtp.mailfrom=qi.zheng@linux.dev ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796288917; b=yEdOf2j9TFVtK93a2rMsW/ZFGx7B3Eu0+tAn8nC05h/uE7FpujWEi901hWNvrfSKMAnmm4 CMGHRhUhdm8QaG0cWI9XxURG6Mq0SzHAOxjhCR/4EQL7aestUlwrDxrEJohPyAqZS2r7iV anG55BikCxy/WjbOLrwFcvLfi6N5+vQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796288917; 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=jwy/whYNWVJfPKPeloPxRivGnt4MqE60jA0E7ErQdFs=; b=xz6v1o7qqE20tqxetvA7QwiLGbLEii4pRaYjilZVZG9c/mPRQbAGRti0XIz/eOeJhnPLvK UYxhSCVp4v5VsQHb+MUp8WFBoiuOs1g2JFxFikKGLrZGknihiMp0vjmmQFkFPtDI+5bstC VlNBKAdnt23DgOeTXyf7ZMnXWMDNlfk= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=AIGIH9Xb; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf05.hostedemail.com: domain of qi.zheng@linux.dev designates 95.215.58.72 as permitted sender) smtp.mailfrom=qi.zheng@linux.dev X-Envelope-To: linux-mm@kvack.org DKIM-Signature: a=rsa-sha256; bh=mHxMLy+mhblxlrAXfhL4M0yziNebmN55c4aAJXEVMuw=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796288915; v=1; x=1796893715; b=AIGIH9Xb6JSSp4cplNU5vCkWClHlG5+w/sYq7kv7JsomZnbhwzQ3egqN84BfpA84Zydfpr60 G+wcSuY1xa4b7VOKv+JuMRrmYJZ2w3O63gh/9ieKwbLxaSSfiumiZyWSt1Yk5kaN11EzstjHPA2 UyRFsDC41uvGHLE6Jzi9oF9s= X-Envelope-To: linux-mm@kvack.org Received: by smtp.migadu.com with ESMTPS id 7a7830ed6a1789eb; Thu, 03 Dec 2026 09:08:34 +0000 X-Mizu-Trace-ID: 7a7830ed6a1789eb X-Migadu-Flow: FLOW_OUT Message-ID: <61b3e09b-4b60-4654-b612-c8cf24b2574d@linux.dev> Date: Thu, 3 Dec 2026 17:08:26 +0800 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] mm/mglru: fix the outdated can_swap field of the aging command To: Barry Song Cc: akpm@linux-foundation.org, axelrasmussen@google.com, baolin.wang@linux.alibaba.com, baoquan.he@linux.dev, corbet@lwn.net, david@kernel.org, hanchuanhua802@gmail.com, hanchuanhua@xiaomi.com, kasong@tencent.com, liam@infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com, rdunlap@infradead.org, rppt@kernel.org, shakeel.butt@linux.dev, skhan@linuxfoundation.org, vbabka@kernel.org, weixugc@google.com, yuanchu@google.com References: <20261203084013.13396-1-baohua@kernel.org> From: Qi Zheng In-Reply-To: <20261203084013.13396-1-baohua@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: EDC78100007 X-Rspam-User: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Rspamd-Server: rspam03 X-Stat-Signature: 6a4rt8nap4cdm5zzksc3fjeh3xb155xh X-HE-Tag: 1796288916-893836 X-HE-Meta: U2FsdGVkX1/hF4B4VzXAygQK0msbMpeAxNt2xvTN+Nu3v/9Icm6OPXXb+/TzOojOV8WYYdor89zLn4rKjwSHVsPZia3etYkdfZOZlIOEsC02Ku7514aEanFNFeOgiWCNJeS+ghx0swmFkNmA+im1yonCKAIZJpb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j+ebP6b+JWwlhIlOg/je4+wZbxyY1iTNhSHXSVMgeocqM1+uyXTaPK+2OnDoCziSZr4s+JpznFoj8b/ca0RmThS6hFKQQ82drme1m9ML1fiCurVmuMsvDdLXJgOewgZa3JMcXyZg2rlQE7QO7G4SRS6uXuD9ZsmcmdZQW6M6IagzIiXE+dMiyT/mjdMrvC7BpvkqNWog/dwnt4xswZoBw5vD3yz819tmwYvINPxUFtsdnOQHrjWTOLzTp7ylnVxNsMsiT5eZQo4Biu93gKG/XYQ/JUG4/j0XnteDdR4yt4igiXG9L2fZ5pDbP+qJTNKJMI4kRhu7OuvaVtJCj8WGUEYV2jX3X9wUtGLUyPefmond3QPdvIrQqCZTc Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi Barry, On 12/3/26 4:40 PM, Barry Song wrote: > On Thu, Dec 3, 2026 at 2:43 PM Qi Zheng wrote: >> >> Hi Chuanhua, >> >> On 12/3/26 12:00 PM, Chuanhua Han wrote: >>> From: Chuanhua Han >>> >>> The fourth field of the aging command in /sys/kernel/debug/lru_gen is >>> documented as can_swap, but lru_gen_seq_write() parses it as a >>> swappiness value, the same as for the eviction command. >>> Commit b40599930f00 ("mm: add max swappiness arg to lru_gen for >>> anonymous memory only") added "max" to this field, but documented it >>> only for eviction. >>> >>> For aging, the value decides which VMAs the page table walk scans: 0 >>> skips anon and shmem VMAs, "max" skips file VMAs other than shmem, and >>> any value in [1, 200] scans both. Document the field as swappiness. >>> >>> Signed-off-by: Chuanhua Han >>> --- >>> v1 -> v2: >>>   - Reword the subject to make it clear this is a doc fix (Barry) >>>   - Say "VMAs" instead of "pages" and mention shmem VMAs (Barry) >>>   - Fix the From/Signed-off-by mismatch (Barry) >>>   - Drop the test notes (Barry) >>> v1: https://lore.kernel.org/linux-mm/20261202121419.4026587-1-hanchuanhua@xiaomi.com/ >>> >>>   Documentation/admin-guide/mm/multigen_lru.rst | 9 ++++++--- >>>   1 file changed, 6 insertions(+), 3 deletions(-) >>> >>> diff --git a/Documentation/admin-guide/mm/multigen_lru.rst b/Documentation/admin-guide/mm/multigen_lru.rst >>> index 9cb54b4ff5d9..7c2c6af61fe0 100644 >>> --- a/Documentation/admin-guide/mm/multigen_lru.rst >>> +++ b/Documentation/admin-guide/mm/multigen_lru.rst >>> @@ -122,10 +122,13 @@ the former is the largest and that of the latter is the smallest. >>>   Users can write the following command to ``lru_gen`` to create a new >>>   generation ``max_gen_nr+1``: >>> >>> -    ``+ memcg_id node_id max_gen_nr [can_swap [force_scan]]`` >>> +    ``+ memcg_id node_id max_gen_nr [swappiness [force_scan]]`` >>> >>> -``can_swap`` defaults to the swap setting and, if it is set to ``1``, >>> -it forces the scan of anon pages when swap is off, and vice versa. >>> +``swappiness`` overrides the default value in ``/proc/sys/vm/swappiness`` >> >> Or could this also be `memcg->swappiness` under cgroup v1? > > Good catch. Currently, the documentation only mentions > /proc/sys/vm/swappiness for both the eviction and aging paths. > However, we actually override either vm_swappiness or > memcg->swappiness in cgroup v1. > > static int run_cmd(char cmd, u64 memcg_id, int nid, unsigned long seq, >                    struct scan_control *sc, int swappiness, unsigned long opt) > { >         ... >         if (swappiness < MIN_SWAPPINESS) >                 swappiness = get_swappiness(lruvec, sc); >         else if (swappiness > SWAPPINESS_ANON_ONLY) >                 goto done; >         .. >         return err; > } > > I guess we can put some words for both "Proactive reclaim" and "aging" path > with the below incremental changes? LGTM! > > From 36deb839afb2c1a3421a54889c1e43bdea438016 Mon Sep 17 00:00:00 2001 > From: Barry Song > Date: Thu, 3 Dec 2026 16:33:50 +0800 > Subject: [PATCH] > Fix-mm-mglru-fix-the-outdated-can_swap-field-of-the-aging-command.patch > > Also mention that the swappiness override can override the memcg's > swappiness in cgroup v1. > > Suggested-by: Qi Zheng > Signed-off-by: Barry Song > --- > Documentation/admin-guide/mm/multigen_lru.rst | 18 ++++++++++-------- > 1 file changed, 10 insertions(+), 8 deletions(-) > > diff --git a/Documentation/admin-guide/mm/multigen_lru.rst b/Documentation/admin-guide/mm/multigen_lru.rst > index e59621fb052f..cfb208430411 100644 > --- a/Documentation/admin-guide/mm/multigen_lru.rst > +++ b/Documentation/admin-guide/mm/multigen_lru.rst > @@ -125,10 +125,11 @@ generation ``max_gen_nr+1``: > ``+ memcg_id node_id max_gen_nr [swappiness [force_scan]]`` > > ``swappiness`` overrides the default value in ``/proc/sys/vm/swappiness`` > -and the valid range is [0-200, max]. If it is set to ``0``, the page > -table walk skips anon and shmem VMAs; if it is set to ``max``, it skips > -file VMAs other than shmem; otherwise, it scans both. For any nonzero > -value, anon and shmem VMAs are scanned even when swap is off. > +or ``memory.swappiness`` in cgroup v1. The valid range is [0-200, max]. > +If it is set to ``0``, the page table walk skips anon and shmem VMAs; > +if it is set to ``max``, it skips file VMAs other than shmem; otherwise, > +it scans both. For any nonzero value, anon and shmem VMAs are scanned > +even when swap is off. > ``force_scan`` defaults to ``1`` and, if it is set to ``0``, it > employs heuristics to reduce the overhead, which is likely to reduce > the coverage as well. > @@ -153,10 +154,11 @@ generations less than or equal to ``min_gen_nr``. > > ``min_gen_nr`` should be less than ``max_gen_nr-1``, since > ``max_gen_nr`` and ``max_gen_nr-1`` are not fully aged and therefore > -cannot be evicted. ``swappiness`` > -overrides the default value in ``/proc/sys/vm/swappiness`` and the valid > -range is [0-200, max], with max being exclusively used for the reclamation > -of anonymous memory. ``nr_to_reclaim`` limits the number of pages to evict. > +cannot be evicted. ``swappiness`` overrides the default value in > +``/proc/sys/vm/swappiness`` or ``memory.swappiness`` in cgroup v1. > +The valid range is [0-200, max], with ``max`` being used exclusively > +for the reclamation of anonymous memory. ``nr_to_reclaim`` limits > +the number of pages to evict. > > A typical use case is that a job scheduler runs this command before it > tries to land a new job on a server. If it fails to materialize enough > > > >> +and the valid range is [0-200, max]. If it is set to > ``0``, the page > >> +table walk skips anon and shmem VMAs; if it is set to > ``max``, it skips > >> +file VMAs other than shmem; otherwise, it scans both. > For any nonzero > >> +value, anon and shmem VMAs are scanned even when swap > is off. > > > > It reads a bit odd at first glance. > > > > Maybe add a note on why we still need to scan here — e.> g. to update the > > stats? Demotion could also be a case? > > The context is already clear that we're talking about > aging: > "Users can write the following command to ``lru_gen`` to > create a new > generation ``max_gen_nr+1``." > So it should already be clear that the scan is for aging, right? Fair enough. It just seemed odd to me that we still scan anon pages in the swap-off case. That seems fine as is — the aging section covers the details of what actually happens. Thanks, Qi