Re: [PATCH 1/2] mm: use is_migrate_highatomic() to simplify the code

From: Andrew Morton
Date: Fri Mar 03 2017 - 18:16:09 EST


On Fri, 3 Mar 2017 14:18:08 +0100 Michal Hocko <mhocko@xxxxxxxxxx> wrote:

> On Fri 03-03-17 19:10:13, Xishi Qiu wrote:
> > Introduce two helpers, is_migrate_highatomic() and is_migrate_highatomic_page().
> > Simplify the code, no functional changes.
>
> static inline helpers would be nicer than macros

Always.

We made a big dependency mess in mmzone.h. internal.h works.

--- a/include/linux/mmzone.h~mm-use-is_migrate_highatomic-to-simplify-the-code-fix
+++ a/include/linux/mmzone.h
@@ -35,7 +35,7 @@
*/
#define PAGE_ALLOC_COSTLY_ORDER 3

-enum {
+enum migratetype {
MIGRATE_UNMOVABLE,
MIGRATE_MOVABLE,
MIGRATE_RECLAIMABLE,
@@ -66,11 +66,6 @@ enum {
/* In mm/page_alloc.c; keep in sync also with show_migration_types() there */
extern char * const migratetype_names[MIGRATE_TYPES];

-#define is_migrate_highatomic(migratetype) \
- (migratetype == MIGRATE_HIGHATOMIC)
-#define is_migrate_highatomic_page(_page) \
- (get_pageblock_migratetype(_page) == MIGRATE_HIGHATOMIC)
-
#ifdef CONFIG_CMA
# define is_migrate_cma(migratetype) unlikely((migratetype) == MIGRATE_CMA)
# define is_migrate_cma_page(_page) (get_pageblock_migratetype(_page) == MIGRATE_CMA)
diff -puN mm/page_alloc.c~mm-use-is_migrate_highatomic-to-simplify-the-code-fix mm/page_alloc.c
diff -puN mm/internal.h~mm-use-is_migrate_highatomic-to-simplify-the-code-fix mm/internal.h
--- a/mm/internal.h~mm-use-is_migrate_highatomic-to-simplify-the-code-fix
+++ a/mm/internal.h
@@ -503,4 +503,14 @@ extern const struct trace_print_flags pa
extern const struct trace_print_flags vmaflag_names[];
extern const struct trace_print_flags gfpflag_names[];

+static inline bool is_migrate_highatomic(enum migratetype migratetype)
+{
+ return migratetype == MIGRATE_HIGHATOMIC;
+}
+
+static inline bool is_migrate_highatomic_page(struct page *page)
+{
+ return get_pageblock_migratetype(page) == MIGRATE_HIGHATOMIC;
+}
+
#endif /* __MM_INTERNAL_H */
_