diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-09-24 19:10:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-09-24 19:10:23 -0400 |
commit | 9c9fa97a8edbc3668dfc7a25de516e80c146e86f (patch) | |
tree | 2dc0e90203796a4b346ce190f9521c3294104058 /mm/madvise.c | |
parent | 5184d449600f501a8688069f35c138c6b3bf8b94 (diff) | |
parent | 2b38d01b4de8b1bbda7f5f7e91252609557635fc (diff) |
Merge branch 'akpm' (patches from Andrew)
Merge updates from Andrew Morton:
- a few hot fixes
- ocfs2 updates
- almost all of -mm (slab-generic, slab, slub, kmemleak, kasan,
cleanups, debug, pagecache, memcg, gup, pagemap, memory-hotplug,
sparsemem, vmalloc, initialization, z3fold, compaction, mempolicy,
oom-kill, hugetlb, migration, thp, mmap, madvise, shmem, zswap,
zsmalloc)
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (132 commits)
mm/zsmalloc.c: fix a -Wunused-function warning
zswap: do not map same object twice
zswap: use movable memory if zpool support allocate movable memory
zpool: add malloc_support_movable to zpool_driver
shmem: fix obsolete comment in shmem_getpage_gfp()
mm/madvise: reduce code duplication in error handling paths
mm: mmap: increase sockets maximum memory size pgoff for 32bits
mm/mmap.c: refine find_vma_prev() with rb_last()
riscv: make mmap allocation top-down by default
mips: use generic mmap top-down layout and brk randomization
mips: replace arch specific way to determine 32bit task with generic version
mips: adjust brk randomization offset to fit generic version
mips: use STACK_TOP when computing mmap base address
mips: properly account for stack randomization and stack guard gap
arm: use generic mmap top-down layout and brk randomization
arm: use STACK_TOP when computing mmap base address
arm: properly account for stack randomization and stack guard gap
arm64, mm: make randomization selected by generic topdown mmap layout
arm64, mm: move generic mmap layout functions to mm
arm64: consider stack randomization for mmap base only when necessary
...
Diffstat (limited to 'mm/madvise.c')
-rw-r--r-- | mm/madvise.c | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/mm/madvise.c b/mm/madvise.c index 88babcc384b9..68ab988ad433 100644 --- a/mm/madvise.c +++ b/mm/madvise.c | |||
@@ -107,28 +107,14 @@ static long madvise_behavior(struct vm_area_struct *vma, | |||
107 | case MADV_MERGEABLE: | 107 | case MADV_MERGEABLE: |
108 | case MADV_UNMERGEABLE: | 108 | case MADV_UNMERGEABLE: |
109 | error = ksm_madvise(vma, start, end, behavior, &new_flags); | 109 | error = ksm_madvise(vma, start, end, behavior, &new_flags); |
110 | if (error) { | 110 | if (error) |
111 | /* | 111 | goto out_convert_errno; |
112 | * madvise() returns EAGAIN if kernel resources, such as | ||
113 | * slab, are temporarily unavailable. | ||
114 | */ | ||
115 | if (error == -ENOMEM) | ||
116 | error = -EAGAIN; | ||
117 | goto out; | ||
118 | } | ||
119 | break; | 112 | break; |
120 | case MADV_HUGEPAGE: | 113 | case MADV_HUGEPAGE: |
121 | case MADV_NOHUGEPAGE: | 114 | case MADV_NOHUGEPAGE: |
122 | error = hugepage_madvise(vma, &new_flags, behavior); | 115 | error = hugepage_madvise(vma, &new_flags, behavior); |
123 | if (error) { | 116 | if (error) |
124 | /* | 117 | goto out_convert_errno; |
125 | * madvise() returns EAGAIN if kernel resources, such as | ||
126 | * slab, are temporarily unavailable. | ||
127 | */ | ||
128 | if (error == -ENOMEM) | ||
129 | error = -EAGAIN; | ||
130 | goto out; | ||
131 | } | ||
132 | break; | 118 | break; |
133 | } | 119 | } |
134 | 120 | ||
@@ -154,15 +140,8 @@ static long madvise_behavior(struct vm_area_struct *vma, | |||
154 | goto out; | 140 | goto out; |
155 | } | 141 | } |
156 | error = __split_vma(mm, vma, start, 1); | 142 | error = __split_vma(mm, vma, start, 1); |
157 | if (error) { | 143 | if (error) |
158 | /* | 144 | goto out_convert_errno; |
159 | * madvise() returns EAGAIN if kernel resources, such as | ||
160 | * slab, are temporarily unavailable. | ||
161 | */ | ||
162 | if (error == -ENOMEM) | ||
163 | error = -EAGAIN; | ||
164 | goto out; | ||
165 | } | ||
166 | } | 145 | } |
167 | 146 | ||
168 | if (end != vma->vm_end) { | 147 | if (end != vma->vm_end) { |
@@ -171,15 +150,8 @@ static long madvise_behavior(struct vm_area_struct *vma, | |||
171 | goto out; | 150 | goto out; |
172 | } | 151 | } |
173 | error = __split_vma(mm, vma, end, 0); | 152 | error = __split_vma(mm, vma, end, 0); |
174 | if (error) { | 153 | if (error) |
175 | /* | 154 | goto out_convert_errno; |
176 | * madvise() returns EAGAIN if kernel resources, such as | ||
177 | * slab, are temporarily unavailable. | ||
178 | */ | ||
179 | if (error == -ENOMEM) | ||
180 | error = -EAGAIN; | ||
181 | goto out; | ||
182 | } | ||
183 | } | 155 | } |
184 | 156 | ||
185 | success: | 157 | success: |
@@ -187,6 +159,14 @@ success: | |||
187 | * vm_flags is protected by the mmap_sem held in write mode. | 159 | * vm_flags is protected by the mmap_sem held in write mode. |
188 | */ | 160 | */ |
189 | vma->vm_flags = new_flags; | 161 | vma->vm_flags = new_flags; |
162 | |||
163 | out_convert_errno: | ||
164 | /* | ||
165 | * madvise() returns EAGAIN if kernel resources, such as | ||
166 | * slab, are temporarily unavailable. | ||
167 | */ | ||
168 | if (error == -ENOMEM) | ||
169 | error = -EAGAIN; | ||
190 | out: | 170 | out: |
191 | return error; | 171 | return error; |
192 | } | 172 | } |