diff options
Diffstat (limited to 'drivers/xen/balloon.c')
-rw-r--r-- | drivers/xen/balloon.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 37a36c6b9f93..4e11de6cde81 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c | |||
@@ -535,8 +535,15 @@ static void balloon_process(struct work_struct *work) | |||
535 | state = reserve_additional_memory(); | 535 | state = reserve_additional_memory(); |
536 | } | 536 | } |
537 | 537 | ||
538 | if (credit < 0) | 538 | if (credit < 0) { |
539 | state = decrease_reservation(-credit, GFP_BALLOON); | 539 | long n_pages; |
540 | |||
541 | n_pages = min(-credit, si_mem_available()); | ||
542 | state = decrease_reservation(n_pages, GFP_BALLOON); | ||
543 | if (state == BP_DONE && n_pages != -credit && | ||
544 | n_pages < totalreserve_pages) | ||
545 | state = BP_EAGAIN; | ||
546 | } | ||
540 | 547 | ||
541 | state = update_schedule(state); | 548 | state = update_schedule(state); |
542 | 549 | ||
@@ -575,6 +582,9 @@ static int add_ballooned_pages(int nr_pages) | |||
575 | } | 582 | } |
576 | } | 583 | } |
577 | 584 | ||
585 | if (si_mem_available() < nr_pages) | ||
586 | return -ENOMEM; | ||
587 | |||
578 | st = decrease_reservation(nr_pages, GFP_USER); | 588 | st = decrease_reservation(nr_pages, GFP_USER); |
579 | if (st != BP_DONE) | 589 | if (st != BP_DONE) |
580 | return -ENOMEM; | 590 | return -ENOMEM; |
@@ -707,7 +717,7 @@ static int __init balloon_init(void) | |||
707 | balloon_stats.schedule_delay = 1; | 717 | balloon_stats.schedule_delay = 1; |
708 | balloon_stats.max_schedule_delay = 32; | 718 | balloon_stats.max_schedule_delay = 32; |
709 | balloon_stats.retry_count = 1; | 719 | balloon_stats.retry_count = 1; |
710 | balloon_stats.max_retry_count = RETRY_UNLIMITED; | 720 | balloon_stats.max_retry_count = 4; |
711 | 721 | ||
712 | #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG | 722 | #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG |
713 | set_online_page_callback(&xen_online_page); | 723 | set_online_page_callback(&xen_online_page); |