diff options
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 | } |