Skip to content

Commit

Permalink
xen: clean up "extra" memory handling some more
Browse files Browse the repository at this point in the history
Make sure that extra_pages is added for all E820_RAM regions beyond
mem_end - completely excluded regions as well as the remains of partially
included regions.

Also makes sure the extra region is not unnecessarily high, and simplifies
the logic to decide which regions should be added.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
  • Loading branch information
Jeremy Fitzhardinge committed Nov 23, 2010
1 parent 1233471 commit c2d0879
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions arch/x86/xen/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,21 @@ char * __init xen_memory_setup(void)
for (i = 0; i < memmap.nr_entries; i++) {
unsigned long long end = map[i].addr + map[i].size;

if (map[i].type == E820_RAM) {
if (map[i].addr < mem_end && end > mem_end) {
/* Truncate region to max_mem. */
u64 delta = end - mem_end;
if (map[i].type == E820_RAM && end > mem_end) {
/* RAM off the end - may be partially included */
u64 delta = min(map[i].size, end - mem_end);

map[i].size -= delta;
extra_pages += PFN_DOWN(delta);
map[i].size -= delta;
end -= delta;

end = mem_end;
}
extra_pages += PFN_DOWN(delta);
}

if (end > xen_extra_mem_start)
if (map[i].size > 0 && end > xen_extra_mem_start)
xen_extra_mem_start = end;

/* If region is non-RAM or below mem_end, add what remains */
if ((map[i].type != E820_RAM || map[i].addr < mem_end) &&
map[i].size > 0)
/* Add region if any remains */
if (map[i].size > 0)
e820_add_region(map[i].addr, map[i].size, map[i].type);
}

Expand Down

0 comments on commit c2d0879

Please sign in to comment.