Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 217854
b: refs/heads/master
c: 698bb8d
h: refs/heads/master
v: v3
  • Loading branch information
Jeremy Fitzhardinge committed Oct 22, 2010
1 parent a165417 commit 3943e7c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b5b43ced7a6e79d30df3232b37dc82c5d8dfa843
refs/heads/master: 698bb8d14a5b577b6841acaccdf5095d3b7c7389
32 changes: 32 additions & 0 deletions trunk/arch/x86/xen/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ extern void xen_syscall32_target(void);
/* Amount of extra memory space we add to the e820 ranges */
phys_addr_t xen_extra_mem_start, xen_extra_mem_size;

/*
* The maximum amount of extra memory compared to the base size. The
* main scaling factor is the size of struct page. At extreme ratios
* of base:extra, all the base memory can be filled with page
* structures for the extra memory, leaving no space for anything
* else.
*
* 10x seems like a reasonable balance between scaling flexibility and
* leaving a practically usable system.
*/
#define EXTRA_MEM_RATIO (10)

static __init void xen_add_extra_mem(unsigned long pages)
{
u64 size = (u64)pages * PAGE_SIZE;
Expand Down Expand Up @@ -134,6 +146,7 @@ char * __init xen_memory_setup(void)
int rc;
struct xen_memory_map memmap;
unsigned long extra_pages = 0;
unsigned long extra_limit;
int i;

max_pfn = min(MAX_DOMAIN_PAGES, max_pfn);
Expand Down Expand Up @@ -196,6 +209,25 @@ char * __init xen_memory_setup(void)

extra_pages += xen_return_unused_memory(xen_start_info->nr_pages, &e820);

/*
* Clamp the amount of extra memory to a EXTRA_MEM_RATIO
* factor the base size. On non-highmem systems, the base
* size is the full initial memory allocation; on highmem it
* is limited to the max size of lowmem, so that it doesn't
* get completely filled.
*
* In principle there could be a problem in lowmem systems if
* the initial memory is also very large with respect to
* lowmem, but we won't try to deal with that here.
*/
extra_limit = min(EXTRA_MEM_RATIO * min(max_pfn, PFN_DOWN(MAXMEM)),
max_pfn + extra_pages);

if (extra_limit >= max_pfn)
extra_pages = extra_limit - max_pfn;
else
extra_pages = 0;

xen_add_extra_mem(extra_pages);

return "Xen";
Expand Down

0 comments on commit 3943e7c

Please sign in to comment.