Re: [PATCH] mm/debug: sync up latest migrate_reason to migrate_reason_names

From: John Hubbard
Date: Fri Sep 17 2021 - 20:30:24 EST


On 9/17/21 02:48, Weizhao Ouyang wrote:
...
const struct trace_print_flags pageflag_names[] = {
Good catch! Thanks!

Reviewed-by: "Huang, Ying" <ying.huang@xxxxxxxxx>

It may be better to use BUILD_BUG_ON() to capture similar issue earlier?

How about move migrate_reason_names into mm/page_owner.c and make it size uninitialized(get rid of MR_TYPES).
Then use BUILD_BUG_ON(ARRAY_SIZE(migrate_reason_names != MR_TYPES)) to check it?

A couple more thoughts:

1) From a naming and location point of view, migrate_reason_names[]
really doesn't want to be located in page_owner.c.

2) There are actually three places to synchronize, not two. And in fact,
sure enough, the MR_CONTIG_RANGE is already drifting out of synch: it
has a string of "cma" in mm/debug.c, versus "contig_range" in
include/trace/events/migrate.h.

So...is it possible to use the macro and enums in
include/trace/events/migrate.h, to define the connection between
migrate_reason and a string, everywhere?


thanks,
--
John Hubbard
NVIDIA