mm/vmscan: move vmscan tracepoints to a local header
Subsystems (7)
cover mm/vmscan: move vmscan tracepoints to a local header
From: Ridong Chen <[email protected]>
Background:
This series started as an effort to add two tracepoints for MGLRU. In the discussion, Steven suggested moving include/trace/events/vmscan.h to mm/trace_vmscan.h [1], as several other subsystems already do. Once the header lives under mm/, struct scan_control can be moved there too, letting the trace events access its fields directly instead of having each callsite copy the scalars out by hand.
The series builds in four small steps:
1) drop the now-unused vmscan trace include from memcontrol.c;
2) move include/trace/events/vmscan.h to mm/trace_vmscan.h, using a
relative TRACE_INCLUDE_PATH so no Makefile change is needed;
3) move struct scan_control into that header, guarded against the
multi-read that define_trace.h performs; 4) pass scan_control to the reclaim-begin tracepoints and pick the fields out in TP_fast_assign.
There is no functional change and no ABI change: TP_STRUCT__entry and TP_printk are untouched, so the exported event format is identical. This was confirmed by diffing the tracefs format files before and after, and by capturing the direct/memcg/node reclaim-begin events under load in a QEMU guest (order, gfp_flags and memcg_id all match).
This RFC only converts the three reclaim-begin tracepoints (direct/memcg/node) to take a scan_control pointer as a first, self-contained step. Other vmscan tracepoints that currently spell out individual sc->... fields can be converted the same way once the approach is agreed upon;
[1] https://lore.kernel.org/linux-mm/20260916095122.50cbb620@robin/
Ridong Chen (4):
mm/memcontrol: drop unused vmscan tracepoint include mm/vmscan: move vmscan tracepoints to a local header mm/vmscan: move struct scan_control to the local trace header mm/vmscan: pass scan_control to the reclaim-begin tracepoints
MAINTAINERS | 2 + mm/memcontrol.c | 2 - mm/shrinker.c | 2 +- .../events/vmscan.h => mm/trace_vmscan.h | 143 ++++++++++++++++-- mm/vmscan.c | 117 +------------- 5 files changed, 138 insertions(+), 128 deletions(-) rename include/trace/events/vmscan.h => mm/trace_vmscan.h (81%)
Signature · 1 line
2.34.1
RFC PATCH 1/4 mm/memcontrol: drop unused vmscan tracepoint include
From: Ridong Chen <[email protected]>
memcontrol.c includes <trace/events/vmscan.h> but does not use any of the tracepoints or macros it defines: all tracepoints invoked here come from memcg.h and writeback.h. Removing the include still compiles cleanly.
--- mm/memcontrol.c | 2 -- 1 file changed, 2 deletions(-)
mm/memcontrol.c +0 -2
@@ -77,8 +77,6 @@#include <trace/events/memcg.h> #undef CREATE_TRACE_POINTS -#include <trace/events/vmscan.h> -struct cgroup_subsys memory_cgrp_subsys__read_mostly ;EXPORT_SYMBOL (memory_cgrp_subsys);
Signature · 1 line
2.34.1
RFC PATCH 2/4 mm/vmscan: move vmscan tracepoints to a local header
In reply to Ridong ChenFrom: Ridong Chen <[email protected]>
Move include/trace/events/vmscan.h to mm/trace_vmscan.h so that the tracepoints can be extended to reference vmscan-internal structures such as struct scan_control, which is not visible outside mm/. This mirrors what several other subsystems already do with their trace headers (e.g. fs/ext2, kernel/trace/trace_benchmark).
No functional change.
--- MAINTAINERS | 2 ++ mm/shrinker.c | 2 +- include/trace/events/vmscan.h => mm/trace_vmscan.h | 4 ++++ mm/vmscan.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) rename include/trace/events/vmscan.h => mm/trace_vmscan.h (99%)
MAINTAINERS +2 -0
@@ -17227,6 +17227,7 @@ F: Documentation/admin-guide/mm/multigen_lru.rst F: Documentation/mm/multigen_lru.rst F: include/linux/mm_inline.h F: include/linux/mmzone.h +F: mm/trace_vmscan.h F: mm/vmscan.c F: mm/workingset.c
@@ -17374,6 +17375,7 @@ R: Shakeel Butt <[email protected]> R: Lorenzo Stoakes <[email protected]> L: [email protected] S: Maintained +F: mm/trace_vmscan.h F: mm/vmscan.c F: mm/workingset.c
mm/shrinker.c +1 -1
@@ -3,7 +3,7 @@#include <linux/rwsem.h> #include <linux/shrinker.h> #include <linux/rculist.h> -#include <trace/events/vmscan.h> +#include "trace_vmscan.h" #include "internal.h"
mm/trace_vmscan.h renamed from include/trace/events/vmscan.h +4 -0
@@ -648,4 +648,8 @@ TRACE_EVENT(mm_vmscan_kswapd_clear_hopeless,#endif /* _TRACE_VMSCAN_H */ /* This part must be outside protection */ +#undef TRACE_INCLUDE_FILE +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH ../../mm +#define TRACE_INCLUDE_FILE trace_vmscan#include <trace/define_trace.h>
mm/vmscan.c +1 -1
@@ -71,7 +71,7 @@#include "swap.h" #define CREATE_TRACE_POINTS -#include <trace/events/vmscan.h> +#include "trace_vmscan.h" struct scan_control {/* How many pages shrink_list() should reclaim */
Signature · 1 line
2.34.1
RFC PATCH 3/4 mm/vmscan: move struct scan_control to the local trace header
In reply to Ridong ChenFrom: Ridong Chen <[email protected]>
Now that the vmscan tracepoints live in mm/trace_vmscan.h, move struct scan_control there as well so the trace events can reference reclaim-internal state directly. The definition is wrapped in its own include guard because the trace header is re-read under TRACE_HEADER_MULTI_READ, while a C struct may only be defined once.
No functional change.
--- mm/trace_vmscan.h | 115 ++++++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 108 ------------------------------------------- 2 files changed, 115 insertions(+), 108 deletions(-)
mm/trace_vmscan.h +115 -0
@@ -9,8 +9,123 @@#include <linux/tracepoint.h> #include <linux/mm.h> #include <linux/memcontrol.h> +#include <linux/swap.h> #include <trace/events/mmflags.h> +/* Guard the struct against define_trace.h's repeated inclusion. */ +#ifndef _MM_VMSCAN_INTERNAL_H +#define _MM_VMSCAN_INTERNAL_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_INTERNAL_H */ +#define RECLAIM_WB_ANON 0x0001u#define RECLAIM_WB_FILE 0x0002u#define RECLAIM_WB_MIXED 0x0010u
mm/vmscan.c +0 -108
114 lines not on this page · raw message
Signature · 1 line
2.34.1
Baoquan He
reviewerRe: [PATCH RFC 3/4] mm/vmscan: move struct scan_control to the local trace header
mm/trace_vmscan.h
Quoted 21 lines · Ridong Chen
From: Ridong Chen <[email protected]>
Now that the vmscan tracepoints live in
mm/trace_vmscan.h, move structscan_controlthere as well so the trace events can reference reclaim-internal state directly. The definition is wrapped in its own include guard because the trace header is re-read underTRACE_HEADER_MULTI_READ, while a C struct may only be defined once.No functional change.
Assisted-by Claude:claude-opus-4-8Signed-off-by Ridong Chen <[email protected]>--- mm/trace_vmscan.h | 115 ++++++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 108 ------------------------------------------- 2 files changed, 115 insertions(+), 108 deletions(-)mm/trace_vmscan.h +0
-0
This looks not good, I would rather see it's added in mm/internal.h, or a new mm/vmscan.h. Putting scan_control in mm/trace_vmscan.h is too weird.
Quoted 246 lines
mm/trace_vmscan.h +115
-0@@ -9,8 +9,123 @@#include <linux/tracepoint.h> #include <linux/mm.h> #include <linux/memcontrol.h> +#include <linux/swap.h> #include <trace/events/mmflags.h> +/* Guard the struct against define_trace.h's repeated inclusion. */ +#ifndef _MM_VMSCAN_INTERNAL_H +#define _MM_VMSCAN_INTERNAL_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_INTERNAL_H */ +#define RECLAIM_WB_ANON 0x0001u#define RECLAIM_WB_FILE 0x0002u#define RECLAIM_WB_MIXED 0x0010umm/vmscan.c +0
-108@@ -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)Signature · 1 line
2.34.1
Re: [PATCH RFC 3/4] mm/vmscan: move struct scan_control to the local trace header
Quoted 18 lines · Baoquan He
Quoted 17 lines · Ridong Chen
From: Ridong Chen <[email protected]>
Now that the vmscan tracepoints live in
mm/trace_vmscan.h, move structscan_controlthere as well so the trace events can reference reclaim-internal state directly. The definition is wrapped in its own include guard because the trace header is re-read underTRACE_HEADER_MULTI_READ, while a C struct may only be defined once.No functional change.
Assisted-by Claude:claude-opus-4-8Signed-off-by Ridong Chen <[email protected]>--- mm/trace_vmscan.h | 115 ++++++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 108 ------------------------------------------- 2 files changed, 115 insertions(+), 108 deletions(-)
Quoted 8 lines
mm/trace_vmscan.h
Quoted 4 lines
mm/trace_vmscan.h +0
-0This looks not good, I would rather see it's added in
mm/internal.h, or a newmm/vmscan.h. Puttingscan_controlinmm/trace_vmscan.his too weird.
Thanks.
I'm not sure whether the maintainers would be happy to make scan_control external. I'd prefer to move scan_control to a new mm/vmscan.h, since mm/internal.h is getting larger and larger. So I'd like to hear other opinions.
Quoted 246 lines
Quoted 246 lines
mm/trace_vmscan.h +115
-0@@ -9,8 +9,123 @@#include <linux/tracepoint.h> #include <linux/mm.h> #include <linux/memcontrol.h> +#include <linux/swap.h> #include <trace/events/mmflags.h> +/* Guard the struct against define_trace.h's repeated inclusion. */ +#ifndef _MM_VMSCAN_INTERNAL_H +#define _MM_VMSCAN_INTERNAL_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_INTERNAL_H */ +#define RECLAIM_WB_ANON 0x0001u#define RECLAIM_WB_FILE 0x0002u#define RECLAIM_WB_MIXED 0x0010umm/vmscan.c +0
-108@@ -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)Signature · 1 line
2.34.1
Signature · 2 lines
Best regards Ridong
RFC PATCH 4/4 mm/vmscan: pass scan_control to the reclaim-begin tracepoints
In reply to Ridong ChenFrom: Ridong Chen <[email protected]>
The reclaim-begin tracepoints describe the entry conditions of a reclaim invocation, which struct scan_control already carries. Now that the struct is visible from the trace header, pass sc directly and pick the fields out in TP_fast_assign instead of spelling out gfp_mask and order at every callsite. The exported event format is unchanged.
No functional change.
--- mm/trace_vmscan.h | 24 ++++++++++++------------ mm/vmscan.c | 7 +++---- 2 files changed, 15 insertions(+), 16 deletions(-)
mm/trace_vmscan.h +12 -12
@@ -291,9 +291,9 @@ TRACE_EVENT(mm_vmscan_wakeup_kswapd, DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template, - TP_PROTO(gfp_t gfp_flags, int order, struct mem_cgroup *memcg), + TP_PROTO(struct scan_control *sc, struct mem_cgroup *memcg), - TP_ARGS(gfp_flags, order, memcg), + TP_ARGS(sc, memcg), TP_STRUCT__entry( __field( unsigned long, gfp_flags )
@@ -302,8 +302,8 @@ DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template, ),TP_fast_assign ( - __entry->gfp_flags = (__force unsigned long)gfp_flags; - __entry->order = order; + __entry->gfp_flags = (__force unsigned long)sc->gfp_mask; + __entry->order = sc->order; __entry->memcg_id =mem_cgroup_id (memcg); ),
@@ -317,17 +317,17 @@ DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,DEFINE_EVENT (mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin, - TP_PROTO(gfp_t gfp_flags, int order, struct mem_cgroup *memcg), + TP_PROTO(struct scan_control *sc, struct mem_cgroup *memcg), -TP_ARGS (gfp_flags, order, memcg) +TP_ARGS (sc, memcg) );#ifdef CONFIG_MEMCG DEFINE_EVENT (mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin, - TP_PROTO(gfp_t gfp_flags, int order, struct mem_cgroup *memcg), + TP_PROTO(struct scan_control *sc, struct mem_cgroup *memcg), -TP_ARGS (gfp_flags, order, memcg) +TP_ARGS (sc, memcg) );#endif /* CONFIG_MEMCG */
@@ -664,9 +664,9 @@ TRACE_EVENT(mm_vmscan_lru_shrink_active, TRACE_EVENT(mm_vmscan_node_reclaim_begin, - TP_PROTO(int nid, int order, gfp_t gfp_flags), + TP_PROTO(int nid, struct scan_control *sc), - TP_ARGS(nid, order, gfp_flags), + TP_ARGS(nid, sc), TP_STRUCT__entry( __field(int, nid)
@@ -676,8 +676,8 @@ TRACE_EVENT(mm_vmscan_node_reclaim_begin,TP_fast_assign ( __entry->nid = nid; - __entry->order = order; - __entry->gfp_flags = (__force unsigned long )gfp_flags; + __entry->order = sc->order; + __entry->gfp_flags = (__force unsigned long )sc->gfp_mask; ), TP_printk("nid=%d order=%d gfp_flags=%s",
mm/vmscan.c +3 -4
@@ -6885,7 +6885,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,return 1 ;set_task_reclaim_state (current, &sc.reclaim_state); -trace_mm_vmscan_direct_reclaim_begin (sc.gfp_mask, order,NULL ); +trace_mm_vmscan_direct_reclaim_begin (&sc,NULL ); nr_reclaimed =do_try_to_free_pages (zonelist, &sc);
@@ -6926,7 +6926,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg,struct zonelist *zonelist =node_zonelist (numa_node_id (), sc.gfp_mask);set_task_reclaim_state (current, &sc.reclaim_state); -trace_mm_vmscan_memcg_reclaim_begin (sc.gfp_mask,0 , memcg); +trace_mm_vmscan_memcg_reclaim_begin (&sc, memcg); noreclaim_flag =memalloc_noreclaim_save (); nr_reclaimed =do_try_to_free_pages (zonelist, &sc);
@@ -7882,8 +7882,7 @@ static unsigned long __node_reclaim(struct pglist_data *pgdat,unsigned int noreclaim_flag;unsigned long pflags; -trace_mm_vmscan_node_reclaim_begin (pgdat->node_id, sc->order, - sc->gfp_mask); +trace_mm_vmscan_node_reclaim_begin (pgdat->node_id, sc);cond_resched ();psi_memstall_enter (&pflags);
Signature · 1 line
2.34.1