mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
pagewalk: only split huge pages when necessary
Right now, if a mm_walk has either ->pte_entry or ->pmd_entry set, it will unconditionally split any transparent huge pages it runs in to. In practice, that means that anyone doing a cat /proc/$pid/smaps will unconditionally break down every huge page in the process and depend on khugepaged to re-collapse it later. This is fairly suboptimal. This patch changes that behavior. It teaches each ->pmd_entry handler (there are five) that they must break down the THPs themselves. Also, the _generic_ code will never break down a THP unless a ->pte_entry handler is actually set. This means that the ->pmd_entry handlers can now choose to deal with THPs without breaking them down. [[email protected]: coding-style fixes] Signed-off-by: Dave Hansen <[email protected]> Acked-by: Mel Gorman <[email protected]> Acked-by: David Rientjes <[email protected]> Reviewed-by: Eric B Munson <[email protected]> Tested-by: Eric B Munson <[email protected]> Cc: Michael J Wolf <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Matt Mackall <[email protected]> Cc: Jeremy Fitzhardinge <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
278df9f451
commit
033193275b
4 changed files with 32 additions and 6 deletions
|
|
@ -33,19 +33,35 @@ static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
|
|||
|
||||
pmd = pmd_offset(pud, addr);
|
||||
do {
|
||||
again:
|
||||
next = pmd_addr_end(addr, end);
|
||||
split_huge_page_pmd(walk->mm, pmd);
|
||||
if (pmd_none_or_clear_bad(pmd)) {
|
||||
if (pmd_none(*pmd)) {
|
||||
if (walk->pte_hole)
|
||||
err = walk->pte_hole(addr, next, walk);
|
||||
if (err)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* This implies that each ->pmd_entry() handler
|
||||
* needs to know about pmd_trans_huge() pmds
|
||||
*/
|
||||
if (walk->pmd_entry)
|
||||
err = walk->pmd_entry(pmd, addr, next, walk);
|
||||
if (!err && walk->pte_entry)
|
||||
err = walk_pte_range(pmd, addr, next, walk);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Check this here so we only break down trans_huge
|
||||
* pages when we _need_ to
|
||||
*/
|
||||
if (!walk->pte_entry)
|
||||
continue;
|
||||
|
||||
split_huge_page_pmd(walk->mm, pmd);
|
||||
if (pmd_none_or_clear_bad(pmd))
|
||||
goto again;
|
||||
err = walk_pte_range(pmd, addr, next, walk);
|
||||
if (err)
|
||||
break;
|
||||
} while (pmd++, addr = next, addr != end);
|
||||
|
|
|
|||
Loading…
Reference in a new issue