diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /mm/madvise.c | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'mm/madvise.c')
-rw-r--r-- | mm/madvise.c | 43 |
1 files changed, 11 insertions, 32 deletions
diff --git a/mm/madvise.c b/mm/madvise.c index 03dfa5c7adb..74bf193eff0 100644 --- a/mm/madvise.c +++ b/mm/madvise.c | |||
@@ -11,11 +11,8 @@ | |||
11 | #include <linux/mempolicy.h> | 11 | #include <linux/mempolicy.h> |
12 | #include <linux/page-isolation.h> | 12 | #include <linux/page-isolation.h> |
13 | #include <linux/hugetlb.h> | 13 | #include <linux/hugetlb.h> |
14 | #include <linux/falloc.h> | ||
15 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
16 | #include <linux/ksm.h> | 15 | #include <linux/ksm.h> |
17 | #include <linux/fs.h> | ||
18 | #include <linux/file.h> | ||
19 | 16 | ||
20 | /* | 17 | /* |
21 | * Any behaviour which results in changes to the vma->vm_flags needs to | 18 | * Any behaviour which results in changes to the vma->vm_flags needs to |
@@ -68,16 +65,6 @@ static long madvise_behavior(struct vm_area_struct * vma, | |||
68 | } | 65 | } |
69 | new_flags &= ~VM_DONTCOPY; | 66 | new_flags &= ~VM_DONTCOPY; |
70 | break; | 67 | break; |
71 | case MADV_DONTDUMP: | ||
72 | new_flags |= VM_DONTDUMP; | ||
73 | break; | ||
74 | case MADV_DODUMP: | ||
75 | if (new_flags & VM_SPECIAL) { | ||
76 | error = -EINVAL; | ||
77 | goto out; | ||
78 | } | ||
79 | new_flags &= ~VM_DONTDUMP; | ||
80 | break; | ||
81 | case MADV_MERGEABLE: | 68 | case MADV_MERGEABLE: |
82 | case MADV_UNMERGEABLE: | 69 | case MADV_UNMERGEABLE: |
83 | error = ksm_madvise(vma, start, end, behavior, &new_flags); | 70 | error = ksm_madvise(vma, start, end, behavior, &new_flags); |
@@ -207,39 +194,33 @@ static long madvise_remove(struct vm_area_struct *vma, | |||
207 | struct vm_area_struct **prev, | 194 | struct vm_area_struct **prev, |
208 | unsigned long start, unsigned long end) | 195 | unsigned long start, unsigned long end) |
209 | { | 196 | { |
210 | loff_t offset; | 197 | struct address_space *mapping; |
198 | loff_t offset, endoff; | ||
211 | int error; | 199 | int error; |
212 | struct file *f; | ||
213 | 200 | ||
214 | *prev = NULL; /* tell sys_madvise we drop mmap_sem */ | 201 | *prev = NULL; /* tell sys_madvise we drop mmap_sem */ |
215 | 202 | ||
216 | if (vma->vm_flags & (VM_LOCKED|VM_NONLINEAR|VM_HUGETLB)) | 203 | if (vma->vm_flags & (VM_LOCKED|VM_NONLINEAR|VM_HUGETLB)) |
217 | return -EINVAL; | 204 | return -EINVAL; |
218 | 205 | ||
219 | f = vma->vm_file; | 206 | if (!vma->vm_file || !vma->vm_file->f_mapping |
220 | 207 | || !vma->vm_file->f_mapping->host) { | |
221 | if (!f || !f->f_mapping || !f->f_mapping->host) { | ||
222 | return -EINVAL; | 208 | return -EINVAL; |
223 | } | 209 | } |
224 | 210 | ||
225 | if ((vma->vm_flags & (VM_SHARED|VM_WRITE)) != (VM_SHARED|VM_WRITE)) | 211 | if ((vma->vm_flags & (VM_SHARED|VM_WRITE)) != (VM_SHARED|VM_WRITE)) |
226 | return -EACCES; | 212 | return -EACCES; |
227 | 213 | ||
214 | mapping = vma->vm_file->f_mapping; | ||
215 | |||
228 | offset = (loff_t)(start - vma->vm_start) | 216 | offset = (loff_t)(start - vma->vm_start) |
229 | + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); | 217 | + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); |
218 | endoff = (loff_t)(end - vma->vm_start - 1) | ||
219 | + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); | ||
230 | 220 | ||
231 | /* | 221 | /* vmtruncate_range needs to take i_mutex */ |
232 | * Filesystem's fallocate may need to take i_mutex. We need to | ||
233 | * explicitly grab a reference because the vma (and hence the | ||
234 | * vma's reference to the file) can go away as soon as we drop | ||
235 | * mmap_sem. | ||
236 | */ | ||
237 | get_file(f); | ||
238 | up_read(¤t->mm->mmap_sem); | 222 | up_read(¤t->mm->mmap_sem); |
239 | error = do_fallocate(f, | 223 | error = vmtruncate_range(mapping->host, offset, endoff); |
240 | FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, | ||
241 | offset, end - start); | ||
242 | fput(f); | ||
243 | down_read(¤t->mm->mmap_sem); | 224 | down_read(¤t->mm->mmap_sem); |
244 | return error; | 225 | return error; |
245 | } | 226 | } |
@@ -270,7 +251,7 @@ static int madvise_hwpoison(int bhv, unsigned long start, unsigned long end) | |||
270 | printk(KERN_INFO "Injecting memory failure for page %lx at %lx\n", | 251 | printk(KERN_INFO "Injecting memory failure for page %lx at %lx\n", |
271 | page_to_pfn(p), start); | 252 | page_to_pfn(p), start); |
272 | /* Ignore return value for now */ | 253 | /* Ignore return value for now */ |
273 | memory_failure(page_to_pfn(p), 0, MF_COUNT_INCREASED); | 254 | __memory_failure(page_to_pfn(p), 0, MF_COUNT_INCREASED); |
274 | } | 255 | } |
275 | return ret; | 256 | return ret; |
276 | } | 257 | } |
@@ -312,8 +293,6 @@ madvise_behavior_valid(int behavior) | |||
312 | case MADV_HUGEPAGE: | 293 | case MADV_HUGEPAGE: |
313 | case MADV_NOHUGEPAGE: | 294 | case MADV_NOHUGEPAGE: |
314 | #endif | 295 | #endif |
315 | case MADV_DONTDUMP: | ||
316 | case MADV_DODUMP: | ||
317 | return 1; | 296 | return 1; |
318 | 297 | ||
319 | default: | 298 | default: |