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
forked fromtorvalds/linux

Commit0a85e51

Browse files
kiryltorvalds
authored andcommitted
thp: reduce indentation level in change_huge_pmd()
Patch series "thp: fix few MADV_DONTNEED races"For MADV_DONTNEED to work properly with huge pages, it's critical to notclear pmd intermittently unless you hold down_write(mmap_sem).Otherwise MADV_DONTNEED can miss the THP which can lead to userspacebreakage.See example of such race in commit message of patch 2/4.All these races are found by code inspection. I haven't seen themtriggered. I don't think it's worth to apply them to stable@.This patch (of 4):Restructure code in preparation for a fix.Link:http://lkml.kernel.org/r/20170302151034.27829-2-kirill.shutemov@linux.intel.comSigned-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>Acked-by: Vlastimil Babka <vbabka@suse.cz>Cc: Andrea Arcangeli <aarcange@redhat.com>Cc: Hillf Danton <hillf.zj@alibaba-inc.com>Cc: <stable@vger.kernel.org>Signed-off-by: Andrew Morton <akpm@linux-foundation.org>Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent76e32a2 commit0a85e51

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

‎mm/huge_memory.c‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,37 +1724,37 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
17241724
{
17251725
structmm_struct*mm=vma->vm_mm;
17261726
spinlock_t*ptl;
1727-
intret=0;
1727+
pmd_tentry;
1728+
boolpreserve_write;
1729+
intret;
17281730

17291731
ptl=__pmd_trans_huge_lock(pmd,vma);
1730-
if (ptl) {
1731-
pmd_tentry;
1732-
boolpreserve_write=prot_numa&&pmd_write(*pmd);
1733-
ret=1;
1732+
if (!ptl)
1733+
return0;
17341734

1735-
/*
1736-
* Avoid trapping faults against the zero page. The read-only
1737-
* data is likely to be read-cached on the local CPU and
1738-
* local/remote hits to the zero page are not interesting.
1739-
*/
1740-
if (prot_numa&&is_huge_zero_pmd(*pmd)) {
1741-
spin_unlock(ptl);
1742-
returnret;
1743-
}
1735+
preserve_write=prot_numa&&pmd_write(*pmd);
1736+
ret=1;
17441737

1745-
if (!prot_numa|| !pmd_protnone(*pmd)) {
1746-
entry=pmdp_huge_get_and_clear_notify(mm,addr,pmd);
1747-
entry=pmd_modify(entry,newprot);
1748-
if (preserve_write)
1749-
entry=pmd_mk_savedwrite(entry);
1750-
ret=HPAGE_PMD_NR;
1751-
set_pmd_at(mm,addr,pmd,entry);
1752-
BUG_ON(vma_is_anonymous(vma)&& !preserve_write&&
1753-
pmd_write(entry));
1754-
}
1755-
spin_unlock(ptl);
1756-
}
1738+
/*
1739+
* Avoid trapping faults against the zero page. The read-only
1740+
* data is likely to be read-cached on the local CPU and
1741+
* local/remote hits to the zero page are not interesting.
1742+
*/
1743+
if (prot_numa&&is_huge_zero_pmd(*pmd))
1744+
gotounlock;
17571745

1746+
if (prot_numa&&pmd_protnone(*pmd))
1747+
gotounlock;
1748+
1749+
entry=pmdp_huge_get_and_clear_notify(mm,addr,pmd);
1750+
entry=pmd_modify(entry,newprot);
1751+
if (preserve_write)
1752+
entry=pmd_mk_savedwrite(entry);
1753+
ret=HPAGE_PMD_NR;
1754+
set_pmd_at(mm,addr,pmd,entry);
1755+
BUG_ON(vma_is_anonymous(vma)&& !preserve_write&&pmd_write(entry));
1756+
unlock:
1757+
spin_unlock(ptl);
17581758
returnret;
17591759
}
17601760

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp