From: Baoquan He <baoquan.he@linux.dev>
To: Ridong Chen <ridong.chen@linux.dev>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Dave Chinner <david@fromorbit.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Muchun Song <muchun.song@linux.dev>,
Qi Zheng <qi.zheng@linux.dev>, Kairui Song <kasong@tencent.com>,
Barry Song <baohua@kernel.org>,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-mm@kvack.org,
"open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)"
<cgroups@vger.kernel.org>,
"open list:BPF [MISC]:Keyword:(?:b|_)bpf(?:b|_)"
<bpf@vger.kernel.org>, Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [PATCH v5 3/6] mm/vmscan: move struct scan_control to a dedicated header
Date: Mon, 2 Nov 2026 09:38:18 +0800 [thread overview]
Message-ID: <aufpiiCkpQaHG04m@bogon> (raw)
In-Reply-To: <20261031090041.58574-4-ridong.chen@linux.dev>
On 10/31/26 at 05:00pm, Ridong Chen wrote:
> From: Ridong Chen <chenridong@xiaomi.com>
>
> The definition of struct scan_control has lived inline at the top of
> mm/vmscan.c. Move it out to a new mm/vmscan.h so the reclaim-internal
> state can be referenced from other reclaim translation units without
> duplicating the definition.
>
> The header uses an ordinary include guard and pulls in only what the
> struct needs (nodemask_t, gfp_t and struct reclaim_state).
>
> mm/trace_vmscan.h includes the new header directly so that any
> translation unit pulling in the trace events (mm/vmscan.c, mm/shrinker.c)
> sees the full definition of struct scan_control regardless of include
> order.
>
> No functional change.
>
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
> ---
> MAINTAINERS | 2 +
> mm/trace_vmscan.h | 2 +
> mm/vmscan.c | 108 ------------------------------------------
> mm/vmscan.h | 118 ++++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 122 insertions(+), 108 deletions(-)
> create mode 100644 mm/vmscan.h
Reviewed-by: Baoquan He <baoquan.he@linux.dev>
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 2ad01107fa05..724791bb779f 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -17655,6 +17655,7 @@ F: include/linux/mm_inline.h
> F: include/linux/mmzone.h
> F: mm/trace_vmscan.h
> F: mm/vmscan.c
> +F: mm/vmscan.h
> F: mm/workingset.c
>
> MEMORY MANAGEMENT - MIGRATION
> @@ -17805,6 +17806,7 @@ L: linux-mm@kvack.org
> S: Maintained
> F: mm/trace_vmscan.h
> F: mm/vmscan.c
> +F: mm/vmscan.h
> F: mm/workingset.c
>
> MEMORY MANAGEMENT - RMAP (REVERSE MAPPING)
> diff --git a/mm/trace_vmscan.h b/mm/trace_vmscan.h
> index ad90f0e9bf2e..3917e1b62dfa 100644
> --- a/mm/trace_vmscan.h
> +++ b/mm/trace_vmscan.h
> @@ -11,6 +11,8 @@
> #include <linux/memcontrol.h>
> #include <trace/events/mmflags.h>
>
> +#include "vmscan.h"
> +
> #define RECLAIM_WB_ANON 0x0001u
> #define RECLAIM_WB_FILE 0x0002u
> #define RECLAIM_WB_MIXED 0x0010u
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 79d2d614afd0..49677464fc9a 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -73,114 +73,6 @@
> #define CREATE_TRACE_POINTS
> #include "trace_vmscan.h"
>
> -struct scan_control {
> - /* How many pages shrink_list() should reclaim */
> - unsigned long nr_to_reclaim;
> -
> - /*
> - * Nodemask of nodes allowed by the caller. If NULL, all nodes
> - * are scanned.
> - */
> - const nodemask_t *nodemask;
> -
> - /*
> - * The memory cgroup that hit its limit and as a result is the
> - * primary target of this reclaim invocation.
> - */
> - struct mem_cgroup *target_mem_cgroup;
> -
> - /*
> - * Scan pressure balancing between anon and file LRUs
> - */
> - unsigned long anon_cost;
> - unsigned long file_cost;
> -
> - /* Swappiness value for proactive reclaim. Always use sc_swappiness()! */
> - int *proactive_swappiness;
> -
> - /* Can active folios be deactivated as part of reclaim? */
> -#define DEACTIVATE_ANON 1
> -#define DEACTIVATE_FILE 2
> - unsigned int may_deactivate:2;
> - unsigned int force_deactivate:1;
> - unsigned int skipped_deactivate:1;
> -
> - /* zone_reclaim_mode, boost reclaim */
> - unsigned int may_writepage:1;
> -
> - /* zone_reclaim_mode */
> - unsigned int may_unmap:1;
> -
> - /* zone_reclaim_mode, boost reclaim, cgroup restrictions */
> - unsigned int may_swap:1;
> -
> - /* Not allow cache_trim_mode to be turned on as part of reclaim? */
> - unsigned int no_cache_trim_mode:1;
> -
> - /* Has cache_trim_mode failed at least once? */
> - unsigned int cache_trim_mode_failed:1;
> -
> - /* Proactive reclaim invoked by userspace */
> - unsigned int proactive:1;
> -
> - /*
> - * Cgroup memory below memory.low is protected as long as we
> - * don't threaten to OOM. If any cgroup is reclaimed at
> - * reduced force or passed over entirely due to its memory.low
> - * setting (memcg_low_skipped), and nothing is reclaimed as a
> - * result, then go back for one more cycle that reclaims the protected
> - * memory (memcg_low_reclaim) to avert OOM.
> - */
> - unsigned int memcg_low_reclaim:1;
> - unsigned int memcg_low_skipped:1;
> -
> - /* Shared cgroup tree walk failed, rescan the whole tree */
> - unsigned int memcg_full_walk:1;
> -
> - unsigned int hibernation_mode:1;
> -
> - /* One of the zones is ready for compaction */
> - unsigned int compaction_ready:1;
> -
> - /* There is easily reclaimable cold cache in the current node */
> - unsigned int cache_trim_mode:1;
> -
> - /* The file folios on the current node are dangerously low */
> - unsigned int file_is_tiny:1;
> -
> - /* Always discard instead of demoting to lower tier memory */
> - unsigned int no_demotion:1;
> -
> - /* Allocation order */
> - s8 order;
> -
> - /* Scan (total_size >> priority) pages at once */
> - s8 priority;
> -
> - /* The highest zone to isolate folios for reclaim from */
> - s8 reclaim_idx;
> -
> - /* This context's GFP mask */
> - gfp_t gfp_mask;
> -
> - /* Incremented by the number of inactive pages that were scanned */
> - unsigned long nr_scanned;
> -
> - /* Number of pages freed so far during a call to shrink_zones() */
> - unsigned long nr_reclaimed;
> -
> - struct {
> - unsigned int dirty;
> - unsigned int congested;
> - unsigned int writeback;
> - unsigned int immediate;
> - unsigned int taken;
> - } nr;
> -
> - /* for recording the reclaimed slab by now */
> - struct reclaim_state reclaim_state;
> -};
> -
> #ifdef ARCH_HAS_PREFETCHW
> static inline void prefetchw_prev_lru_folio(struct folio *folio,
> struct list_head *base)
> diff --git a/mm/vmscan.h b/mm/vmscan.h
> new file mode 100644
> index 000000000000..adb22e80d760
> --- /dev/null
> +++ b/mm/vmscan.h
> @@ -0,0 +1,118 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _MM_VMSCAN_H
> +#define _MM_VMSCAN_H
> +
> +#include <linux/gfp_types.h>
> +#include <linux/nodemask.h>
> +#include <linux/swap.h>
> +#include <linux/types.h>
> +
> +struct scan_control {
> + /* How many pages shrink_list() should reclaim */
> + unsigned long nr_to_reclaim;
> +
> + /*
> + * Nodemask of nodes allowed by the caller. If NULL, all nodes
> + * are scanned.
> + */
> + const nodemask_t *nodemask;
> +
> + /*
> + * The memory cgroup that hit its limit and as a result is the
> + * primary target of this reclaim invocation.
> + */
> + struct mem_cgroup *target_mem_cgroup;
> +
> + /*
> + * Scan pressure balancing between anon and file LRUs
> + */
> + unsigned long anon_cost;
> + unsigned long file_cost;
> +
> + /* Swappiness value for proactive reclaim. Always use sc_swappiness()! */
> + int *proactive_swappiness;
> +
> + /* Can active folios be deactivated as part of reclaim? */
> +#define DEACTIVATE_ANON 1
> +#define DEACTIVATE_FILE 2
> + unsigned int may_deactivate:2;
> + unsigned int force_deactivate:1;
> + unsigned int skipped_deactivate:1;
> +
> + /* zone_reclaim_mode, boost reclaim */
> + unsigned int may_writepage:1;
> +
> + /* zone_reclaim_mode */
> + unsigned int may_unmap:1;
> +
> + /* zone_reclaim_mode, boost reclaim, cgroup restrictions */
> + unsigned int may_swap:1;
> +
> + /* Not allow cache_trim_mode to be turned on as part of reclaim? */
> + unsigned int no_cache_trim_mode:1;
> +
> + /* Has cache_trim_mode failed at least once? */
> + unsigned int cache_trim_mode_failed:1;
> +
> + /* Proactive reclaim invoked by userspace */
> + unsigned int proactive:1;
> +
> + /*
> + * Cgroup memory below memory.low is protected as long as we
> + * don't threaten to OOM. If any cgroup is reclaimed at
> + * reduced force or passed over entirely due to its memory.low
> + * setting (memcg_low_skipped), and nothing is reclaimed as a
> + * result, then go back for one more cycle that reclaims the protected
> + * memory (memcg_low_reclaim) to avert OOM.
> + */
> + unsigned int memcg_low_reclaim:1;
> + unsigned int memcg_low_skipped:1;
> +
> + /* Shared cgroup tree walk failed, rescan the whole tree */
> + unsigned int memcg_full_walk:1;
> +
> + unsigned int hibernation_mode:1;
> +
> + /* One of the zones is ready for compaction */
> + unsigned int compaction_ready:1;
> +
> + /* There is easily reclaimable cold cache in the current node */
> + unsigned int cache_trim_mode:1;
> +
> + /* The file folios on the current node are dangerously low */
> + unsigned int file_is_tiny:1;
> +
> + /* Always discard instead of demoting to lower tier memory */
> + unsigned int no_demotion:1;
> +
> + /* Allocation order */
> + s8 order;
> +
> + /* Scan (total_size >> priority) pages at once */
> + s8 priority;
> +
> + /* The highest zone to isolate folios for reclaim from */
> + s8 reclaim_idx;
> +
> + /* This context's GFP mask */
> + gfp_t gfp_mask;
> +
> + /* Incremented by the number of inactive pages that were scanned */
> + unsigned long nr_scanned;
> +
> + /* Number of pages freed so far during a call to shrink_zones() */
> + unsigned long nr_reclaimed;
> +
> + struct {
> + unsigned int dirty;
> + unsigned int congested;
> + unsigned int writeback;
> + unsigned int immediate;
> + unsigned int taken;
> + } nr;
> +
> + /* for recording the reclaimed slab by now */
> + struct reclaim_state reclaim_state;
> +};
> +
> +#endif /* _MM_VMSCAN_H */
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-11-02 1:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 9:00 [PATCH v5 0/6] mm/vmscan: move tracepoints to mm/ and add MGLRU tracepoints Ridong Chen
2026-10-31 9:00 ` [PATCH v5 1/6] mm/memcontrol: drop unused vmscan tracepoint include Ridong Chen
2026-11-01 3:20 ` Baoquan He
2026-10-31 9:00 ` [PATCH v5 2/6] mm/vmscan: move vmscan tracepoints to a local header Ridong Chen
2026-10-31 9:27 ` Muchun Song
2026-11-02 1:37 ` Baoquan He
2026-11-02 10:46 ` Ridong Chen
2026-10-31 9:00 ` [PATCH v5 3/6] mm/vmscan: move struct scan_control to a dedicated header Ridong Chen
2026-10-31 9:29 ` Muchun Song
2026-11-02 1:38 ` Baoquan He [this message]
2026-10-31 9:00 ` [PATCH v5 4/6] mm/vmscan: pass scan_control to the vmscan tracepoints Ridong Chen
2026-10-31 10:12 ` Muchun Song
2026-11-02 1:40 ` Baoquan He
2026-10-31 9:00 ` [PATCH v5 5/6] mm/mglru: add tracepoint for scan_folios() Ridong Chen
2026-10-31 21:02 ` Barry Song
2026-11-02 1:44 ` Baoquan He
2026-10-31 9:00 ` [PATCH v5 6/6] mm/mglru: add tracepoint for inc_max_seq() Ridong Chen
2026-10-31 21:21 ` Barry Song
2026-11-02 2:13 ` Baoquan He
2026-11-02 11:22 ` Ridong Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aufpiiCkpQaHG04m@bogon \
--to=baoquan.he@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=bpf@vger.kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@xiaomi.com \
--cc=david@fromorbit.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=qi.zheng@linux.dev \
--cc=ridong.chen@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=shakeel.butt@linux.dev \
--cc=weixugc@google.com \
--cc=yuanchu@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox