Skip to content

Commit 5c07ebb

Browse files
VMoolaakpm00
authored andcommitted
mm/khugepaged: convert hpage_collapse_scan_pmd() to use folios
Replaces 5 calls to compound_head(), and removes 1385 bytes of kernel text. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Vishal Moola (Oracle) <[email protected]> Reviewed-by: Rik van Riel <[email protected]> Reviewed-by: Yang Shi <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 8dd1e89 commit 5c07ebb

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

mm/khugepaged.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
12481248
int result = SCAN_FAIL, referenced = 0;
12491249
int none_or_zero = 0, shared = 0;
12501250
struct page *page = NULL;
1251+
struct folio *folio = NULL;
12511252
unsigned long _address;
12521253
spinlock_t *ptl;
12531254
int node = NUMA_NO_NODE, unmapped = 0;
@@ -1334,29 +1335,28 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
13341335
}
13351336
}
13361337

1337-
page = compound_head(page);
1338-
1338+
folio = page_folio(page);
13391339
/*
13401340
* Record which node the original page is from and save this
13411341
* information to cc->node_load[].
13421342
* Khugepaged will allocate hugepage from the node has the max
13431343
* hit record.
13441344
*/
1345-
node = page_to_nid(page);
1345+
node = folio_nid(folio);
13461346
if (hpage_collapse_scan_abort(node, cc)) {
13471347
result = SCAN_SCAN_ABORT;
13481348
goto out_unmap;
13491349
}
13501350
cc->node_load[node]++;
1351-
if (!PageLRU(page)) {
1351+
if (!folio_test_lru(folio)) {
13521352
result = SCAN_PAGE_LRU;
13531353
goto out_unmap;
13541354
}
1355-
if (PageLocked(page)) {
1355+
if (folio_test_locked(folio)) {
13561356
result = SCAN_PAGE_LOCK;
13571357
goto out_unmap;
13581358
}
1359-
if (!PageAnon(page)) {
1359+
if (!folio_test_anon(folio)) {
13601360
result = SCAN_PAGE_ANON;
13611361
goto out_unmap;
13621362
}
@@ -1371,7 +1371,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
13711371
* has excessive GUP pins (i.e. 512). Anyway the same check
13721372
* will be done again later the risk seems low.
13731373
*/
1374-
if (!is_refcount_suitable(page)) {
1374+
if (!is_refcount_suitable(&folio->page)) {
13751375
result = SCAN_PAGE_COUNT;
13761376
goto out_unmap;
13771377
}
@@ -1381,8 +1381,8 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
13811381
* enough young pte to justify collapsing the page
13821382
*/
13831383
if (cc->is_khugepaged &&
1384-
(pte_young(pteval) || page_is_young(page) ||
1385-
PageReferenced(page) || mmu_notifier_test_young(vma->vm_mm,
1384+
(pte_young(pteval) || folio_test_young(folio) ||
1385+
folio_test_referenced(folio) || mmu_notifier_test_young(vma->vm_mm,
13861386
address)))
13871387
referenced++;
13881388
}
@@ -1404,7 +1404,7 @@ static int hpage_collapse_scan_pmd(struct mm_struct *mm,
14041404
*mmap_locked = false;
14051405
}
14061406
out:
1407-
trace_mm_khugepaged_scan_pmd(mm, page, writable, referenced,
1407+
trace_mm_khugepaged_scan_pmd(mm, &folio->page, writable, referenced,
14081408
none_or_zero, result, unmapped);
14091409
return result;
14101410
}

0 commit comments

Comments
 (0)