Skip to content

Commit 6c35784

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
mm: replace hpage_nr_pages with thp_nr_pages
The thp prefix is more frequently used than hpage and we should be consistent between the various functions. [[email protected]: fix mm/migrate.c] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: William Kucharski <[email protected]> Reviewed-by: Zi Yan <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent af3bbc1 commit 6c35784

20 files changed

+65
-62
lines changed

include/linux/huge_mm.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,14 @@ static inline unsigned int thp_order(struct page *page)
271271
return 0;
272272
}
273273

274-
static inline int hpage_nr_pages(struct page *page)
274+
/**
275+
* thp_nr_pages - The number of regular pages in this huge page.
276+
* @page: The head page of a huge page.
277+
*/
278+
static inline int thp_nr_pages(struct page *page)
275279
{
276-
if (unlikely(PageTransHuge(page)))
280+
VM_BUG_ON_PGFLAGS(PageTail(page), page);
281+
if (PageHead(page))
277282
return HPAGE_PMD_NR;
278283
return 1;
279284
}
@@ -336,9 +341,9 @@ static inline unsigned int thp_order(struct page *page)
336341
return 0;
337342
}
338343

339-
static inline int hpage_nr_pages(struct page *page)
344+
static inline int thp_nr_pages(struct page *page)
340345
{
341-
VM_BUG_ON_PAGE(PageTail(page), page);
346+
VM_BUG_ON_PGFLAGS(PageTail(page), page);
342347
return 1;
343348
}
344349

