Commit 02347792 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Andrew Morton

khugepaged: remove hpage from collapse_huge_page()

Work purely in terms of the folio.  Removes a call to compound_head()
in put_page().

Link: https://lkml.kernel.org/r/20240403171838.1445826-4-willy@infradead.orgSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarVishal Moola (Oracle) <vishal.moola@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent d5ab50b9
...@@ -1082,7 +1082,6 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, ...@@ -1082,7 +1082,6 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,
pte_t *pte; pte_t *pte;
pgtable_t pgtable; pgtable_t pgtable;
struct folio *folio; struct folio *folio;
struct page *hpage;
spinlock_t *pmd_ptl, *pte_ptl; spinlock_t *pmd_ptl, *pte_ptl;
int result = SCAN_FAIL; int result = SCAN_FAIL;
struct vm_area_struct *vma; struct vm_area_struct *vma;
...@@ -1099,7 +1098,6 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, ...@@ -1099,7 +1098,6 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,
mmap_read_unlock(mm); mmap_read_unlock(mm);
result = alloc_charge_folio(&folio, mm, cc); result = alloc_charge_folio(&folio, mm, cc);
hpage = &folio->page;
if (result != SCAN_SUCCEED) if (result != SCAN_SUCCEED)
goto out_nolock; goto out_nolock;
...@@ -1198,7 +1196,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, ...@@ -1198,7 +1196,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,
*/ */
anon_vma_unlock_write(vma->anon_vma); anon_vma_unlock_write(vma->anon_vma);
result = __collapse_huge_page_copy(pte, hpage, pmd, _pmd, result = __collapse_huge_page_copy(pte, &folio->page, pmd, _pmd,
vma, address, pte_ptl, vma, address, pte_ptl,
&compound_pagelist); &compound_pagelist);
pte_unmap(pte); pte_unmap(pte);
...@@ -1213,7 +1211,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, ...@@ -1213,7 +1211,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,
__folio_mark_uptodate(folio); __folio_mark_uptodate(folio);
pgtable = pmd_pgtable(_pmd); pgtable = pmd_pgtable(_pmd);
_pmd = mk_huge_pmd(hpage, vma->vm_page_prot); _pmd = mk_huge_pmd(&folio->page, vma->vm_page_prot);
_pmd = maybe_pmd_mkwrite(pmd_mkdirty(_pmd), vma); _pmd = maybe_pmd_mkwrite(pmd_mkdirty(_pmd), vma);
spin_lock(pmd_ptl); spin_lock(pmd_ptl);
...@@ -1225,14 +1223,14 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, ...@@ -1225,14 +1223,14 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,
update_mmu_cache_pmd(vma, address, pmd); update_mmu_cache_pmd(vma, address, pmd);
spin_unlock(pmd_ptl); spin_unlock(pmd_ptl);
hpage = NULL; folio = NULL;
result = SCAN_SUCCEED; result = SCAN_SUCCEED;
out_up_write: out_up_write:
mmap_write_unlock(mm); mmap_write_unlock(mm);
out_nolock: out_nolock:
if (hpage) if (folio)
put_page(hpage); folio_put(folio);
trace_mm_collapse_huge_page(mm, result == SCAN_SUCCEED, result); trace_mm_collapse_huge_page(mm, result == SCAN_SUCCEED, result);
return result; return result;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment