diff options
Diffstat (limited to 'mm/memory.c')
-rw-r--r-- | mm/memory.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/mm/memory.c b/mm/memory.c index d67fd9fcf1f2..8b44f765b645 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -2758,23 +2758,18 @@ void do_set_pte(struct vm_area_struct *vma, unsigned long address, | |||
2758 | update_mmu_cache(vma, address, pte); | 2758 | update_mmu_cache(vma, address, pte); |
2759 | } | 2759 | } |
2760 | 2760 | ||
2761 | static unsigned long fault_around_bytes = 65536; | 2761 | static unsigned long fault_around_bytes = rounddown_pow_of_two(65536); |
2762 | 2762 | ||
2763 | /* | ||
2764 | * fault_around_pages() and fault_around_mask() round down fault_around_bytes | ||
2765 | * to nearest page order. It's what do_fault_around() expects to see. | ||
2766 | */ | ||
2767 | static inline unsigned long fault_around_pages(void) | 2763 | static inline unsigned long fault_around_pages(void) |
2768 | { | 2764 | { |
2769 | return rounddown_pow_of_two(fault_around_bytes) / PAGE_SIZE; | 2765 | return fault_around_bytes >> PAGE_SHIFT; |
2770 | } | 2766 | } |
2771 | 2767 | ||
2772 | static inline unsigned long fault_around_mask(void) | 2768 | static inline unsigned long fault_around_mask(void) |
2773 | { | 2769 | { |
2774 | return ~(rounddown_pow_of_two(fault_around_bytes) - 1) & PAGE_MASK; | 2770 | return ~(fault_around_bytes - 1) & PAGE_MASK; |
2775 | } | 2771 | } |
2776 | 2772 | ||
2777 | |||
2778 | #ifdef CONFIG_DEBUG_FS | 2773 | #ifdef CONFIG_DEBUG_FS |
2779 | static int fault_around_bytes_get(void *data, u64 *val) | 2774 | static int fault_around_bytes_get(void *data, u64 *val) |
2780 | { | 2775 | { |
@@ -2782,11 +2777,19 @@ static int fault_around_bytes_get(void *data, u64 *val) | |||
2782 | return 0; | 2777 | return 0; |
2783 | } | 2778 | } |
2784 | 2779 | ||
2780 | /* | ||
2781 | * fault_around_pages() and fault_around_mask() expects fault_around_bytes | ||
2782 | * rounded down to nearest page order. It's what do_fault_around() expects to | ||
2783 | * see. | ||
2784 | */ | ||
2785 | static int fault_around_bytes_set(void *data, u64 val) | 2785 | static int fault_around_bytes_set(void *data, u64 val) |
2786 | { | 2786 | { |
2787 | if (val / PAGE_SIZE > PTRS_PER_PTE) | 2787 | if (val / PAGE_SIZE > PTRS_PER_PTE) |
2788 | return -EINVAL; | 2788 | return -EINVAL; |
2789 | fault_around_bytes = val; | 2789 | if (val > PAGE_SIZE) |
2790 | fault_around_bytes = rounddown_pow_of_two(val); | ||
2791 | else | ||
2792 | fault_around_bytes = PAGE_SIZE; /* rounddown_pow_of_two(0) is undefined */ | ||
2790 | return 0; | 2793 | return 0; |
2791 | } | 2794 | } |
2792 | DEFINE_SIMPLE_ATTRIBUTE(fault_around_bytes_fops, | 2795 | DEFINE_SIMPLE_ATTRIBUTE(fault_around_bytes_fops, |
@@ -2882,7 +2885,8 @@ static int do_read_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
2882 | * if page by the offset is not ready to be mapped (cold cache or | 2885 | * if page by the offset is not ready to be mapped (cold cache or |
2883 | * something). | 2886 | * something). |
2884 | */ | 2887 | */ |
2885 | if (vma->vm_ops->map_pages && fault_around_pages() > 1) { | 2888 | if (vma->vm_ops->map_pages && !(flags & FAULT_FLAG_NONLINEAR) && |
2889 | fault_around_pages() > 1) { | ||
2886 | pte = pte_offset_map_lock(mm, pmd, address, &ptl); | 2890 | pte = pte_offset_map_lock(mm, pmd, address, &ptl); |
2887 | do_fault_around(vma, address, pte, pgoff, flags); | 2891 | do_fault_around(vma, address, pte, pgoff, flags); |
2888 | if (!pte_same(*pte, orig_pte)) | 2892 | if (!pte_same(*pte, orig_pte)) |