diff options
Diffstat (limited to 'mm/huge_memory.c')
-rw-r--r-- | mm/huge_memory.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index fef4cf210cc7..a513861a9037 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
@@ -1724,37 +1724,37 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, | |||
1724 | { | 1724 | { |
1725 | struct mm_struct *mm = vma->vm_mm; | 1725 | struct mm_struct *mm = vma->vm_mm; |
1726 | spinlock_t *ptl; | 1726 | spinlock_t *ptl; |
1727 | int ret = 0; | 1727 | pmd_t entry; |
1728 | bool preserve_write; | ||
1729 | int ret; | ||
1728 | 1730 | ||
1729 | ptl = __pmd_trans_huge_lock(pmd, vma); | 1731 | ptl = __pmd_trans_huge_lock(pmd, vma); |
1730 | if (ptl) { | 1732 | if (!ptl) |
1731 | pmd_t entry; | 1733 | return 0; |
1732 | bool preserve_write = prot_numa && pmd_write(*pmd); | ||
1733 | ret = 1; | ||
1734 | 1734 | ||
1735 | /* | 1735 | preserve_write = prot_numa && pmd_write(*pmd); |
1736 | * Avoid trapping faults against the zero page. The read-only | 1736 | ret = 1; |
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 | return ret; | ||
1743 | } | ||
1744 | 1737 | ||
1745 | if (!prot_numa || !pmd_protnone(*pmd)) { | 1738 | /* |
1746 | entry = pmdp_huge_get_and_clear_notify(mm, addr, pmd); | 1739 | * Avoid trapping faults against the zero page. The read-only |
1747 | entry = pmd_modify(entry, newprot); | 1740 | * data is likely to be read-cached on the local CPU and |
1748 | if (preserve_write) | 1741 | * local/remote hits to the zero page are not interesting. |
1749 | entry = pmd_mk_savedwrite(entry); | 1742 | */ |
1750 | ret = HPAGE_PMD_NR; | 1743 | if (prot_numa && is_huge_zero_pmd(*pmd)) |
1751 | set_pmd_at(mm, addr, pmd, entry); | 1744 | goto unlock; |
1752 | BUG_ON(vma_is_anonymous(vma) && !preserve_write && | ||
1753 | pmd_write(entry)); | ||
1754 | } | ||
1755 | spin_unlock(ptl); | ||
1756 | } | ||
1757 | 1745 | ||
1746 | if (prot_numa && pmd_protnone(*pmd)) | ||
1747 | goto unlock; | ||
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); | ||
1758 | return ret; | 1758 | return ret; |
1759 | } | 1759 | } |
1760 | 1760 | ||