aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/vm
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2009-10-07 19:32:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-10-08 10:36:39 -0400
commite577ebde9fb161bdc87511763c75dfad291059e2 (patch)
tree693862be0bae0b32578361f0070ba38378961307 /Documentation/vm
parent4a1b6726feee3132905996ae4cd1c7dc2104e721 (diff)
page-types: make voffset local variables
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Cc: Andi Kleen <andi@firstfloor.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation/vm')
-rw-r--r--Documentation/vm/page-types.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/Documentation/vm/page-types.c b/Documentation/vm/page-types.c
index 18e891a329e0..56f33b63d160 100644
--- a/Documentation/vm/page-types.c
+++ b/Documentation/vm/page-types.c
@@ -159,7 +159,6 @@ static unsigned long opt_size[MAX_ADDR_RANGES];
159static int nr_vmas; 159static int nr_vmas;
160static unsigned long pg_start[MAX_VMAS]; 160static unsigned long pg_start[MAX_VMAS];
161static unsigned long pg_end[MAX_VMAS]; 161static unsigned long pg_end[MAX_VMAS];
162static unsigned long voffset;
163 162
164#define MAX_BIT_FILTERS 64 163#define MAX_BIT_FILTERS 64
165static int nr_bit_filters; 164static int nr_bit_filters;
@@ -328,7 +327,8 @@ static char *page_flag_longname(uint64_t flags)
328 * page list and summary 327 * page list and summary
329 */ 328 */
330 329
331static void show_page_range(unsigned long offset, uint64_t flags) 330static void show_page_range(unsigned long voffset,
331 unsigned long offset, uint64_t flags)
332{ 332{
333 static uint64_t flags0; 333 static uint64_t flags0;
334 static unsigned long voff; 334 static unsigned long voff;
@@ -354,7 +354,8 @@ static void show_page_range(unsigned long offset, uint64_t flags)
354 count = 1; 354 count = 1;
355} 355}
356 356
357static void show_page(unsigned long offset, uint64_t flags) 357static void show_page(unsigned long voffset,
358 unsigned long offset, uint64_t flags)
358{ 359{
359 if (opt_pid) 360 if (opt_pid)
360 printf("%lx\t", voffset); 361 printf("%lx\t", voffset);
@@ -435,7 +436,6 @@ static uint64_t well_known_flags(uint64_t flags)
435 return flags; 436 return flags;
436} 437}
437 438
438
439/* 439/*
440 * page frame walker 440 * page frame walker
441 */ 441 */
@@ -467,7 +467,8 @@ static int hash_slot(uint64_t flags)
467 exit(EXIT_FAILURE); 467 exit(EXIT_FAILURE);
468} 468}
469 469
470static void add_page(unsigned long offset, uint64_t flags) 470static void add_page(unsigned long voffset,
471 unsigned long offset, uint64_t flags)
471{ 472{
472 flags = expand_overloaded_flags(flags); 473 flags = expand_overloaded_flags(flags);
473 474
@@ -478,16 +479,18 @@ static void add_page(unsigned long offset, uint64_t flags)
478 return; 479 return;
479 480
480 if (opt_list == 1) 481 if (opt_list == 1)
481 show_page_range(offset, flags); 482 show_page_range(voffset, offset, flags);
482 else if (opt_list == 2) 483 else if (opt_list == 2)
483 show_page(offset, flags); 484 show_page(voffset, offset, flags);
484 485
485 nr_pages[hash_slot(flags)]++; 486 nr_pages[hash_slot(flags)]++;
486 total_pages++; 487 total_pages++;
487} 488}
488 489
489#define KPAGEFLAGS_BATCH (64 << 10) /* 64k pages */ 490#define KPAGEFLAGS_BATCH (64 << 10) /* 64k pages */
490static void walk_pfn(unsigned long index, unsigned long count) 491static void walk_pfn(unsigned long voffset,
492 unsigned long index,
493 unsigned long count)
491{ 494{
492 uint64_t buf[KPAGEFLAGS_BATCH]; 495 uint64_t buf[KPAGEFLAGS_BATCH];
493 unsigned long batch; 496 unsigned long batch;
@@ -501,7 +504,7 @@ static void walk_pfn(unsigned long index, unsigned long count)
501 break; 504 break;
502 505
503 for (i = 0; i < pages; i++) 506 for (i = 0; i < pages; i++)
504 add_page(index + i, buf[i]); 507 add_page(voffset + i, index + i, buf[i]);
505 508
506 index += pages; 509 index += pages;
507 count -= pages; 510 count -= pages;
@@ -525,9 +528,8 @@ static void walk_vma(unsigned long index, unsigned long count)
525 528
526 for (i = 0; i < pages; i++) { 529 for (i = 0; i < pages; i++) {
527 pfn = pagemap_pfn(buf[i]); 530 pfn = pagemap_pfn(buf[i]);
528 voffset = index + i;
529 if (pfn) 531 if (pfn)
530 walk_pfn(pfn, 1); 532 walk_pfn(index + i, pfn, 1);
531 } 533 }
532 534
533 index += pages; 535 index += pages;
@@ -537,8 +539,9 @@ static void walk_vma(unsigned long index, unsigned long count)
537 539
538static void walk_task(unsigned long index, unsigned long count) 540static void walk_task(unsigned long index, unsigned long count)
539{ 541{
540 int i = 0;
541 const unsigned long end = index + count; 542 const unsigned long end = index + count;
543 unsigned long start;
544 int i = 0;
542 545
543 while (index < end) { 546 while (index < end) {
544 547
@@ -548,11 +551,11 @@ static void walk_task(unsigned long index, unsigned long count)
548 if (pg_start[i] >= end) 551 if (pg_start[i] >= end)
549 return; 552 return;
550 553
551 voffset = max_t(unsigned long, pg_start[i], index); 554 start = max_t(unsigned long, pg_start[i], index);
552 index = min_t(unsigned long, pg_end[i], end); 555 index = min_t(unsigned long, pg_end[i], end);
553 556
554 assert(voffset < index); 557 assert(start < index);
555 walk_vma(voffset, index - voffset); 558 walk_vma(start, index - start);
556 } 559 }
557} 560}
558 561
@@ -577,7 +580,7 @@ static void walk_addr_ranges(void)
577 580
578 for (i = 0; i < nr_addr_ranges; i++) 581 for (i = 0; i < nr_addr_ranges; i++)
579 if (!opt_pid) 582 if (!opt_pid)
580 walk_pfn(opt_offset[i], opt_size[i]); 583 walk_pfn(0, opt_offset[i], opt_size[i]);
581 else 584 else
582 walk_task(opt_offset[i], opt_size[i]); 585 walk_task(opt_offset[i], opt_size[i]);
583 586
@@ -879,7 +882,7 @@ int main(int argc, char *argv[])
879 walk_addr_ranges(); 882 walk_addr_ranges();
880 883
881 if (opt_list == 1) 884 if (opt_list == 1)
882 show_page_range(0, 0); /* drain the buffer */ 885 show_page_range(0, 0, 0); /* drain the buffer */
883 886
884 if (opt_no_summary) 887 if (opt_no_summary)
885 return 0; 888 return 0;