public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Moussa A. Ba" <moussa.a.ba@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, adobriyan@gmail.com, mpm@selenic.com,
	mel@csn.ul.ie, yinghan@google.com, npiggin@suse.de,
	jaredeh@gmail.com, moussa.a.ba@gmail.com
Subject: [PATCH 1/1] pagemap clear_refs: modify to specify anon or mapped vma clearing
Date: Thu, 23 Jul 2009 20:57:22 -0700	[thread overview]
Message-ID: <4A693122.6060503@gmail.com> (raw)


Signed-off-by: Jared E. Hulbert <jaredeh@gmail.com>
Signed-off-by: Moussa Ba <moussa.a.ba@gmail.com>
--- a/fs/proc/task_mmu.c	2009-07-21 14:30:01.000000000 -0700
+++ b/fs/proc/task_mmu.c	2009-07-21 14:32:56.000000000 -0700
@@ -461,6 +461,33 @@
  	cond_resched();
  	return 0;
  }
+static void walk_vma_area(struct mm_walk *this_walk, struct 
vm_area_struct *vma,
+						int type)
+{
+	switch (type) {
+		/* Clear Anon VMAs only */
+	case 1:
+		if (!is_vm_hugetlb_page(vma) && !vma->vm_file)
+			walk_page_range(vma->vm_start,
+					vma->vm_end,
+					this_walk);
+		break;
+		/* Clear Mapped VMAs only */
+	case 2:
+		if (!is_vm_hugetlb_page(vma) && vma->vm_file)
+			walk_page_range(vma->vm_start,
+					vma->vm_end,
+					this_walk);
+		break;
+		/* Clear All VMAs */
+	default:
+		if (!is_vm_hugetlb_page(vma))
+			walk_page_range(vma->vm_start,
+					vma->vm_end,
+					this_walk);
+		break;
+	}
+}

  static ssize_t clear_refs_write(struct file *file, const char __user * 
buf,
  				size_t count, loff_t * ppos)
@@ -469,13 +496,15 @@
  	char buffer[PROC_NUMBUF], *end;
  	struct mm_struct *mm;
  	struct vm_area_struct *vma;
+	int type;

  	memset(buffer, 0, sizeof(buffer));
  	if (count > sizeof(buffer) - 1)
  		count = sizeof(buffer) - 1;
  	if (copy_from_user(buffer, buf, count))
  		return -EFAULT;
-	if (!simple_strtol(buffer, &end, 0))
+	type = simple_strtol(buffer, &end, 0);
+	if (!type)
  		return -EINVAL;
  	if (*end == '\n')
  		end++;
@@ -491,9 +520,7 @@
  		down_read(&mm->mmap_sem);
  		for (vma = mm->mmap; vma; vma = vma->vm_next) {
  			clear_refs_walk.private = vma;
-			if (!is_vm_hugetlb_page(vma))
-				walk_page_range(vma->vm_start, vma->vm_end,
-						&clear_refs_walk);
+			walk_vma_area(&clear_refs_walk, vma, type);
  		}
  		flush_tlb_mm(mm);
  		up_read(&mm->mmap_sem);

             reply	other threads:[~2009-07-24  4:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-24  3:57 Moussa A. Ba [this message]
2009-07-24  8:39 ` [PATCH 1/1] pagemap clear_refs: modify to specify anon or mapped vma clearing Amerigo Wang
2009-07-24 18:00   ` Moussa Ba
2009-07-27 20:19   ` Moussa A. Ba
2009-07-27 20:30     ` Matt Mackall
2009-07-27 20:57     ` David Rientjes
2009-07-27 22:14       ` Moussa Ba
2009-07-27 22:20         ` Matt Mackall
2009-07-27 22:49         ` David Rientjes
2009-07-27 23:38           ` Moussa Ba
2009-07-27 23:42             ` Moussa Ba
2009-07-27 23:58             ` David Rientjes
2009-07-28  3:24               ` Amerigo Wang
2009-07-28 16:44               ` Moussa A. Ba
2009-07-28 21:01                 ` David Rientjes
2009-07-28 22:52                   ` Moussa A. Ba
2009-07-28 23:52                     ` Andrew Morton
2009-07-29  0:00                       ` Moussa Ba
2009-07-29 14:58                         ` Mel Gorman
2009-07-29 16:41                           ` Matt Mackall
2009-07-30 19:21                           ` Moussa Ba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A693122.6060503@gmail.com \
    --to=moussa.a.ba@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=jaredeh@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mel@csn.ul.ie \
    --cc=mpm@selenic.com \
    --cc=npiggin@suse.de \
    --cc=yinghan@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox