Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcd7548a

Browse files
hnaztorvalds
authored andcommitted
thp: mprotect: transparent huge page support
Natively handle huge pmds when changing page tables on behalf ofmprotect().I left out update_mmu_cache() because we do not need it on x86 anyway butmore importantly the interface works on ptes, not pmds.Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>Reviewed-by: Rik van Riel <riel@redhat.com>Signed-off-by: Andrew Morton <akpm@linux-foundation.org>Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parentb36f5b0 commitcd7548a

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

‎include/linux/huge_mm.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ extern int zap_huge_pmd(struct mmu_gather *tlb,
2222
externintmincore_huge_pmd(structvm_area_struct*vma,pmd_t*pmd,
2323
unsigned longaddr,unsigned longend,
2424
unsignedchar*vec);
25+
externintchange_huge_pmd(structvm_area_struct*vma,pmd_t*pmd,
26+
unsigned longaddr,pgprot_tnewprot);
2527

2628
enumtransparent_hugepage_flag {
2729
TRANSPARENT_HUGEPAGE_FLAG,

‎mm/huge_memory.c‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,33 @@ int mincore_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
948948
returnret;
949949
}
950950

951+
intchange_huge_pmd(structvm_area_struct*vma,pmd_t*pmd,
952+
unsigned longaddr,pgprot_tnewprot)
953+
{
954+
structmm_struct*mm=vma->vm_mm;
955+
intret=0;
956+
957+
spin_lock(&mm->page_table_lock);
958+
if (likely(pmd_trans_huge(*pmd))) {
959+
if (unlikely(pmd_trans_splitting(*pmd))) {
960+
spin_unlock(&mm->page_table_lock);
961+
wait_split_huge_page(vma->anon_vma,pmd);
962+
}else {
963+
pmd_tentry;
964+
965+
entry=pmdp_get_and_clear(mm,addr,pmd);
966+
entry=pmd_modify(entry,newprot);
967+
set_pmd_at(mm,addr,pmd,entry);
968+
spin_unlock(&vma->vm_mm->page_table_lock);
969+
flush_tlb_range(vma,addr,addr+HPAGE_PMD_SIZE);
970+
ret=1;
971+
}
972+
}else
973+
spin_unlock(&vma->vm_mm->page_table_lock);
974+
975+
returnret;
976+
}
977+
951978
pmd_t*page_check_address_pmd(structpage*page,
952979
structmm_struct*mm,
953980
unsigned longaddress,

‎mm/mprotect.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ static inline void change_pmd_range(struct vm_area_struct *vma, pud_t *pud,
8888
pmd=pmd_offset(pud,addr);
8989
do {
9090
next=pmd_addr_end(addr,end);
91-
split_huge_page_pmd(vma->vm_mm,pmd);
91+
if (pmd_trans_huge(*pmd)) {
92+
if (next-addr!=HPAGE_PMD_SIZE)
93+
split_huge_page_pmd(vma->vm_mm,pmd);
94+
elseif (change_huge_pmd(vma,pmd,addr,newprot))
95+
continue;
96+
/* fall through */
97+
}
9298
if (pmd_none_or_clear_bad(pmd))
9399
continue;
94100
change_pte_range(vma->vm_mm,pmd,addr,next,newprot,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp