All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wu Fengguang <fengguang.wu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Wu Fengguang <fengguang.wu@intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Andi Kleen <andi@firstfloor.org>
Subject: [PATCH 6/8] page-types: make voffset local variables
Date: Wed, 16 Sep 2009 18:01:25 +0800	[thread overview]
Message-ID: <20090916100657.628953865@intel.com> (raw)
In-Reply-To: 20090916100119.275066569@intel.com

[-- Attachment #1: page-types-voffset.patch --]
[-- Type: text/plain, Size: 3911 bytes --]

CC: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
 Documentation/vm/page-types.c |   39 +++++++++++++++++---------------
 1 file changed, 21 insertions(+), 18 deletions(-)

--- linux-mm.orig/Documentation/vm/page-types.c	2009-09-16 17:25:07.000000000 +0800
+++ linux-mm/Documentation/vm/page-types.c	2009-09-16 17:53:36.000000000 +0800
@@ -159,7 +159,6 @@ static unsigned long	opt_size[MAX_ADDR_R
 static int		nr_vmas;
 static unsigned long	pg_start[MAX_VMAS];
 static unsigned long	pg_end[MAX_VMAS];
-static unsigned long	voffset;
 
 #define MAX_BIT_FILTERS	64
 static int		nr_bit_filters;
@@ -328,7 +327,8 @@ static char *page_flag_longname(uint64_t
  * page list and summary
  */
 
-static void show_page_range(unsigned long offset, uint64_t flags)
+static void show_page_range(unsigned long voffset,
+			    unsigned long offset, uint64_t flags)
 {
 	static uint64_t      flags0;
 	static unsigned long voff;
@@ -354,7 +354,8 @@ static void show_page_range(unsigned lon
 	count  = 1;
 }
 
-static void show_page(unsigned long offset, uint64_t flags)
+static void show_page(unsigned long voffset,
+		      unsigned long offset, uint64_t flags)
 {
 	if (opt_pid)
 		printf("%lx\t", voffset);
@@ -435,7 +436,6 @@ static uint64_t well_known_flags(uint64_
 	return flags;
 }
 
-
 /*
  * page frame walker
  */
@@ -467,7 +467,8 @@ static int hash_slot(uint64_t flags)
 	exit(EXIT_FAILURE);
 }
 
-static void add_page(unsigned long offset, uint64_t flags)
+static void add_page(unsigned long voffset,
+		     unsigned long offset, uint64_t flags)
 {
 	flags = expand_overloaded_flags(flags);
 
@@ -478,16 +479,18 @@ static void add_page(unsigned long offse
 		return;
 
 	if (opt_list == 1)
-		show_page_range(offset, flags);
+		show_page_range(voffset, offset, flags);
 	else if (opt_list == 2)
-		show_page(offset, flags);
+		show_page(voffset, offset, flags);
 
 	nr_pages[hash_slot(flags)]++;
 	total_pages++;
 }
 
 #define KPAGEFLAGS_BATCH	(64 << 10)	/* 64k pages */
-static void walk_pfn(unsigned long index, unsigned long count)
+static void walk_pfn(unsigned long voffset,
+		     unsigned long index,
+		     unsigned long count)
 {
 	uint64_t buf[KPAGEFLAGS_BATCH];
 	unsigned long batch;
@@ -501,7 +504,7 @@ static void walk_pfn(unsigned long index
 			break;
 
 		for (i = 0; i < pages; i++)
-			add_page(index + i, buf[i]);
+			add_page(voffset + i, index + i, buf[i]);
 
 		index += pages;
 		count -= pages;
@@ -525,9 +528,8 @@ static void walk_vma(unsigned long index
 
 		for (i = 0; i < pages; i++) {
 			pfn = pagemap_pfn(buf[i]);
-			voffset = index + i;
 			if (pfn)
-				walk_pfn(pfn, 1);
+				walk_pfn(index + i, pfn, 1);
 		}
 
 		index += pages;
@@ -537,8 +539,9 @@ static void walk_vma(unsigned long index
 
 static void walk_task(unsigned long index, unsigned long count)
 {
-	int i = 0;
 	const unsigned long end = index + count;
+	unsigned long start;
+	int i = 0;
 
 	while (index < end) {
 
@@ -548,11 +551,11 @@ static void walk_task(unsigned long inde
 		if (pg_start[i] >= end)
 			return;
 
-		voffset = max_t(unsigned long, pg_start[i], index);
-		index   = min_t(unsigned long, pg_end[i], end);
+		start = max_t(unsigned long, pg_start[i], index);
+		index = min_t(unsigned long, pg_end[i], end);
 
-		assert(voffset < index);
-		walk_vma(voffset, index - voffset);
+		assert(start < index);
+		walk_vma(start, index - start);
 	}
 }
 
@@ -577,7 +580,7 @@ static void walk_addr_ranges(void)
 
 	for (i = 0; i < nr_addr_ranges; i++)
 		if (!opt_pid)
-			walk_pfn(opt_offset[i], opt_size[i]);
+			walk_pfn(0, opt_offset[i], opt_size[i]);
 		else
 			walk_task(opt_offset[i], opt_size[i]);
 
@@ -879,7 +882,7 @@ int main(int argc, char *argv[])
 	walk_addr_ranges();
 
 	if (opt_list == 1)
-		show_page_range(0, 0);  /* drain the buffer */
+		show_page_range(0, 0, 0);  /* drain the buffer */
 
 	if (opt_no_summary)
 		return 0;

-- 


  parent reply	other threads:[~2009-09-16 10:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-16 10:01 [PATCH 0/8] page-types tool updates Wu Fengguang
2009-09-16 10:01 ` [PATCH 1/8] pagemap: export KPF_HWPOISON Wu Fengguang
2009-09-16 10:01 ` [PATCH 2/8] pagemap: document KPF_KSM and show it in page-types Wu Fengguang
2009-09-16 10:01 ` [PATCH 3/8] page-types: add GPL note Wu Fengguang
2009-09-16 10:01 ` [PATCH 4/8] page-types: introduce checked_open() Wu Fengguang
2009-09-16 10:01 ` [PATCH 5/8] page-types: make standalone pagemap/kpageflags read routines Wu Fengguang
2009-09-16 10:01 ` Wu Fengguang [this message]
2009-09-16 10:01 ` [PATCH 7/8] page-types: introduce kpageflags_flags() Wu Fengguang
2009-09-16 10:01 ` [PATCH 8/8] page-types: add hwpoison/unpoison feature 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=20090916100657.628953865@intel.com \
    --to=fengguang.wu@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.