Skip to content

Commit a6ffdc0

Browse files
Xishi Qiutorvalds
authored andcommitted
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. [akpm@linux-foundation.org: use static inlines rather than macros, per mhocko] Link: http://lkml.kernel.org/r/58B94F15.6060606@huawei.com Signed-off-by: Xishi Qiu <qiuxishi@huawei.com> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Minchan Kim <minchan@kernel.org> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 322b8af commit a6ffdc0

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎include/linux/mmzone.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*/
3636
#define PAGE_ALLOC_COSTLY_ORDER 3
3737

38-
enum {
38+
enum migratetype {
3939
MIGRATE_UNMOVABLE,
4040
MIGRATE_MOVABLE,
4141
MIGRATE_RECLAIMABLE,

‎mm/internal.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,4 +510,14 @@ extern const struct trace_print_flags pageflag_names[];
510510
extern const struct trace_print_flags vmaflag_names[];
511511
extern const struct trace_print_flags gfpflag_names[];
512512

513+
static inline bool is_migrate_highatomic(enum migratetype migratetype)
514+
{
515+
return migratetype == MIGRATE_HIGHATOMIC;
516+
}
517+
518+
static inline bool is_migrate_highatomic_page(struct page *page)
519+
{
520+
return get_pageblock_migratetype(page) == MIGRATE_HIGHATOMIC;
521+
}
522+
513523
#endif /* __MM_INTERNAL_H */

‎mm/page_alloc.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,8 +2036,8 @@ static void reserve_highatomic_pageblock(struct page *page, struct zone *zone,
20362036

20372037
/* Yoink! */
20382038
mt = get_pageblock_migratetype(page);
2039-
if (mt != MIGRATE_HIGHATOMIC &&
2040-
!is_migrate_isolate(mt) && !is_migrate_cma(mt)) {
2039+
if (!is_migrate_highatomic(mt) && !is_migrate_isolate(mt)
2040+
&& !is_migrate_cma(mt)) {
20412041
zone->nr_reserved_highatomic += pageblock_nr_pages;
20422042
set_pageblock_migratetype(page, MIGRATE_HIGHATOMIC);
20432043
move_freepages_block(zone, page, MIGRATE_HIGHATOMIC);
@@ -2094,8 +2094,7 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac,
20942094
* from highatomic to ac->migratetype. So we should
20952095
* adjust the count once.
20962096
*/
2097-
if (get_pageblock_migratetype(page) ==
2098-
MIGRATE_HIGHATOMIC) {
2097+
if (is_migrate_highatomic_page(page)) {
20992098
/*
21002099
* It should never happen but changes to
21012100
* locking could inadvertently allow a per-cpu
@@ -2152,8 +2151,7 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, int start_migratetype)
21522151

21532152
page = list_first_entry(&area->free_list[fallback_mt],
21542153
struct page, lru);
2155-
if (can_steal &&
2156-
get_pageblock_migratetype(page) != MIGRATE_HIGHATOMIC)
2154+
if (can_steal && !is_migrate_highatomic_page(page))
21572155
steal_suitable_fallback(zone, page, start_migratetype);
21582156

21592157
/* Remove the page from the freelists */
@@ -2493,7 +2491,7 @@ void free_hot_cold_page(struct page *page, bool cold)
24932491
/*
24942492
* We only track unmovable, reclaimable and movable on pcp lists.
24952493
* Free ISOLATE pages back to the allocator because they are being
2496-
* offlined but treat RESERVE as movable pages so we can get those
2494+
* offlined but treat HIGHATOMIC as movable pages so we can get those
24972495
* areas back if necessary. Otherwise, we may have to free
24982496
* excessively into the page allocator
24992497
*/
@@ -2603,7 +2601,7 @@ int __isolate_free_page(struct page *page, unsigned int order)
26032601
for (; page < endpage; page += pageblock_nr_pages) {
26042602
int mt = get_pageblock_migratetype(page);
26052603
if (!is_migrate_isolate(mt) && !is_migrate_cma(mt)
2606-
&& mt != MIGRATE_HIGHATOMIC)
2604+
&& !is_migrate_highatomic(mt))
26072605
set_pageblock_migratetype(page,
26082606
MIGRATE_MOVABLE);
26092607
}

0 commit comments

Comments
 (0)