diff options
author | Matt Mackall <mpm@selenic.com> | 2008-02-05 01:29:03 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-05 12:44:16 -0500 |
commit | f248dcb34d7b7ac255db70071a20be9d9c6ad491 (patch) | |
tree | ec7c7fb115e40b4a337af98a6f9f2ad5db9af1f0 /fs/proc/task_mmu.c | |
parent | 4752c369789250eafcd7813e11c8fb689235b0d2 (diff) |
maps4: move clear_refs code to task_mmu.c
This puts all the clear_refs code where it belongs and probably lets things
compile on MMU-less systems as well.
Signed-off-by: Matt Mackall <mpm@selenic.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/task_mmu.c')
-rw-r--r-- | fs/proc/task_mmu.c | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index abc44f39f1d6..fcdbd233f252 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -323,19 +323,47 @@ static int show_smap(struct seq_file *m, void *v) | |||
323 | 323 | ||
324 | static struct mm_walk clear_refs_walk = { .pmd_entry = clear_refs_pte_range }; | 324 | static struct mm_walk clear_refs_walk = { .pmd_entry = clear_refs_pte_range }; |
325 | 325 | ||
326 | void clear_refs_smap(struct mm_struct *mm) | 326 | static ssize_t clear_refs_write(struct file *file, const char __user *buf, |
327 | size_t count, loff_t *ppos) | ||
327 | { | 328 | { |
329 | struct task_struct *task; | ||
330 | char buffer[PROC_NUMBUF], *end; | ||
331 | struct mm_struct *mm; | ||
328 | struct vm_area_struct *vma; | 332 | struct vm_area_struct *vma; |
329 | 333 | ||
330 | down_read(&mm->mmap_sem); | 334 | memset(buffer, 0, sizeof(buffer)); |
331 | for (vma = mm->mmap; vma; vma = vma->vm_next) | 335 | if (count > sizeof(buffer) - 1) |
332 | if (vma->vm_mm && !is_vm_hugetlb_page(vma)) | 336 | count = sizeof(buffer) - 1; |
333 | walk_page_range(vma->vm_mm, vma->vm_start, vma->vm_end, | 337 | if (copy_from_user(buffer, buf, count)) |
334 | &clear_refs_walk, vma); | 338 | return -EFAULT; |
335 | flush_tlb_mm(mm); | 339 | if (!simple_strtol(buffer, &end, 0)) |
336 | up_read(&mm->mmap_sem); | 340 | return -EINVAL; |
341 | if (*end == '\n') | ||
342 | end++; | ||
343 | task = get_proc_task(file->f_path.dentry->d_inode); | ||
344 | if (!task) | ||
345 | return -ESRCH; | ||
346 | mm = get_task_mm(task); | ||
347 | if (mm) { | ||
348 | down_read(&mm->mmap_sem); | ||
349 | for (vma = mm->mmap; vma; vma = vma->vm_next) | ||
350 | if (!is_vm_hugetlb_page(vma)) | ||
351 | walk_page_range(mm, vma->vm_start, vma->vm_end, | ||
352 | &clear_refs_walk, vma); | ||
353 | flush_tlb_mm(mm); | ||
354 | up_read(&mm->mmap_sem); | ||
355 | mmput(mm); | ||
356 | } | ||
357 | put_task_struct(task); | ||
358 | if (end - buffer == 0) | ||
359 | return -EIO; | ||
360 | return end - buffer; | ||
337 | } | 361 | } |
338 | 362 | ||
363 | const struct file_operations proc_clear_refs_operations = { | ||
364 | .write = clear_refs_write, | ||
365 | }; | ||
366 | |||
339 | static void *m_start(struct seq_file *m, loff_t *pos) | 367 | static void *m_start(struct seq_file *m, loff_t *pos) |
340 | { | 368 | { |
341 | struct proc_maps_private *priv = m->private; | 369 | struct proc_maps_private *priv = m->private; |