Skip to content

Commit

Permalink
page-types: make voffset local variables
Browse files Browse the repository at this point in the history
Signed-off-by: Wu Fengguang <[email protected]>
Cc: Andi Kleen <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Wu Fengguang authored and torvalds committed Oct 8, 2009
1 parent 4a1b672 commit e577ebd
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions Documentation/vm/page-types.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ static unsigned long opt_size[MAX_ADDR_RANGES];
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;
Expand Down Expand Up @@ -328,7 +327,8 @@ static char *page_flag_longname(uint64_t flags)
* 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;
Expand All @@ -354,7 +354,8 @@ static void show_page_range(unsigned long offset, uint64_t flags)
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);
Expand Down Expand Up @@ -435,7 +436,6 @@ static uint64_t well_known_flags(uint64_t flags)
return flags;
}


/*
* page frame walker
*/
Expand Down Expand Up @@ -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);

Expand All @@ -478,16 +479,18 @@ static void add_page(unsigned long offset, uint64_t flags)
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;
Expand All @@ -501,7 +504,7 @@ static void walk_pfn(unsigned long index, unsigned long count)
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;
Expand All @@ -525,9 +528,8 @@ static void walk_vma(unsigned long index, unsigned long count)

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;
Expand All @@ -537,8 +539,9 @@ static void walk_vma(unsigned long index, unsigned long count)

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) {

Expand All @@ -548,11 +551,11 @@ static void walk_task(unsigned long index, unsigned long count)
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);
}
}

Expand All @@ -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]);

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e577ebd

Please sign in to comment.