Skip to content

Commit 1dd38b6

Browse files
kvaneeshtorvalds
authored andcommitted
mm: move vma_is_anonymous check within pmd_move_must_withdraw
Independent of whether the vma is for anonymous memory, some arches like ppc64 would like to override pmd_move_must_withdraw(). One option is to encapsulate the vma_is_anonymous() check for general architectures inside pmd_move_must_withdraw() so that is always called and architectures that need unconditional overriding can override this function. ppc64 needs to override the function when the MMU is configured to use hash PTE's. [[email protected]: reworked changelog] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Aneesh Kumar K.V <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Acked-by: Michael Ellerman <[email protected]> (powerpc) Cc: Benjamin Herrenschmidt <[email protected]> Cc: Michael Neuling <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Balbir Singh <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 763b218 commit 1dd38b6

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

arch/powerpc/include/asm/book3s/64/pgtable.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,8 @@ static inline void pmdp_huge_split_prepare(struct vm_area_struct *vma,
10091009
#define pmd_move_must_withdraw pmd_move_must_withdraw
10101010
struct spinlock;
10111011
static inline int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl,
1012-
struct spinlock *old_pmd_ptl)
1012+
struct spinlock *old_pmd_ptl,
1013+
struct vm_area_struct *vma)
10131014
{
10141015
if (radix_enabled())
10151016
return false;

include/asm-generic/pgtable.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -652,18 +652,6 @@ static inline pmd_t pmd_read_atomic(pmd_t *pmdp)
652652
}
653653
#endif
654654

655-
#ifndef pmd_move_must_withdraw
656-
static inline int pmd_move_must_withdraw(spinlock_t *new_pmd_ptl,
657-
spinlock_t *old_pmd_ptl)
658-
{
659-
/*
660-
* With split pmd lock we also need to move preallocated
661-
* PTE page table if new_pmd is on different PMD page table.
662-
*/
663-
return new_pmd_ptl != old_pmd_ptl;
664-
}
665-
#endif
666-
667655
/*
668656
* This function is meant to be used by sites walking pagetables with
669657
* the mmap_sem hold in read mode to protect against MADV_DONTNEED and

mm/huge_memory.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,21 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
14291429
return 1;
14301430
}
14311431

1432+
#ifndef pmd_move_must_withdraw
1433+
static inline int pmd_move_must_withdraw(spinlock_t *new_pmd_ptl,
1434+
spinlock_t *old_pmd_ptl,
1435+
struct vm_area_struct *vma)
1436+
{
1437+
/*
1438+
* With split pmd lock we also need to move preallocated
1439+
* PTE page table if new_pmd is on different PMD page table.
1440+
*
1441+
* We also don't deposit and withdraw tables for file pages.
1442+
*/
1443+
return (new_pmd_ptl != old_pmd_ptl) && vma_is_anonymous(vma);
1444+
}
1445+
#endif
1446+
14321447
bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr,
14331448
unsigned long new_addr, unsigned long old_end,
14341449
pmd_t *old_pmd, pmd_t *new_pmd, bool *need_flush)
@@ -1466,8 +1481,7 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr,
14661481
force_flush = true;
14671482
VM_BUG_ON(!pmd_none(*new_pmd));
14681483

1469-
if (pmd_move_must_withdraw(new_ptl, old_ptl) &&
1470-
vma_is_anonymous(vma)) {
1484+
if (pmd_move_must_withdraw(new_ptl, old_ptl, vma)) {
14711485
pgtable_t pgtable;
14721486
pgtable = pgtable_trans_huge_withdraw(mm, old_pmd);
14731487
pgtable_trans_huge_deposit(mm, new_pmd, pgtable);

0 commit comments

Comments
 (0)