Skip to content

Commit 7f4b606

Browse files
fancxlakpm00
authored andcommitted
mm/hugetlb: refactor __unmap_hugepage_range() to take folio instead of page
The function __unmap_hugepage_range() has two kinds of users: 1) unmap_hugepage_range(), which passes in the head page of a folio. Since unmap_hugepage_range() already takes folio and there are no other uses of the folio struct in the function, it is natural for __unmap_hugepage_range() to take folio also. 2) All other uses, which pass in NULL pointer. In both cases, we can pass in folio. Refactor __unmap_hugepage_range() to take folio. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Fan Ni <[email protected]> Acked-by: David Hildenbrand <[email protected]> Reviewed-by: Oscar Salvador <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Muchun Song <[email protected]> Cc: Sidhartha Kumar <[email protected]> Cc: "Vishal Moola (Oracle)" <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 81edb1b commit 7f4b606

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

include/linux/hugetlb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void unmap_hugepage_range(struct vm_area_struct *,
134134
void __unmap_hugepage_range(struct mmu_gather *tlb,
135135
struct vm_area_struct *vma,
136136
unsigned long start, unsigned long end,
137-
struct page *ref_page, zap_flags_t zap_flags);
137+
struct folio *, zap_flags_t zap_flags);
138138
void hugetlb_report_meminfo(struct seq_file *);
139139
int hugetlb_report_node_meminfo(char *buf, int len, int nid);
140140
void hugetlb_show_meminfo_node(int nid);
@@ -455,7 +455,7 @@ static inline long hugetlb_change_protection(
455455

456456
static inline void __unmap_hugepage_range(struct mmu_gather *tlb,
457457
struct vm_area_struct *vma, unsigned long start,
458-
unsigned long end, struct page *ref_page,
458+
unsigned long end, struct folio *folio,
459459
zap_flags_t zap_flags)
460460
{
461461
BUG();

mm/hugetlb.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5840,7 +5840,7 @@ int move_hugetlb_page_tables(struct vm_area_struct *vma,
58405840

58415841
void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
58425842
unsigned long start, unsigned long end,
5843-
struct page *ref_page, zap_flags_t zap_flags)
5843+
struct folio *folio, zap_flags_t zap_flags)
58445844
{
58455845
struct mm_struct *mm = vma->vm_mm;
58465846
unsigned long address;
@@ -5913,12 +5913,12 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
59135913

59145914
page = pte_page(pte);
59155915
/*
5916-
* If a reference page is supplied, it is because a specific
5917-
* page is being unmapped, not a range. Ensure the page we
5918-
* are about to unmap is the actual page of interest.
5916+
* If a folio is supplied, it is because a specific
5917+
* folio is being unmapped, not a range. Ensure the folio we
5918+
* are about to unmap is the actual folio of interest.
59195919
*/
5920-
if (ref_page) {
5921-
if (page != ref_page) {
5920+
if (folio) {
5921+
if (page_folio(page) != folio) {
59225922
spin_unlock(ptl);
59235923
continue;
59245924
}
@@ -5982,9 +5982,9 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
59825982

59835983
tlb_remove_page_size(tlb, page, huge_page_size(h));
59845984
/*
5985-
* Bail out after unmapping reference page if supplied
5985+
* If we were instructed to unmap a specific folio, we're done.
59865986
*/
5987-
if (ref_page)
5987+
if (folio)
59885988
break;
59895989
}
59905990
tlb_end_vma(tlb, vma);
@@ -6059,7 +6059,7 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
60596059
tlb_gather_mmu(&tlb, vma->vm_mm);
60606060

60616061
__unmap_hugepage_range(&tlb, vma, start, end,
6062-
&folio->page, zap_flags);
6062+
folio, zap_flags);
60636063

60646064
mmu_notifier_invalidate_range_end(&range);
60656065
tlb_finish_mmu(&tlb);

0 commit comments

Comments
 (0)