* [PATCH v5 2/9] mm/page_owner: add MR_NEVER to enum migrate_reason and use it for last_migrate_reason [not found] <20260701061101.344679-1-ye.liu@linux.dev> @ 2026-07-01 6:10 ` Ye Liu 2026-07-01 6:10 ` [PATCH v5 3/9] mm: use enum migrate_reason instead of int for migration reason parameters Ye Liu 1 sibling, 0 replies; 3+ messages in thread From: Ye Liu @ 2026-07-01 6:10 UTC (permalink / raw) To: Andrew Morton, David Hildenbrand, Steven Rostedt, Masami Hiramatsu, Vlastimil Babka, Jan Kiszka, Kieran Bingham Cc: Ye Liu, Zi Yan, Matthew Brost, Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang, Alistair Popple, Mathieu Desnoyers, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Johannes Weiner, linux-mm, linux-kernel, linux-trace-kernel The last_migrate_reason field uses -1 as a sentinel value to mean "no migration has happened". Replace the four bare -1 occurrences by adding a proper MR_NEVER member to enum migrate_reason, defining a corresponding "never_migrated" string in the MIGRATE_REASON trace macro, and updating the GDB page_owner script to use MR_NEVER instead of the hardcoded -1 so that lx-dump-page-owner does not incorrectly report unmigrated pages as migrated. No functional change. Signed-off-by: Ye Liu <ye.liu@linux.dev> Reviewed-by: Zi Yan <ziy@nvidia.com> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> --- include/linux/migrate_mode.h | 1 + include/trace/events/migrate.h | 3 ++- mm/page_owner.c | 8 ++++---- scripts/gdb/linux/page_owner.py | 4 +++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/linux/migrate_mode.h b/include/linux/migrate_mode.h index 265c4328b36a..05102d4d2490 100644 --- a/include/linux/migrate_mode.h +++ b/include/linux/migrate_mode.h @@ -25,6 +25,7 @@ enum migrate_reason { MR_LONGTERM_PIN, MR_DEMOTION, MR_DAMON, + MR_NEVER, /* page has never been migrated */ MR_TYPES }; diff --git a/include/trace/events/migrate.h b/include/trace/events/migrate.h index cd01dd7b3640..11bc0aa14c7e 100644 --- a/include/trace/events/migrate.h +++ b/include/trace/events/migrate.h @@ -23,7 +23,8 @@ EM( MR_CONTIG_RANGE, "contig_range") \ EM( MR_LONGTERM_PIN, "longterm_pin") \ EM( MR_DEMOTION, "demotion") \ - EMe(MR_DAMON, "damon") + EM( MR_DAMON, "damon") \ + EMe(MR_NEVER, "never_migrated") /* * First define the enums in the above macros to be exported to userspace diff --git a/mm/page_owner.c b/mm/page_owner.c index 342549891a8d..c2f43ab860eb 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -339,7 +339,7 @@ noinline void __set_page_owner(struct page *page, unsigned short order, depot_stack_handle_t handle; handle = save_stack(gfp_mask); - __update_page_owner_handle(page, handle, order, gfp_mask, -1, + __update_page_owner_handle(page, handle, order, gfp_mask, MR_NEVER, ts_nsec, current->pid, current->tgid, current->comm); inc_stack_record_count(handle, gfp_mask, 1 << order); @@ -596,7 +596,7 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, if (ret >= count) goto err; - if (page_owner->last_migrate_reason != -1) { + if (page_owner->last_migrate_reason != MR_NEVER) { ret += scnprintf(kbuf + ret, count - ret, "Page has been migrated, last migrate reason: %s\n", migrate_reason_names[page_owner->last_migrate_reason]); @@ -667,7 +667,7 @@ void __dump_page_owner(const struct page *page) stack_depot_print(handle); } - if (page_owner->last_migrate_reason != -1) + if (page_owner->last_migrate_reason != MR_NEVER) pr_alert("page has been migrated, last migrate reason: %s\n", migrate_reason_names[page_owner->last_migrate_reason]); page_ext_put(page_ext); @@ -826,7 +826,7 @@ static void init_pages_in_zone(struct zone *zone) /* Found early allocated page */ __update_page_owner_handle(page, early_handle, 0, 0, - -1, local_clock(), current->pid, + MR_NEVER, local_clock(), current->pid, current->tgid, current->comm); count++; ext_put_continue: diff --git a/scripts/gdb/linux/page_owner.py b/scripts/gdb/linux/page_owner.py index 8e713a09cfe7..eeabaeed438b 100644 --- a/scripts/gdb/linux/page_owner.py +++ b/scripts/gdb/linux/page_owner.py @@ -34,6 +34,7 @@ class DumpPageOwner(gdb.Command): max_pfn = None p_ops = None migrate_reason_names = None + mr_never = None def __init__(self): super(DumpPageOwner, self).__init__("lx-dump-page-owner", gdb.COMMAND_SUPPORT) @@ -65,6 +66,7 @@ class DumpPageOwner(gdb.Command): self.max_pfn = int(gdb.parse_and_eval("max_pfn")) self.page_ext_size = int(gdb.parse_and_eval("page_ext_size")) self.migrate_reason_names = gdb.parse_and_eval('migrate_reason_names') + self.mr_never = int(gdb.parse_and_eval('MR_NEVER')) def page_ext_invalid(self, page_ext): if page_ext == gdb.Value(0): @@ -138,7 +140,7 @@ class DumpPageOwner(gdb.Command): else: gdb.write('page last free stack trace:\n') stackdepot.stack_depot_print(page_owner["free_handle"]) - if page_owner['last_migrate_reason'] != -1: + if page_owner['last_migrate_reason'] != self.mr_never: gdb.write('page has been migrated, last migrate reason: %s\n' % self.migrate_reason_names[page_owner['last_migrate_reason']]) def read_page_owner(self): -- 2.43.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v5 3/9] mm: use enum migrate_reason instead of int for migration reason parameters [not found] <20260701061101.344679-1-ye.liu@linux.dev> 2026-07-01 6:10 ` [PATCH v5 2/9] mm/page_owner: add MR_NEVER to enum migrate_reason and use it for last_migrate_reason Ye Liu @ 2026-07-01 6:10 ` Ye Liu 2026-07-01 10:23 ` Lorenzo Stoakes 1 sibling, 1 reply; 3+ messages in thread From: Ye Liu @ 2026-07-01 6:10 UTC (permalink / raw) To: Muchun Song, Oscar Salvador, Andrew Morton, David Hildenbrand, Steven Rostedt, Masami Hiramatsu, Vlastimil Babka Cc: Ye Liu, Zi Yan, Matthew Brost, Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang, Alistair Popple, Lorenzo Stoakes, Liam R. Howlett, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Mathieu Desnoyers, Brendan Jackman, Johannes Weiner, linux-mm, linux-kernel, linux-trace-kernel Replace all 'int reason' function parameters that carry migrate_reason values with the proper 'enum migrate_reason' type. This makes the intent explicit and leverages compiler type checking. The affected subsystems are: - page_owner: __folio_set_owner_migrate_reason(), folio_set_owner_migrate_reason() - migrate: migrate_pages(), migrate_pages_sync(), migrate_pages_batch(), migrate_folios_move(), migrate_hugetlbs(), unmap_and_move_huge_page() - hugetlb: move_hugetlb_state(), htlb_allow_alloc_fallback() - trace: mm_migrate_pages and mm_migrate_pages_start events The 'short last_migrate_reason' struct field and internal helper parameter in page_owner are intentionally left as 'short' since they store per-page metadata where size matters. No functional change. Signed-off-by: Ye Liu <ye.liu@linux.dev> Reviewed-by: Zi Yan <ziy@nvidia.com> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> --- include/linux/hugetlb.h | 9 +++++---- include/linux/migrate.h | 6 ++++-- include/linux/page_owner.h | 7 ++++--- include/trace/events/migrate.h | 8 ++++---- mm/hugetlb.c | 3 ++- mm/migrate.c | 12 ++++++------ mm/page_owner.c | 2 +- 7 files changed, 26 insertions(+), 21 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 2abaf99321e9..fa828232dfcc 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -154,7 +154,8 @@ long hugetlb_unreserve_pages(struct inode *inode, long start, long end, bool folio_isolate_hugetlb(struct folio *folio, struct list_head *list); int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison); void folio_putback_hugetlb(struct folio *folio); -void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int reason); +void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, + enum migrate_reason reason); void hugetlb_fix_reserve_counts(struct inode *inode); extern struct mutex *hugetlb_fault_mutex_table; u32 hugetlb_fault_mutex_hash(struct address_space *mapping, pgoff_t idx); @@ -424,7 +425,7 @@ static inline void folio_putback_hugetlb(struct folio *folio) } static inline void move_hugetlb_state(struct folio *old_folio, - struct folio *new_folio, int reason) + struct folio *new_folio, enum migrate_reason reason) { } @@ -956,7 +957,7 @@ static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask) return modified_mask; } -static inline bool htlb_allow_alloc_fallback(int reason) +static inline bool htlb_allow_alloc_fallback(enum migrate_reason reason) { bool allowed_fallback = false; @@ -1238,7 +1239,7 @@ static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask) return 0; } -static inline bool htlb_allow_alloc_fallback(int reason) +static inline bool htlb_allow_alloc_fallback(enum migrate_reason reason) { return false; } diff --git a/include/linux/migrate.h b/include/linux/migrate.h index d5af2b7f577b..1f83924615d6 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -57,7 +57,8 @@ void putback_movable_pages(struct list_head *l); int migrate_folio(struct address_space *mapping, struct folio *dst, struct folio *src, enum migrate_mode mode); int migrate_pages(struct list_head *l, new_folio_t new, free_folio_t free, - unsigned long private, enum migrate_mode mode, int reason, + unsigned long private, enum migrate_mode mode, + enum migrate_reason reason, unsigned int *ret_succeeded); struct folio *alloc_migration_target(struct folio *src, unsigned long private); bool isolate_movable_ops_page(struct page *page, isolate_mode_t mode); @@ -77,7 +78,8 @@ int set_movable_ops(const struct movable_operations *ops, enum pagetype type); static inline void putback_movable_pages(struct list_head *l) {} static inline int migrate_pages(struct list_head *l, new_folio_t new, free_folio_t free, unsigned long private, - enum migrate_mode mode, int reason, unsigned int *ret_succeeded) + enum migrate_mode mode, enum migrate_reason reason, + unsigned int *ret_succeeded) { return -ENOSYS; } static inline struct folio *alloc_migration_target(struct folio *src, unsigned long private) diff --git a/include/linux/page_owner.h b/include/linux/page_owner.h index 3328357f6dba..9fe51dfccf26 100644 --- a/include/linux/page_owner.h +++ b/include/linux/page_owner.h @@ -3,6 +3,7 @@ #define __LINUX_PAGE_OWNER_H #include <linux/jump_label.h> +#include <linux/migrate_mode.h> #ifdef CONFIG_PAGE_OWNER extern struct static_key_false page_owner_inited; @@ -14,7 +15,7 @@ extern void __set_page_owner(struct page *page, extern void __split_page_owner(struct page *page, int old_order, int new_order); extern void __folio_copy_owner(struct folio *newfolio, struct folio *old); -extern void __folio_set_owner_migrate_reason(struct folio *folio, int reason); +extern void __folio_set_owner_migrate_reason(struct folio *folio, enum migrate_reason reason); extern void __dump_page_owner(const struct page *page); extern void pagetypeinfo_showmixedcount_print(struct seq_file *m, pg_data_t *pgdat, struct zone *zone); @@ -43,7 +44,7 @@ static inline void folio_copy_owner(struct folio *newfolio, struct folio *old) if (static_branch_unlikely(&page_owner_inited)) __folio_copy_owner(newfolio, old); } -static inline void folio_set_owner_migrate_reason(struct folio *folio, int reason) +static inline void folio_set_owner_migrate_reason(struct folio *folio, enum migrate_reason reason) { if (static_branch_unlikely(&page_owner_inited)) __folio_set_owner_migrate_reason(folio, reason); @@ -68,7 +69,7 @@ static inline void split_page_owner(struct page *page, int old_order, static inline void folio_copy_owner(struct folio *newfolio, struct folio *folio) { } -static inline void folio_set_owner_migrate_reason(struct folio *folio, int reason) +static inline void folio_set_owner_migrate_reason(struct folio *folio, enum migrate_reason reason) { } static inline void dump_page_owner(const struct page *page) diff --git a/include/trace/events/migrate.h b/include/trace/events/migrate.h index 11bc0aa14c7e..15ee2ef201b5 100644 --- a/include/trace/events/migrate.h +++ b/include/trace/events/migrate.h @@ -52,7 +52,7 @@ TRACE_EVENT(mm_migrate_pages, TP_PROTO(unsigned long succeeded, unsigned long failed, unsigned long thp_succeeded, unsigned long thp_failed, unsigned long thp_split, unsigned long large_folio_split, - enum migrate_mode mode, int reason), + enum migrate_mode mode, enum migrate_reason reason), TP_ARGS(succeeded, failed, thp_succeeded, thp_failed, thp_split, large_folio_split, mode, reason), @@ -65,7 +65,7 @@ TRACE_EVENT(mm_migrate_pages, __field( unsigned long, thp_split) __field( unsigned long, large_folio_split) __field( enum migrate_mode, mode) - __field( int, reason) + __field( enum migrate_reason, reason) ), TP_fast_assign( @@ -92,13 +92,13 @@ TRACE_EVENT(mm_migrate_pages, TRACE_EVENT(mm_migrate_pages_start, - TP_PROTO(enum migrate_mode mode, int reason), + TP_PROTO(enum migrate_mode mode, enum migrate_reason reason), TP_ARGS(mode, reason), TP_STRUCT__entry( __field(enum migrate_mode, mode) - __field(int, reason) + __field(enum migrate_reason, reason) ), TP_fast_assign( diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 571212b80835..17732d1fdc5e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7182,7 +7182,8 @@ void folio_putback_hugetlb(struct folio *folio) folio_put(folio); } -void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int reason) +void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, + enum migrate_reason reason) { struct hstate *h = folio_hstate(old_folio); diff --git a/mm/migrate.c b/mm/migrate.c index d9b23909d716..49e10feeb094 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1469,7 +1469,7 @@ static int migrate_folio_move(free_folio_t put_new_folio, unsigned long private, static int unmap_and_move_huge_page(new_folio_t get_new_folio, free_folio_t put_new_folio, unsigned long private, struct folio *src, int force, enum migrate_mode mode, - int reason, struct list_head *ret) + enum migrate_reason reason, struct list_head *ret) { struct folio *dst; int rc = -EAGAIN; @@ -1626,7 +1626,7 @@ struct migrate_pages_stats { */ static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio, free_folio_t put_new_folio, unsigned long private, - enum migrate_mode mode, int reason, + enum migrate_mode mode, enum migrate_reason reason, struct migrate_pages_stats *stats, struct list_head *ret_folios) { @@ -1716,7 +1716,7 @@ static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio, static void migrate_folios_move(struct list_head *src_folios, struct list_head *dst_folios, free_folio_t put_new_folio, unsigned long private, - enum migrate_mode mode, int reason, + enum migrate_mode mode, enum migrate_reason reason, struct list_head *ret_folios, struct migrate_pages_stats *stats, int *retry, int *thp_retry, int *nr_failed, @@ -1799,7 +1799,7 @@ static void migrate_folios_undo(struct list_head *src_folios, */ static int migrate_pages_batch(struct list_head *from, new_folio_t get_new_folio, free_folio_t put_new_folio, - unsigned long private, enum migrate_mode mode, int reason, + unsigned long private, enum migrate_mode mode, enum migrate_reason reason, struct list_head *ret_folios, struct list_head *split_folios, struct migrate_pages_stats *stats, int nr_pass) { @@ -2011,7 +2011,7 @@ static int migrate_pages_batch(struct list_head *from, static int migrate_pages_sync(struct list_head *from, new_folio_t get_new_folio, free_folio_t put_new_folio, unsigned long private, - enum migrate_mode mode, int reason, + enum migrate_mode mode, enum migrate_reason reason, struct list_head *ret_folios, struct list_head *split_folios, struct migrate_pages_stats *stats) { @@ -2088,7 +2088,7 @@ static int migrate_pages_sync(struct list_head *from, new_folio_t get_new_folio, */ int migrate_pages(struct list_head *from, new_folio_t get_new_folio, free_folio_t put_new_folio, unsigned long private, - enum migrate_mode mode, int reason, unsigned int *ret_succeeded) + enum migrate_mode mode, enum migrate_reason reason, unsigned int *ret_succeeded) { int rc, rc_gather; int nr_pages; diff --git a/mm/page_owner.c b/mm/page_owner.c index c2f43ab860eb..4e352941a6e2 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -345,7 +345,7 @@ noinline void __set_page_owner(struct page *page, unsigned short order, inc_stack_record_count(handle, gfp_mask, 1 << order); } -void __folio_set_owner_migrate_reason(struct folio *folio, int reason) +void __folio_set_owner_migrate_reason(struct folio *folio, enum migrate_reason reason) { struct page_ext *page_ext = page_ext_get(&folio->page); struct page_owner *page_owner; -- 2.43.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v5 3/9] mm: use enum migrate_reason instead of int for migration reason parameters 2026-07-01 6:10 ` [PATCH v5 3/9] mm: use enum migrate_reason instead of int for migration reason parameters Ye Liu @ 2026-07-01 10:23 ` Lorenzo Stoakes 0 siblings, 0 replies; 3+ messages in thread From: Lorenzo Stoakes @ 2026-07-01 10:23 UTC (permalink / raw) To: Ye Liu Cc: Muchun Song, Oscar Salvador, Andrew Morton, David Hildenbrand, Steven Rostedt, Masami Hiramatsu, Vlastimil Babka, Zi Yan, Matthew Brost, Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang, Alistair Popple, Liam R. Howlett, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Mathieu Desnoyers, Brendan Jackman, Johannes Weiner, linux-mm, linux-kernel, linux-trace-kernel On Wed, Jul 01, 2026 at 02:10:46PM +0800, Ye Liu wrote: > Replace all 'int reason' function parameters that carry migrate_reason > values with the proper 'enum migrate_reason' type. This makes the > intent explicit and leverages compiler type checking. The affected > subsystems are: > > - page_owner: __folio_set_owner_migrate_reason(), > folio_set_owner_migrate_reason() > - migrate: migrate_pages(), migrate_pages_sync(), > migrate_pages_batch(), migrate_folios_move(), > migrate_hugetlbs(), unmap_and_move_huge_page() > - hugetlb: move_hugetlb_state(), htlb_allow_alloc_fallback() > - trace: mm_migrate_pages and mm_migrate_pages_start events > > The 'short last_migrate_reason' struct field and internal helper > parameter in page_owner are intentionally left as 'short' since they > store per-page metadata where size matters. Based on my own personal experience, it's ok to be short ;) > > No functional change. > > Signed-off-by: Ye Liu <ye.liu@linux.dev> > Reviewed-by: Zi Yan <ziy@nvidia.com> > Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> 1 nit below but otherwise LGTM so: Reviewed-by: Lorenzo Stoakes <ljs@kernel.org> > --- > include/linux/hugetlb.h | 9 +++++---- > include/linux/migrate.h | 6 ++++-- > include/linux/page_owner.h | 7 ++++--- > include/trace/events/migrate.h | 8 ++++---- > mm/hugetlb.c | 3 ++- > mm/migrate.c | 12 ++++++------ > mm/page_owner.c | 2 +- > 7 files changed, 26 insertions(+), 21 deletions(-) > > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h > index 2abaf99321e9..fa828232dfcc 100644 > --- a/include/linux/hugetlb.h > +++ b/include/linux/hugetlb.h > @@ -154,7 +154,8 @@ long hugetlb_unreserve_pages(struct inode *inode, long start, long end, > bool folio_isolate_hugetlb(struct folio *folio, struct list_head *list); > int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison); > void folio_putback_hugetlb(struct folio *folio); > -void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int reason); > +void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, > + enum migrate_reason reason); > void hugetlb_fix_reserve_counts(struct inode *inode); > extern struct mutex *hugetlb_fault_mutex_table; > u32 hugetlb_fault_mutex_hash(struct address_space *mapping, pgoff_t idx); > @@ -424,7 +425,7 @@ static inline void folio_putback_hugetlb(struct folio *folio) > } > > static inline void move_hugetlb_state(struct folio *old_folio, > - struct folio *new_folio, int reason) > + struct folio *new_folio, enum migrate_reason reason) > { > } > > @@ -956,7 +957,7 @@ static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask) > return modified_mask; > } > > -static inline bool htlb_allow_alloc_fallback(int reason) > +static inline bool htlb_allow_alloc_fallback(enum migrate_reason reason) > { > bool allowed_fallback = false; > > @@ -1238,7 +1239,7 @@ static inline gfp_t htlb_modify_alloc_mask(struct hstate *h, gfp_t gfp_mask) > return 0; > } > > -static inline bool htlb_allow_alloc_fallback(int reason) > +static inline bool htlb_allow_alloc_fallback(enum migrate_reason reason) > { > return false; > } > diff --git a/include/linux/migrate.h b/include/linux/migrate.h > index d5af2b7f577b..1f83924615d6 100644 > --- a/include/linux/migrate.h > +++ b/include/linux/migrate.h > @@ -57,7 +57,8 @@ void putback_movable_pages(struct list_head *l); > int migrate_folio(struct address_space *mapping, struct folio *dst, > struct folio *src, enum migrate_mode mode); > int migrate_pages(struct list_head *l, new_folio_t new, free_folio_t free, > - unsigned long private, enum migrate_mode mode, int reason, > + unsigned long private, enum migrate_mode mode, > + enum migrate_reason reason, > unsigned int *ret_succeeded); > struct folio *alloc_migration_target(struct folio *src, unsigned long private); > bool isolate_movable_ops_page(struct page *page, isolate_mode_t mode); > @@ -77,7 +78,8 @@ int set_movable_ops(const struct movable_operations *ops, enum pagetype type); > static inline void putback_movable_pages(struct list_head *l) {} > static inline int migrate_pages(struct list_head *l, new_folio_t new, > free_folio_t free, unsigned long private, > - enum migrate_mode mode, int reason, unsigned int *ret_succeeded) > + enum migrate_mode mode, enum migrate_reason reason, > + unsigned int *ret_succeeded) > { return -ENOSYS; } > static inline struct folio *alloc_migration_target(struct folio *src, > unsigned long private) > diff --git a/include/linux/page_owner.h b/include/linux/page_owner.h > index 3328357f6dba..9fe51dfccf26 100644 > --- a/include/linux/page_owner.h > +++ b/include/linux/page_owner.h > @@ -3,6 +3,7 @@ > #define __LINUX_PAGE_OWNER_H > > #include <linux/jump_label.h> > +#include <linux/migrate_mode.h> > > #ifdef CONFIG_PAGE_OWNER > extern struct static_key_false page_owner_inited; > @@ -14,7 +15,7 @@ extern void __set_page_owner(struct page *page, > extern void __split_page_owner(struct page *page, int old_order, > int new_order); > extern void __folio_copy_owner(struct folio *newfolio, struct folio *old); > -extern void __folio_set_owner_migrate_reason(struct folio *folio, int reason); > +extern void __folio_set_owner_migrate_reason(struct folio *folio, enum migrate_reason reason); NIT: We drop externs when we change them as a rule, the extern is unnecessary. > extern void __dump_page_owner(const struct page *page); > extern void pagetypeinfo_showmixedcount_print(struct seq_file *m, > pg_data_t *pgdat, struct zone *zone); > @@ -43,7 +44,7 @@ static inline void folio_copy_owner(struct folio *newfolio, struct folio *old) > if (static_branch_unlikely(&page_owner_inited)) > __folio_copy_owner(newfolio, old); > } > -static inline void folio_set_owner_migrate_reason(struct folio *folio, int reason) > +static inline void folio_set_owner_migrate_reason(struct folio *folio, enum migrate_reason reason) > { > if (static_branch_unlikely(&page_owner_inited)) > __folio_set_owner_migrate_reason(folio, reason); > @@ -68,7 +69,7 @@ static inline void split_page_owner(struct page *page, int old_order, > static inline void folio_copy_owner(struct folio *newfolio, struct folio *folio) > { > } > -static inline void folio_set_owner_migrate_reason(struct folio *folio, int reason) > +static inline void folio_set_owner_migrate_reason(struct folio *folio, enum migrate_reason reason) > { > } > static inline void dump_page_owner(const struct page *page) > diff --git a/include/trace/events/migrate.h b/include/trace/events/migrate.h > index 11bc0aa14c7e..15ee2ef201b5 100644 > --- a/include/trace/events/migrate.h > +++ b/include/trace/events/migrate.h > @@ -52,7 +52,7 @@ TRACE_EVENT(mm_migrate_pages, > TP_PROTO(unsigned long succeeded, unsigned long failed, > unsigned long thp_succeeded, unsigned long thp_failed, > unsigned long thp_split, unsigned long large_folio_split, > - enum migrate_mode mode, int reason), > + enum migrate_mode mode, enum migrate_reason reason), > > TP_ARGS(succeeded, failed, thp_succeeded, thp_failed, > thp_split, large_folio_split, mode, reason), > @@ -65,7 +65,7 @@ TRACE_EVENT(mm_migrate_pages, > __field( unsigned long, thp_split) > __field( unsigned long, large_folio_split) > __field( enum migrate_mode, mode) > - __field( int, reason) > + __field( enum migrate_reason, reason) > ), > > TP_fast_assign( > @@ -92,13 +92,13 @@ TRACE_EVENT(mm_migrate_pages, > > TRACE_EVENT(mm_migrate_pages_start, > > - TP_PROTO(enum migrate_mode mode, int reason), > + TP_PROTO(enum migrate_mode mode, enum migrate_reason reason), > > TP_ARGS(mode, reason), > > TP_STRUCT__entry( > __field(enum migrate_mode, mode) > - __field(int, reason) > + __field(enum migrate_reason, reason) > ), > > TP_fast_assign( > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 571212b80835..17732d1fdc5e 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -7182,7 +7182,8 @@ void folio_putback_hugetlb(struct folio *folio) > folio_put(folio); > } > > -void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int reason) > +void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, > + enum migrate_reason reason) > { > struct hstate *h = folio_hstate(old_folio); > > diff --git a/mm/migrate.c b/mm/migrate.c > index d9b23909d716..49e10feeb094 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1469,7 +1469,7 @@ static int migrate_folio_move(free_folio_t put_new_folio, unsigned long private, > static int unmap_and_move_huge_page(new_folio_t get_new_folio, > free_folio_t put_new_folio, unsigned long private, > struct folio *src, int force, enum migrate_mode mode, > - int reason, struct list_head *ret) > + enum migrate_reason reason, struct list_head *ret) > { > struct folio *dst; > int rc = -EAGAIN; > @@ -1626,7 +1626,7 @@ struct migrate_pages_stats { > */ > static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio, > free_folio_t put_new_folio, unsigned long private, > - enum migrate_mode mode, int reason, > + enum migrate_mode mode, enum migrate_reason reason, > struct migrate_pages_stats *stats, > struct list_head *ret_folios) > { > @@ -1716,7 +1716,7 @@ static int migrate_hugetlbs(struct list_head *from, new_folio_t get_new_folio, > static void migrate_folios_move(struct list_head *src_folios, > struct list_head *dst_folios, > free_folio_t put_new_folio, unsigned long private, > - enum migrate_mode mode, int reason, > + enum migrate_mode mode, enum migrate_reason reason, > struct list_head *ret_folios, > struct migrate_pages_stats *stats, > int *retry, int *thp_retry, int *nr_failed, > @@ -1799,7 +1799,7 @@ static void migrate_folios_undo(struct list_head *src_folios, > */ > static int migrate_pages_batch(struct list_head *from, > new_folio_t get_new_folio, free_folio_t put_new_folio, > - unsigned long private, enum migrate_mode mode, int reason, > + unsigned long private, enum migrate_mode mode, enum migrate_reason reason, > struct list_head *ret_folios, struct list_head *split_folios, > struct migrate_pages_stats *stats, int nr_pass) > { > @@ -2011,7 +2011,7 @@ static int migrate_pages_batch(struct list_head *from, > > static int migrate_pages_sync(struct list_head *from, new_folio_t get_new_folio, > free_folio_t put_new_folio, unsigned long private, > - enum migrate_mode mode, int reason, > + enum migrate_mode mode, enum migrate_reason reason, > struct list_head *ret_folios, struct list_head *split_folios, > struct migrate_pages_stats *stats) > { > @@ -2088,7 +2088,7 @@ static int migrate_pages_sync(struct list_head *from, new_folio_t get_new_folio, > */ > int migrate_pages(struct list_head *from, new_folio_t get_new_folio, > free_folio_t put_new_folio, unsigned long private, > - enum migrate_mode mode, int reason, unsigned int *ret_succeeded) > + enum migrate_mode mode, enum migrate_reason reason, unsigned int *ret_succeeded) > { > int rc, rc_gather; > int nr_pages; > diff --git a/mm/page_owner.c b/mm/page_owner.c > index c2f43ab860eb..4e352941a6e2 100644 > --- a/mm/page_owner.c > +++ b/mm/page_owner.c > @@ -345,7 +345,7 @@ noinline void __set_page_owner(struct page *page, unsigned short order, > inc_stack_record_count(handle, gfp_mask, 1 << order); > } > > -void __folio_set_owner_migrate_reason(struct folio *folio, int reason) > +void __folio_set_owner_migrate_reason(struct folio *folio, enum migrate_reason reason) > { > struct page_ext *page_ext = page_ext_get(&folio->page); > struct page_owner *page_owner; > -- > 2.43.0 > Cheers, Lorenzo ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-01 10:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260701061101.344679-1-ye.liu@linux.dev>
2026-07-01 6:10 ` [PATCH v5 2/9] mm/page_owner: add MR_NEVER to enum migrate_reason and use it for last_migrate_reason Ye Liu
2026-07-01 6:10 ` [PATCH v5 3/9] mm: use enum migrate_reason instead of int for migration reason parameters Ye Liu
2026-07-01 10:23 ` Lorenzo Stoakes
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox