aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/balloon.c
diff options
context:
space:
mode:
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>2011-10-19 17:59:37 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-11-16 12:13:43 -0500
commit72e9cf2ab12ef3e050577ffebdb0c88a28df821d (patch)
tree8b514d680a2af0907705319f078d4f6ec89d03df /drivers/xen/balloon.c
parent5f76d7078ce784916d55fc4e1bb0a42985f085a6 (diff)
xen/balloon: Avoid OOM when requesting highmem
If highmem pages are requested from the balloon on a system without highmem, the implementation of alloc_xenballooned_pages will allocate all available memory trying to find highmem pages to return. Allow low memory to be returned when highmem pages are requested to avoid this loop. Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen/balloon.c')
-rw-r--r--drivers/xen/balloon.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index a767884a6c7a..31ab82fda38a 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -501,7 +501,7 @@ EXPORT_SYMBOL_GPL(balloon_set_new_target);
501 * alloc_xenballooned_pages - get pages that have been ballooned out 501 * alloc_xenballooned_pages - get pages that have been ballooned out
502 * @nr_pages: Number of pages to get 502 * @nr_pages: Number of pages to get
503 * @pages: pages returned 503 * @pages: pages returned
504 * @highmem: highmem or lowmem pages 504 * @highmem: allow highmem pages
505 * @return 0 on success, error otherwise 505 * @return 0 on success, error otherwise
506 */ 506 */
507int alloc_xenballooned_pages(int nr_pages, struct page **pages, bool highmem) 507int alloc_xenballooned_pages(int nr_pages, struct page **pages, bool highmem)
@@ -511,7 +511,7 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages, bool highmem)
511 mutex_lock(&balloon_mutex); 511 mutex_lock(&balloon_mutex);
512 while (pgno < nr_pages) { 512 while (pgno < nr_pages) {
513 page = balloon_retrieve(highmem); 513 page = balloon_retrieve(highmem);
514 if (page && PageHighMem(page) == highmem) { 514 if (page && (highmem || !PageHighMem(page))) {
515 pages[pgno++] = page; 515 pages[pgno++] = page;
516 } else { 516 } else {
517 enum bp_state st; 517 enum bp_state st;