From 7b10419a1de9be352539b38e2ca70cc5b14687d9 Mon Sep 17 00:00:00 2001 From: John Hubbard Date: Sat, 18 Sep 2021 22:07:20 -0700 Subject: [PATCH] Use one definition of MIGRATE_REASON strings, everywhere X-NVConfidentiality: public Cc: John Hubbard (Compiled-tested only, so no signed off by tag.) --- include/linux/migrate.h | 16 ++-------------- include/linux/migrate_mode.h | 13 +++++++++++++ mm/debug.c | 19 ++++++++++++------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 326250996b4e..cb62fbc3d8d6 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -6,6 +6,7 @@ #include #include #include +#include typedef struct page *new_page_t(struct page *page, unsigned long private); typedef void free_page_t(struct page *page, unsigned long private); @@ -19,20 +20,7 @@ struct migration_target_control; */ #define MIGRATEPAGE_SUCCESS 0 -enum migrate_reason { - MR_COMPACTION, - MR_MEMORY_FAILURE, - MR_MEMORY_HOTPLUG, - MR_SYSCALL, /* also applies to cpusets */ - MR_MEMPOLICY_MBIND, - MR_NUMA_MISPLACED, - MR_CONTIG_RANGE, - MR_LONGTERM_PIN, - MR_DEMOTION, - MR_TYPES -}; - -/* In mm/debug.c; also keep sync with include/trace/events/migrate.h */ +/* In mm/debug.c */ extern const char *migrate_reason_names[MR_TYPES]; #ifdef CONFIG_MIGRATION diff --git a/include/linux/migrate_mode.h b/include/linux/migrate_mode.h index 883c99249033..f37cc03f9369 100644 --- a/include/linux/migrate_mode.h +++ b/include/linux/migrate_mode.h @@ -19,4 +19,17 @@ enum migrate_mode { MIGRATE_SYNC_NO_COPY, }; +enum migrate_reason { + MR_COMPACTION, + MR_MEMORY_FAILURE, + MR_MEMORY_HOTPLUG, + MR_SYSCALL, /* also applies to cpusets */ + MR_MEMPOLICY_MBIND, + MR_NUMA_MISPLACED, + MR_CONTIG_RANGE, + MR_LONGTERM_PIN, + MR_DEMOTION, + MR_TYPES +}; + #endif /* MIGRATE_MODE_H_INCLUDED */ diff --git a/mm/debug.c b/mm/debug.c index e73fe0a8ec3d..51152ffc1f29 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -17,14 +17,19 @@ #include "internal.h" +#include + +/* + * Define EM() and EMe() so that MIGRATE_REASON from trace/events/migrate.h can + * be used to populate migrate_reason_names[]. + */ +#undef EM +#undef EMe +#define EM(a, b) b, +#define EMe(a, b) b + const char *migrate_reason_names[MR_TYPES] = { - "compaction", - "memory_failure", - "memory_hotplug", - "syscall_or_cpuset", - "mempolicy_mbind", - "numa_misplaced", - "cma", + MIGRATE_REASON }; const struct trace_print_flags pageflag_names[] = { -- 2.33.0