Skip to content

Commit 72e9cf2

Browse files
dgdegraafkonradwilk
authored andcommitted
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>
1 parent 5f76d70 commit 72e9cf2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/xen/balloon.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ EXPORT_SYMBOL_GPL(balloon_set_new_target);
501501
* alloc_xenballooned_pages - get pages that have been ballooned out
502502
* @nr_pages: Number of pages to get
503503
* @pages: pages returned
504-
* @highmem: highmem or lowmem pages
504+
* @highmem: allow highmem pages
505505
* @return 0 on success, error otherwise
506506
*/
507507
int 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)
511511
mutex_lock(&balloon_mutex);
512512
while (pgno < nr_pages) {
513513
page = balloon_retrieve(highmem);
514-
if (page && PageHighMem(page) == highmem) {
514+
if (page && (highmem || !PageHighMem(page))) {
515515
pages[pgno++] = page;
516516
} else {
517517
enum bp_state st;

0 commit comments

Comments
 (0)