MADVISE_FREE, THP: Fix madvise_free_huge_pmd return value after splitting
Subsystems (2)
PATCH 1/2 MADVISE_FREE, THP: Fix madvise_free_huge_pmd return value after splitting
From: Huang Ying <[email protected]>
madvise_free_huge_pmd should return 0 if the fallback PTE operations are required. In madvise_free_huge_pmd, if part pages of THP are discarded, the THP will be split and fallback PTE operations should be used if splitting succeeds. But the original code will make fallback PTE operations skipped, after splitting succeeds. Fix that via make madvise_free_huge_pmd return 0 after splitting successfully, so that the fallback PTE operations will be done.
--- mm/huge_memory.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
mm/huge_memory.c +1 -6
@@ -1287,14 +1287,9 @@ int madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,if (next - addr !=HPAGE_PMD_SIZE ) {get_page (page);spin_unlock (ptl); -if (split_huge_page (page)) { -put_page (page); -unlock_page (page); - goto out_unlocked; - } +split_huge_page (page);put_page (page);unlock_page (page); - ret =1 ; goto out_unlocked; }
Signature · 7 lines
2.8.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/2 mm, THP: Clean up return value of madvise_free_huge_pmd
From: Huang Ying <[email protected]>
The definition of return value of madvise_free_huge_pmd is not clear before. According to the suggestion of Minchan Kim, change the type of return value to bool and return true if we do MADV_FREE successfully on entire pmd page, otherwise, return false. Comments are added too.
--- include/linux/huge_mm.h | 2 +- mm/huge_memory.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-)
include/linux/huge_mm.h +1 -1
@@ -11,7 +11,7 @@ extern struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,unsigned long addr, pmd_t *pmd, unsigned int flags); -extern int madvise_free_huge_pmd (struct mmu_gather *tlb, +extern bool madvise_free_huge_pmd (struct mmu_gather *tlb,struct vm_area_struct *vma,pmd_t *pmd,unsigned long addr,unsigned long next); extern int zap_huge_pmd(struct mmu_gather *tlb,
mm/huge_memory.c +8 -7
@@ -1249,25 +1249,26 @@ out:return 0 ; } -int madvise_free_huge_pmd (struct mmu_gather *tlb,struct vm_area_struct *vma, +/* +* Return true if we do MADV_FREE successfully on entire pmd page. +* Otherwise, return false. +*/ +bool madvise_free_huge_pmd (struct mmu_gather *tlb,struct vm_area_struct *vma,pmd_t *pmd,unsigned long addr,unsigned long next) - {spinlock_t *ptl;pmd_t orig_pmd;struct page *page;struct mm_struct *mm = tlb->mm; -int ret =0 ; +bool ret = false; ptl =pmd_trans_huge_lock (pmd, vma);if (!ptl) goto out_unlocked; orig_pmd = *pmd; -if (is_huge_zero_pmd (orig_pmd)) { - ret =1 ; +if (is_huge_zero_pmd (orig_pmd)) goto out; - } page =pmd_page (orig_pmd);/*
@@ -1309,7 +1310,7 @@ int madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,set_pmd_at (mm, addr, pmd, orig_pmd);tlb_remove_pmd_tlb_entry (tlb, pmd, addr); } - ret =1 ; + ret = true; out:spin_unlock (ptl); out_unlocked:
Signature · 7 lines
2.8.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/2] mm, THP: Clean up return value of madvise_free_huge_pmd
Quoted 9 lines · Ying
From: Huang Ying <[email protected]>
The definition of return value of
madvise_free_huge_pmdis not clear before. According to the suggestion of Minchan Kim, change the type of return value to bool and return true if we doMADV_FREEsuccessfully on entire pmd page, otherwise, return false. Comments are added too.Cc Minchan Kim <[email protected]>Signed-off-by "Huang, Ying" <[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 10 lines · Ying
From: Huang Ying <[email protected]>
madvise_free_huge_pmdshould return 0 if the fallback PTE operations are required. Inmadvise_free_huge_pmd, if part pages of THP are discarded, the THP will be split and fallback PTE operations should be used if splitting succeeds. But the original code will make fallback PTE operations skipped, after splitting succeeds. Fix that via makemadvise_free_huge_pmdreturn 0 after splitting successfully, so that the fallback PTE operations will be done.
Quoted 2 lines
Cc Minchan Kim <[email protected]>Signed-off-by "Huang, Ying" <[email protected]>
Thanks!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>