mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-11-30 07:29:42 -05:00
thp: add option to setup migration entries during PMD split
We are going to use migration PTE entries to stabilize page counts. If the page is mapped with PMDs we need to split the PMD and setup migration entries. It's reasonable to combine these operations to avoid double-scanning over the page table. Signed-off-by: Kirill A. Shutemov <[email protected]> Tested-by: Sasha Levin <[email protected]> Tested-by: Aneesh Kumar K.V <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Acked-by: Jerome Marchand <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Steve Capper <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: David Rientjes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
eef1b3ba05
commit
ba98828088
1 changed files with 14 additions and 8 deletions
|
|
@ -2695,7 +2695,7 @@ static void __split_huge_zero_page_pmd(struct vm_area_struct *vma,
|
|||
}
|
||||
|
||||
static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
|
||||
unsigned long haddr)
|
||||
unsigned long haddr, bool freeze)
|
||||
{
|
||||
struct mm_struct *mm = vma->vm_mm;
|
||||
struct page *page;
|
||||
|
|
@ -2739,12 +2739,18 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
|
|||
* transferred to avoid any possibility of altering
|
||||
* permissions across VMAs.
|
||||
*/
|
||||
entry = mk_pte(page + i, vma->vm_page_prot);
|
||||
entry = maybe_mkwrite(pte_mkdirty(entry), vma);
|
||||
if (!write)
|
||||
entry = pte_wrprotect(entry);
|
||||
if (!young)
|
||||
entry = pte_mkold(entry);
|
||||
if (freeze) {
|
||||
swp_entry_t swp_entry;
|
||||
swp_entry = make_migration_entry(page + i, write);
|
||||
entry = swp_entry_to_pte(swp_entry);
|
||||
} else {
|
||||
entry = mk_pte(page + i, vma->vm_page_prot);
|
||||
entry = maybe_mkwrite(pte_mkdirty(entry), vma);
|
||||
if (!write)
|
||||
entry = pte_wrprotect(entry);
|
||||
if (!young)
|
||||
entry = pte_mkold(entry);
|
||||
}
|
||||
pte = pte_offset_map(&_pmd, haddr);
|
||||
BUG_ON(!pte_none(*pte));
|
||||
set_pte_at(mm, haddr, pte, entry);
|
||||
|
|
@ -2785,7 +2791,7 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
|
|||
mmu_notifier_invalidate_range_start(mm, haddr, haddr + HPAGE_PMD_SIZE);
|
||||
ptl = pmd_lock(mm, pmd);
|
||||
if (likely(pmd_trans_huge(*pmd)))
|
||||
__split_huge_pmd_locked(vma, pmd, haddr);
|
||||
__split_huge_pmd_locked(vma, pmd, haddr, false);
|
||||
spin_unlock(ptl);
|
||||
mmu_notifier_invalidate_range_end(mm, haddr, haddr + HPAGE_PMD_SIZE);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue