2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-17 01:34:00 +08:00

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>
This commit is contained in:
Wu Fengguang 2009-10-07 16:32:30 -07:00 committed by Linus Torvalds
parent 4a1b6726fe
commit e577ebde9f

View File

@ -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;
@ -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;
@ -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);
@ -435,7 +436,6 @@ static uint64_t well_known_flags(uint64_t flags)
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 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;
@ -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;
@ -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;
@ -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) {
@ -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);
}
}
@ -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;