include/linux/mm_inline.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@ static __always_inline void update_lru_size(struct lruvec *lruvec,
4848
static __always_inline void add_page_to_lru_list(struct page *page,
4949
struct lruvec *lruvec, enum lru_list lru)
5050
{
51-
update_lru_size(lruvec, lru, page_zonenum(page), hpage_nr_pages(page));
51+
update_lru_size(lruvec, lru, page_zonenum(page), thp_nr_pages(page));
5252
list_add(&page->lru, &lruvec->lists[lru]);
5353
}
5454

5555
static __always_inline void add_page_to_lru_list_tail(struct page *page,
5656
struct lruvec *lruvec, enum lru_list lru)
5757
{
58-
update_lru_size(lruvec, lru, page_zonenum(page), hpage_nr_pages(page));
58+
update_lru_size(lruvec, lru, page_zonenum(page), thp_nr_pages(page));
5959
list_add_tail(&page->lru, &lruvec->lists[lru]);
6060
}
6161

6262
static __always_inline void del_page_from_lru_list(struct page *page,
6363
struct lruvec *lruvec, enum lru_list lru)
6464
{
6565
list_del(&page->lru);
66-
update_lru_size(lruvec, lru, page_zonenum(page), -hpage_nr_pages(page));
66+
update_lru_size(lruvec, lru, page_zonenum(page), -thp_nr_pages(page));
6767
}
6868

6969
/**

include/linux/pagemap.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ static inline struct page *find_subpage(struct page *head, pgoff_t index)
381381
if (PageHuge(head))
382382
return head;
383383

384-
return head + (index & (hpage_nr_pages(head) - 1));
384+
return head + (index & (thp_nr_pages(head) - 1));
385385
}
386386

387387
struct page *find_get_entry(struct address_space *mapping, pgoff_t offset);
@@ -773,7 +773,7 @@ static inline struct page *readahead_page(struct readahead_control *rac)
773773

774774
page = xa_load(&rac->mapping->i_pages, rac->_index);
775775
VM_BUG_ON_PAGE(!PageLocked(page), page);
776-
rac->_batch_count = hpage_nr_pages(page);
776+
rac->_batch_count = thp_nr_pages(page);
777777

778778
return page;
779779
}
@@ -796,7 +796,7 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac,
796796
VM_BUG_ON_PAGE(!PageLocked(page), page);
797797
VM_BUG_ON_PAGE(PageTail(page), page);
798798
array[i++] = page;
799-
rac->_batch_count += hpage_nr_pages(page);
799+
rac->_batch_count += thp_nr_pages(page);
800800

801801
/*
802802
* The page cache isn't using multi-index entries yet,

mm/compaction.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
10091009
del_page_from_lru_list(page, lruvec, page_lru(page));
10101010
mod_node_page_state(page_pgdat(page),
10111011
NR_ISOLATED_ANON + page_is_file_lru(page),
1012-
hpage_nr_pages(page));
1012+
thp_nr_pages(page));
10131013

10141014
isolate_success:
10151015
list_add(&page->lru, &cc->migratepages);

mm/filemap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static void unaccount_page_cache_page(struct address_space *mapping,
198198
if (PageHuge(page))
199199
return;
200200

201-
nr = hpage_nr_pages(page);
201+
nr = thp_nr_pages(page);
202202

203203
__mod_lruvec_page_state(page, NR_FILE_PAGES, -nr);
204204
if (PageSwapBacked(page)) {

mm/gup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ static long check_and_migrate_cma_pages(struct mm_struct *mm,
16371637
mod_node_page_state(page_pgdat(head),
16381638
NR_ISOLATED_ANON +
16391639
page_is_file_lru(head),
1640-
hpage_nr_pages(head));
1640+
thp_nr_pages(head));
16411641
}
16421642
}
16431643
}

mm/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ extern void clear_page_mlock(struct page *page);
369369
static inline void mlock_migrate_page(struct page *newpage, struct page *page)
370370
{
371371
if (TestClearPageMlocked(page)) {
372-
int nr_pages = hpage_nr_pages(page);
372+
int nr_pages = thp_nr_pages(page);
373373

374374
/* Holding pmd lock, no change in irq context: __mod is safe */
375375
__mod_zone_page_state(page_zone(page), NR_MLOCK, -nr_pages);

mm/memcontrol.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5589,7 +5589,7 @@ static int mem_cgroup_move_account(struct page *page,
55895589
{
55905590
struct lruvec *from_vec, *to_vec;
55915591
struct pglist_data *pgdat;
5592-
unsigned int nr_pages = compound ? hpage_nr_pages(page) : 1;
5592+
unsigned int nr_pages = compound ? thp_nr_pages(page) : 1;
55935593
int ret;
55945594

55955595
VM_BUG_ON(from == to);
@@ -6682,7 +6682,7 @@ void mem_cgroup_calculate_protection(struct mem_cgroup *root,
66826682
*/
66836683
int mem_cgroup_charge(struct page *page, struct mm_struct *mm, gfp_t gfp_mask)
66846684
{
6685-
unsigned int nr_pages = hpage_nr_pages(page);
6685+
unsigned int nr_pages = thp_nr_pages(page);
66866686
struct mem_cgroup *memcg = NULL;
66876687
int ret = 0;
66886688

@@ -6912,7 +6912,7 @@ void mem_cgroup_migrate(struct page *oldpage, struct page *newpage)
69126912
return;
69136913

69146914
/* Force-charge the new page. The old one will be freed soon */
6915-
nr_pages = hpage_nr_pages(newpage);
6915+
nr_pages = thp_nr_pages(newpage);
69166916

69176917
page_counter_charge(&memcg->memory, nr_pages);
69186918
if (do_memsw_account())
@@ -7114,7 +7114,7 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry)
71147114
* ancestor for the swap instead and transfer the memory+swap charge.
71157115
*/
71167116
swap_memcg = mem_cgroup_id_get_online(memcg);
7117-
nr_entries = hpage_nr_pages(page);
7117+
nr_entries = thp_nr_pages(page);
71187118
/* Get references for the tail pages, too */
71197119
if (nr_entries > 1)
71207120
mem_cgroup_id_get_many(swap_memcg, nr_entries - 1);
@@ -7158,7 +7158,7 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry)
71587158
*/
71597159
int mem_cgroup_try_charge_swap(struct page *page, swp_entry_t entry)
71607160
{
7161-
unsigned int nr_pages = hpage_nr_pages(page);
7161+
unsigned int nr_pages = thp_nr_pages(page);
71627162
struct page_counter *counter;
71637163
struct mem_cgroup *memcg;
71647164
unsigned short oldid;

mm/memory_hotplug.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,23 +1299,22 @@ static int
12991299
do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
13001300
{
13011301
unsigned long pfn;
1302-
struct page *page;
1302+
struct page *page, *head;
13031303
int ret = 0;
13041304
LIST_HEAD(source);
13051305

13061306
for (pfn = start_pfn; pfn < end_pfn; pfn++) {
13071307
if (!pfn_valid(pfn))
13081308
continue;
13091309
page = pfn_to_page(pfn);
1310+
head = compound_head(page);
13101311

13111312
if (PageHuge(page)) {
1312-
struct page *head = compound_head(page);
13131313
pfn = page_to_pfn(head) + compound_nr(head) - 1;
13141314
isolate_huge_page(head, &source);
13151315
continue;
13161316
} else if (PageTransHuge(page))
1317-
pfn = page_to_pfn(compound_head(page))
1318-
+ hpage_nr_pages(page) - 1;
1317+
pfn = page_to_pfn(head) + thp_nr_pages(page) - 1;
13191318

13201319
/*
13211320
* HWPoison pages have elevated reference counts so the migration would

mm/mempolicy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ static int migrate_page_add(struct page *page, struct list_head *pagelist,
10491049
list_add_tail(&head->lru, pagelist);
10501050
mod_node_page_state(page_pgdat(head),
10511051
NR_ISOLATED_ANON + page_is_file_lru(head),
1052-
hpage_nr_pages(head));
1052+
thp_nr_pages(head));
10531053
} else if (flags & MPOL_MF_STRICT) {
10541054
/*
10551055
* Non-movable page may reach here. And, there may be

0 commit comments

Comments
 (0)