mm: use is_migrate_highatomic() to simplify the code
Subsystems (4)
PATCH 1/2 mm: use is_migrate_highatomic() to simplify the code
Introduce two helpers, is_migrate_highatomic() and is_migrate_highatomic_page(). Simplify the code, no functional changes.
--- include/linux/mmzone.h | 5 +++++ mm/page_alloc.c | 14 ++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-)
include/linux/mmzone.h +5 -0
@@ -66,6 +66,11 @@ 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)
mm/page_alloc.c +6 -8
@@ -2040,8 +2040,8 @@ static void reserve_highatomic_pageblock(struct page *page, struct zone *zone,/* Yoink! */ mt =get_pageblock_migratetype (page); -if (mt !=MIGRATE_HIGHATOMIC && - !is_migrate_isolate (mt) && !is_migrate_cma (mt)) { +if (!is_migrate_highatomic (mt) && !is_migrate_isolate (mt) + && !is_migrate_cma (mt)) { zone->nr_reserved_highatomic += pageblock_nr_pages;set_pageblock_migratetype (page,MIGRATE_HIGHATOMIC );move_freepages_block (zone, page,MIGRATE_HIGHATOMIC );
@@ -2098,8 +2098,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac,* from highatomic to ac->migratetype. So we should * adjust the count once. */ -if (get_pageblock_migratetype (page) == -MIGRATE_HIGHATOMIC ) { +if (is_migrate_highatomic_page (page)) {/* * It should never happen but changes to * locking could inadvertently allow a per-cpu
@@ -2156,8 +2155,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac, page =list_first_entry (&area->free_list[fallback_mt], struct page, lru); -if (can_steal && -get_pageblock_migratetype (page) !=MIGRATE_HIGHATOMIC ) +if (can_steal && !is_migrate_highatomic_page (page))steal_suitable_fallback (zone, page, start_migratetype);/* Remove the page from the freelists */
@@ -2494,7 +2492,7 @@ void free_hot_cold_page(struct page *page, bool cold)/* * We only track unmovable, reclaimable and movable on pcp lists. * Free ISOLATE pages back to the allocator because they are being -* offlined but treat RESERVE as movable pages so we can get those +* offlined but treat HIGHATOMIC as movable pages so we can get those * areas back if necessary. Otherwise, we may have to free * excessively into the page allocator */
@@ -2605,7 +2603,7 @@ int __isolate_free_page(struct page *page, unsigned int order)for (; page < endpage; page += pageblock_nr_pages) {int mt =get_pageblock_migratetype (page);if (!is_migrate_isolate (mt) && !is_migrate_cma (mt) - && mt !=MIGRATE_HIGHATOMIC ) + && !is_migrate_highatomic (mt))set_pageblock_migratetype (page,MIGRATE_MOVABLE ); }
Signature · 8 lines
1.8.3.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/2 mm: use is_migrate_isolate_page() to simplify the code
Use is_migrate_isolate_page() to simplify the code, no functional changes.
--- mm/page_isolation.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/page_isolation.c +3 -3
@@ -88,7 +88,7 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype) zone =page_zone (page);spin_lock_irqsave (&zone->lock, flags); -if (get_pageblock_migratetype (page) !=MIGRATE_ISOLATE ) +if (!is_migrate_isolate_page (page)) goto out;/*
@@ -205,7 +205,7 @@ int undo_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, pfn < end_pfn; pfn += pageblock_nr_pages) { page =__first_valid_page (pfn, pageblock_nr_pages); -if (!page ||get_pageblock_migratetype (page) !=MIGRATE_ISOLATE ) +if (!page || !is_migrate_isolate_page (page))continue ;unset_migratetype_isolate (page, migratetype); }
@@ -262,7 +262,7 @@ int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn,*/ for (pfn = start_pfn; pfn < end_pfn; pfn += pageblock_nr_pages) { page =__first_valid_page (pfn, pageblock_nr_pages); -if (page &&get_pageblock_migratetype (page) !=MIGRATE_ISOLATE ) +if (page && !is_migrate_isolate_page (page))break ; } page =__first_valid_page (start_pfn, end_pfn - start_pfn);
Signature · 8 lines
1.8.3.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/2] mm: use is_migrate_isolate_page() to simplify the code
Quoted 3 lines · Xishi Qiu
Use
is_migrate_isolate_page()to simplify the code, no functional changes.Signed-off-by Xishi Qiu <[email protected]>
Quoted 38 lines
--- mm/page_isolation.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)mm/page_isolation.c +3
-3@@ -88,7 +88,7 @@ static void unset_migratetype_isolate(struct page *page, unsigned migratetype) zone =page_zone (page);spin_lock_irqsave (&zone->lock, flags); -if (get_pageblock_migratetype (page) !=MIGRATE_ISOLATE ) +if (!is_migrate_isolate_page (page)) goto out;/* @@ -205,7 +205,7 @@ int undo_isolate_page_range(unsigned long start_pfn, unsigned long end_pfn, pfn < end_pfn; pfn += pageblock_nr_pages) { page =__first_valid_page (pfn, pageblock_nr_pages); -if (!page ||get_pageblock_migratetype (page) !=MIGRATE_ISOLATE ) +if (!page || !is_migrate_isolate_page (page))continue ;unset_migratetype_isolate (page, migratetype); }@@ -262,7 +262,7 @@ int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn,*/ for (pfn = start_pfn; pfn < end_pfn; pfn += pageblock_nr_pages) { page =__first_valid_page (pfn, pageblock_nr_pages); -if (page &&get_pageblock_migratetype (page) !=MIGRATE_ISOLATE ) +if (page && !is_migrate_isolate_page (page))break ; } page =__first_valid_page (start_pfn, end_pfn - start_pfn);Signature · 1 line
1.8.3.1
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 2 lines · Xishi Qiu
Introduce two helpers,
is_migrate_highatomic()andis_migrate_highatomic_page(). Simplify the code, no functional changes.
static inline helpers would be nicer than macros
Quoted 1 line
Signed-off-by Xishi Qiu <[email protected]>
OK this fits with other MIGRATE_$FOO types
Quoted 77 lines
--- include/linux/mmzone.h | 5 +++++ mm/page_alloc.c | 14 ++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-)include/linux/mmzone.h +5
-0@@ -66,6 +66,11 @@ 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)mm/page_alloc.c +6
-8@@ -2040,8 +2040,8 @@ static void reserve_highatomic_pageblock(struct page *page, struct zone *zone,/* Yoink! */ mt =get_pageblock_migratetype (page); -if (mt !=MIGRATE_HIGHATOMIC && - !is_migrate_isolate (mt) && !is_migrate_cma (mt)) { +if (!is_migrate_highatomic (mt) && !is_migrate_isolate (mt) + && !is_migrate_cma (mt)) { zone->nr_reserved_highatomic += pageblock_nr_pages;set_pageblock_migratetype (page,MIGRATE_HIGHATOMIC );move_freepages_block (zone, page,MIGRATE_HIGHATOMIC );@@ -2098,8 +2098,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac,* from highatomic to ac->migratetype. So we should * adjust the count once. */ -if (get_pageblock_migratetype (page) == -MIGRATE_HIGHATOMIC ) { +if (is_migrate_highatomic_page (page)) {/* * It should never happen but changes to * locking could inadvertently allow a per-cpu @@ -2156,8 +2155,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac, page =list_first_entry (&area->free_list[fallback_mt], struct page, lru); -if (can_steal && -get_pageblock_migratetype (page) !=MIGRATE_HIGHATOMIC ) +if (can_steal && !is_migrate_highatomic_page (page))steal_suitable_fallback (zone, page, start_migratetype);/* Remove the page from the freelists */ @@ -2494,7 +2492,7 @@ void free_hot_cold_page(struct page *page, bool cold)/* * We only track unmovable, reclaimable and movable on pcp lists. * Free ISOLATE pages back to the allocator because they are being -* offlined but treat RESERVE as movable pages so we can get those +* offlined but treat HIGHATOMIC as movable pages so we can get those * areas back if necessary. Otherwise, we may have to free * excessively into the page allocator */ @@ -2605,7 +2603,7 @@ int __isolate_free_page(struct page *page, unsigned int order)for (; page < endpage; page += pageblock_nr_pages) {int mt =get_pageblock_migratetype (page);if (!is_migrate_isolate (mt) && !is_migrate_cma (mt) - && mt !=MIGRATE_HIGHATOMIC ) + && !is_migrate_highatomic (mt))set_pageblock_migratetype (page,MIGRATE_MOVABLE ); }Signature · 1 line
1.8.3.1
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 5 lines · On Fri, 3 Mar 2017 14:18:08 +0100 Michal Hocko <[email protected]> wrote:
Quoted 2 lines · Xishi Qiu
Introduce two helpers,
is_migrate_highatomic()andis_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.
include/linux/mmzone.h renamed from include/linux/mmzone.h~mm-use-is_migrate_highatomic-to-simplify-the-code-fix +1 -6
@@ -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
mm/internal.h renamed from mm/internal.h~mm-use-is_migrate_highatomic-to-simplify-the-code-fix +10 -0
@@ -503,4 +503,14 @@ extern const struct trace_print_flags paextern 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 */
_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · Andrew Morton
Quoted 5 lines · On Fri, 3 Mar 2017 14:18:08 +0100 Michal Hocko <[email protected]> wrote:
Quoted 2 lines · Xishi Qiu
Introduce two helpers,
is_migrate_highatomic()andis_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.hworks.
Just too bad we have three different header files for is_migrate_isolate{_page} - include/linux/page-isolation.h is_migrate_cma{_page} - include/linux/mmzone.h is_migrate_highatomic{_page} - mm/internal.h
I guess we want all of them in internal.h?
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 11 lines · On Mon, 6 Mar 2017 14:38:33 +0100 Michal Hocko <[email protected]> wrote:
Quoted 10 lines · Andrew Morton
Quoted 5 lines · On Fri, 3 Mar 2017 14:18:08 +0100 Michal Hocko <[email protected]> wrote:
Quoted 2 lines · Xishi Qiu
Introduce two helpers,
is_migrate_highatomic()andis_migrate_highatomic_page(). Simplify the code, no functional changes.static inline helpers would be nicer than macros
Always.
Quoted 8 lines
Quoted 1 line
We made a big dependency mess in
mmzone.h.internal.hworks.Just too bad we have three different header files for is_migrate_isolate{_page} -
include/linux/page-isolation.his_migrate_cma{_page} -include/linux/mmzone.his_migrate_highatomic{_page} -mm/internal.hI guess we want all of them in
internal.h?
I suppose so. arch/powerpc/mm/mmu_context_iommu.c is using is_migrate_cma_page which would need some attention.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 20 lines · Andrew Morton
Quoted 18 lines · On Mon, 6 Mar 2017 14:38:33 +0100 Michal Hocko <[email protected]> wrote:
Quoted 11 lines · Andrew Morton
Quoted 5 lines · On Fri, 3 Mar 2017 14:18:08 +0100 Michal Hocko <[email protected]> wrote:
Quoted 2 lines · Xishi Qiu
Introduce two helpers,
is_migrate_highatomic()andis_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.hworks.Just too bad we have three different header files for is_migrate_isolate{_page} -
include/linux/page-isolation.his_migrate_cma{_page} -include/linux/mmzone.his_migrate_highatomic{_page} -mm/internal.h
Quoted 4 lines
Quoted 1 line
I guess we want all of them in
internal.h?I suppose so.
arch/powerpc/mm/mmu_context_iommu.cis usingis_migrate_cma_pagewhich would need some attention.
Ble. I am really wondering whether these helpers actually make the end result really worth all the troubles and the mess.
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>