linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Wu Fengguang <fengguang.wu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>, Ingo Molnar <mingo@elte.hu>
Cc: Mel Gorman <mgorman@suse.de>,
	Wu Fengguang <fengguang.wu@intel.com>,
	Linux Memory Management List <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [RFC][PATCH 5/7] tracing/mm: accept echo-able input format for pfn range
Date: Mon, 29 Aug 2011 11:29:56 +0800	[thread overview]
Message-ID: <20110829034932.272364561@intel.com> (raw)
In-Reply-To: <20110829032951.677220552@intel.com>

[-- Attachment #1: trace-mm-pfn-range-input.patch --]
[-- Type: text/plain, Size: 2467 bytes --]

The seek+write style input for specifying pfn range is not scriptable.
Change it to more user friendly echo-able format.

Before patch:

	fd = open("/debug/tracing/object/mm/page/dump-pfn");
	seek(fd, start);
	write(fd, "size");

After patch:

	echo start +size > /debug/tracing/object/mm/page/dump-pfn
or
	echo start end   > /debug/tracing/object/mm/page/dump-pfn

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
 kernel/trace/trace_mm.c |   39 +++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

--- mmotm.orig/kernel/trace/trace_mm.c	2010-12-26 20:05:26.000000000 +0800
+++ mmotm/kernel/trace/trace_mm.c	2010-12-26 20:20:13.000000000 +0800
@@ -9,6 +9,7 @@
 #include <linux/bootmem.h>
 #include <linux/debugfs.h>
 #include <linux/uaccess.h>
+#include <linux/ctype.h>
 
 #include "trace_output.h"
 
@@ -24,8 +25,8 @@ void trace_mm_page_frames(unsigned long 
 	if (start > max_pfn - 1)
 		return;
 
-	if (end > max_pfn - 1)
-		end = max_pfn - 1;
+	if (end > max_pfn)
+		end = max_pfn;
 
 	while (pfn < end) {
 		page = NULL;
@@ -50,13 +51,20 @@ trace_mm_pfn_range_read(struct file *fil
 }
 
 
+/*
+ * recognized formats:
+ * 		"M N"	start=M, end=N
+ * 		"M"	start=M, end=M+1
+ * 		"M +N"	start=M, end=M+N-1
+ */
 static ssize_t
 trace_mm_pfn_range_write(struct file *filp, const char __user *ubuf, size_t cnt,
 			 loff_t *ppos)
 {
-	unsigned long val, start, end;
+	unsigned long start;
+	unsigned long end = 0;
 	char buf[64];
-	int ret;
+	char *ptr;
 
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
@@ -72,19 +80,20 @@ trace_mm_pfn_range_write(struct file *fi
 
 	buf[cnt] = 0;
 
-	ret = strict_strtol(buf, 10, &val);
-	if (ret < 0)
-		return ret;
-
-	start = *ppos;
-	if (val < 0)
-		end = max_pfn - 1;
-	else
-		end = start + val;
+	start = simple_strtoul(buf, &ptr, 0);
 
-	trace_mm_page_frames(start, end, trace_mm_page_frame);
+	for (; *ptr; ptr++) {
+		if (isdigit(*ptr)) {
+			if (*(ptr - 1) == '+')
+				end = start;
+			end += simple_strtoul(ptr, NULL, 0);
+			break;
+		}
+	}
+	if (!*ptr)
+		end = start + 1;
 
-	*ppos += cnt;
+	trace_mm_page_frames(start, end, trace_mm_page_frame);
 
 	return cnt;
 }


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2011-08-29  3:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-29  3:29 [RFC][PATCH 0/7] trace memory objects Wu Fengguang
2011-08-29  3:29 ` [RFC][PATCH 1/7] tracing/mm: add page frame snapshot trace Wu Fengguang
2011-08-29  3:29 ` Wu Fengguang
2011-08-29  3:29 ` [RFC][PATCH 2/7] tracing/mm: rename trigger file to dump-pfn Wu Fengguang
2011-08-29  3:29 ` Wu Fengguang
2011-08-29  3:29 ` [RFC][PATCH 3/7] tracing/mm: create trace_objects.c Wu Fengguang
2011-08-29  3:29 ` Wu Fengguang
2011-08-29  3:29 ` [RFC][PATCH 4/7] tracing/mm: dump more page frame information Wu Fengguang
2011-08-29  3:29 ` Wu Fengguang
2011-08-29  3:29 ` [RFC][PATCH 5/7] tracing/mm: accept echo-able input format for pfn range Wu Fengguang
2011-08-29  3:29 ` Wu Fengguang [this message]
2011-08-29  3:29 ` [RFC][PATCH 6/7] tracing/mm: add dump-file and dump-fs interfaces Wu Fengguang
2011-08-29  3:29 ` Wu Fengguang
2011-08-29  3:29 ` [RFC][PATCH 7/7] tracing/mm: add memcg field Wu Fengguang
2011-08-29  3:29 ` Wu Fengguang
2011-08-29  3:59 ` [RFC][PATCH 0/7] trace memory objects Wu Fengguang

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=20110829034932.272364561@intel.com \
    --to=fengguang.wu@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mingo@elte.hu \
    /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