diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 1e0a317..49be2a9 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -90,6 +90,8 @@ static DEFINE_MUTEX(balloon_mutex); struct balloon_stats balloon_stats; EXPORT_SYMBOL_GPL(balloon_stats); +bool has_additional_memory = true; + /* We increase/decrease in batches which fit in a page */ static xen_pfn_t frame_list[PAGE_SIZE / sizeof(unsigned long)]; static DEFINE_PER_CPU(struct page *, balloon_scratch_page); @@ -223,6 +225,9 @@ static enum bp_state reserve_additional_memory(long credit) u64 hotplug_start_paddr; unsigned long balloon_hotplug = credit; + if (!has_additional_memory) + return BP_ECANCELED; + hotplug_start_paddr = PFN_PHYS(SECTION_ALIGN_UP(max_pfn)); balloon_hotplug = round_up(balloon_hotplug, PAGES_PER_SECTION); nid = memory_add_physaddr_to_nid(hotplug_start_paddr); @@ -231,6 +236,7 @@ static enum bp_state reserve_additional_memory(long credit) if (rc) { pr_warn("Cannot add additional memory (%i)\n", rc); + has_additional_memory = false; return BP_ECANCELED; } @@ -482,7 +488,8 @@ static void balloon_process(struct work_struct *work) if (credit < 0) state = decrease_reservation(-credit, GFP_BALLOON); - state = update_schedule(state); + if (state != BP_ECANCELED) + state = update_schedule(state); #ifndef CONFIG_PREEMPT if (need_resched())