Skip to content

Commit b745bc8

Browse files
Mel Gormantorvalds
authored andcommitted
mm: page_alloc: convert hot/cold parameter and immediate callers to bool
cold is a bool, make it one. Make the likely case the "if" part of the block instead of the else as according to the optimisation manual this is preferred. Signed-off-by: Mel Gorman <mgorman@suse.de> Acked-by: Rik van Riel <riel@redhat.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Jan Kara <jack@suse.cz> Cc: Michal Hocko <mhocko@suse.cz> Cc: Hugh Dickins <hughd@google.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Theodore Ts'o <tytso@mit.edu> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7aeb09f commit b745bc8

9 files changed

Lines changed: 22 additions & 22 deletions

File tree

‎arch/tile/mm/homecache.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ void __homecache_free_pages(struct page *page, unsigned int order)
417417
if (put_page_testzero(page)) {
418418
homecache_change_page_home(page, order, PAGE_HOME_HASH);
419419
if (order == 0) {
420-
free_hot_cold_page(page, 0);
420+
free_hot_cold_page(page, false);
421421
} else {
422422
init_page_count(page);
423423
__free_pages(page, order);

‎fs/fuse/dev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size,
16141614

16151615
static void fuse_retrieve_end(struct fuse_conn *fc, struct fuse_req *req)
16161616
{
1617-
release_pages(req->pages, req->num_pages, 0);
1617+
release_pages(req->pages, req->num_pages, false);
16181618
}
16191619

16201620
static int fuse_retrieve(struct fuse_conn *fc, struct inode *inode,

‎include/linux/gfp.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ void *alloc_pages_exact_nid(int nid, size_t size, gfp_t gfp_mask);
371371

372372
extern void __free_pages(struct page *page, unsigned int order);
373373
extern void free_pages(unsigned long addr, unsigned int order);
374-
extern void free_hot_cold_page(struct page *page, int cold);
375-
extern void free_hot_cold_page_list(struct list_head *list, int cold);
374+
extern void free_hot_cold_page(struct page *page, bool cold);
375+
extern void free_hot_cold_page_list(struct list_head *list, bool cold);
376376

377377
extern void __free_kmem_pages(struct page *page, unsigned int order);
378378
extern void free_kmem_pages(unsigned long addr, unsigned int order);

‎include/linux/pagemap.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
110110

111111
#define page_cache_get(page) get_page(page)
112112
#define page_cache_release(page) put_page(page)
113-
void release_pages(struct page **pages, int nr, int cold);
113+
void release_pages(struct page **pages, int nr, bool cold);
114114

115115
/*
116116
* speculatively take a reference to a page.

‎include/linux/swap.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
477477
#define free_page_and_swap_cache(page) \
478478
page_cache_release(page)
479479
#define free_pages_and_swap_cache(pages, nr) \
480-
release_pages((pages), (nr), 0);
480+
release_pages((pages), (nr), false);
481481

482482
static inline void show_swap_cache_info(void)
483483
{

‎mm/page_alloc.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ static struct page *__rmqueue(struct zone *zone, unsigned int order,
11991199
*/
12001200
static int rmqueue_bulk(struct zone *zone, unsigned int order,
12011201
unsigned long count, struct list_head *list,
1202-
int migratetype, int cold)
1202+
int migratetype, bool cold)
12031203
{
12041204
int i;
12051205

@@ -1218,7 +1218,7 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
12181218
* merge IO requests if the physical pages are ordered
12191219
* properly.
12201220
*/
1221-
if (likely(cold == 0))
1221+
if (likely(!cold))
12221222
list_add(&page->lru, list);
12231223
else
12241224
list_add_tail(&page->lru, list);
@@ -1379,9 +1379,9 @@ void mark_free_pages(struct zone *zone)
13791379

13801380
/*
13811381
* Free a 0-order page
1382-
* cold == 1 ? free a cold page : free a hot page
1382+
* cold == true ? free a cold page : free a hot page
13831383
*/
1384-
void free_hot_cold_page(struct page *page, int cold)
1384+
void free_hot_cold_page(struct page *page, bool cold)
13851385
{
13861386
struct zone *zone = page_zone(page);
13871387
struct per_cpu_pages *pcp;
@@ -1413,10 +1413,10 @@ void free_hot_cold_page(struct page *page, int cold)
14131413
}
14141414

14151415
pcp = &this_cpu_ptr(zone->pageset)->pcp;
1416-
if (cold)
1417-
list_add_tail(&page->lru, &pcp->lists[migratetype]);
1418-
else
1416+
if (!cold)
14191417
list_add(&page->lru, &pcp->lists[migratetype]);
1418+
else
1419+
list_add_tail(&page->lru, &pcp->lists[migratetype]);
14201420
pcp->count++;
14211421
if (pcp->count >= pcp->high) {
14221422
unsigned long batch = ACCESS_ONCE(pcp->batch);
@@ -1431,7 +1431,7 @@ void free_hot_cold_page(struct page *page, int cold)
14311431
/*
14321432
* Free a list of 0-order pages
14331433
*/
1434-
void free_hot_cold_page_list(struct list_head *list, int cold)
1434+
void free_hot_cold_page_list(struct list_head *list, bool cold)
14351435
{
14361436
struct page *page, *next;
14371437

@@ -1548,7 +1548,7 @@ struct page *buffered_rmqueue(struct zone *preferred_zone,
15481548
{
15491549
unsigned long flags;
15501550
struct page *page;
1551-
int cold = !!(gfp_flags & __GFP_COLD);
1551+
bool cold = ((gfp_flags & __GFP_COLD) != 0);
15521552

15531553
again:
15541554
if (likely(order == 0)) {
@@ -2823,7 +2823,7 @@ void __free_pages(struct page *page, unsigned int order)
28232823
{
28242824
if (put_page_testzero(page)) {
28252825
if (order == 0)
2826-
free_hot_cold_page(page, 0);
2826+
free_hot_cold_page(page, false);
28272827
else
28282828
__free_pages_ok(page, order);
28292829
}

‎mm/swap.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void __page_cache_release(struct page *page)
6767
static void __put_single_page(struct page *page)
6868
{
6969
__page_cache_release(page);
70-
free_hot_cold_page(page, 0);
70+
free_hot_cold_page(page, false);
7171
}
7272

7373
static void __put_compound_page(struct page *page)
@@ -860,7 +860,7 @@ void lru_add_drain_all(void)
860860
* grabbed the page via the LRU. If it did, give up: shrink_inactive_list()
861861
* will free it.
862862
*/
863-
void release_pages(struct page **pages, int nr, int cold)
863+
void release_pages(struct page **pages, int nr, bool cold)
864864
{
865865
int i;
866866
LIST_HEAD(pages_to_free);

‎mm/swap_state.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ void free_pages_and_swap_cache(struct page **pages, int nr)
270270

271271
for (i = 0; i < todo; i++)
272272
free_swap_cache(pagep[i]);
273-
release_pages(pagep, todo, 0);
273+
release_pages(pagep, todo, false);
274274
pagep += todo;
275275
nr -= todo;
276276
}

‎mm/vmscan.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
11211121
VM_BUG_ON_PAGE(PageLRU(page) || PageUnevictable(page), page);
11221122
}
11231123

1124-
free_hot_cold_page_list(&free_pages, 1);
1124+
free_hot_cold_page_list(&free_pages, true);
11251125

11261126
list_splice(&ret_pages, page_list);
11271127
count_vm_events(PGACTIVATE, pgactivate);
@@ -1532,7 +1532,7 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,
15321532

15331533
spin_unlock_irq(&zone->lru_lock);
15341534

1535-
free_hot_cold_page_list(&page_list, 1);
1535+
free_hot_cold_page_list(&page_list, true);
15361536

15371537
/*
15381538
* If reclaim is isolating dirty pages under writeback, it implies
@@ -1755,7 +1755,7 @@ static void shrink_active_list(unsigned long nr_to_scan,
17551755
__mod_zone_page_state(zone, NR_ISOLATED_ANON + file, -nr_taken);
17561756
spin_unlock_irq(&zone->lru_lock);
17571757

1758-
free_hot_cold_page_list(&l_hold, 1);
1758+
free_hot_cold_page_list(&l_hold, true);
17591759
}
17601760

17611761
#ifdef CONFIG_SWAP

0 commit comments

Comments
 (0)