diff options
Diffstat (limited to 'mm/memory.c')
| -rw-r--r-- | mm/memory.c | 21 | 
1 files changed, 12 insertions, 9 deletions
diff --git a/mm/memory.c b/mm/memory.c index 7e8d8205b610..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, | 
