Xen balloon: fix totalram_pages counting.

Change totalram_pages when a single page is added/removed to the
ballooned list. This avoid totalram_pages to be set erroneously to
max_pfn at boot.

Signed-off-by: Gianluca Guida <gianluca.guida@citrix.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Stable Kernel <stable@kernel.org>

authored by

Gianluca Guida and committed by
Jeremy Fitzhardinge
3d65c948 b4606f21

+4 -3
+4 -3
drivers/xen/balloon.c
··· 136 list_add(&page->lru, &ballooned_pages); 137 balloon_stats.balloon_low++; 138 } 139 } 140 141 /* balloon_retrieve: rescue a page from the balloon, if it is not empty. */ ··· 157 } 158 else 159 balloon_stats.balloon_low--; 160 161 return page; 162 } ··· 264 } 265 266 balloon_stats.current_pages += nr_pages; 267 - totalram_pages = balloon_stats.current_pages; 268 269 out: 270 spin_unlock_irqrestore(&balloon_lock, flags); ··· 326 BUG_ON(ret != nr_pages); 327 328 balloon_stats.current_pages -= nr_pages; 329 - totalram_pages = balloon_stats.current_pages; 330 331 spin_unlock_irqrestore(&balloon_lock, flags); 332 ··· 424 pr_info("xen_balloon: Initialising balloon driver.\n"); 425 426 balloon_stats.current_pages = min(xen_start_info->nr_pages, max_pfn); 427 - totalram_pages = balloon_stats.current_pages; 428 balloon_stats.target_pages = balloon_stats.current_pages; 429 balloon_stats.balloon_low = 0; 430 balloon_stats.balloon_high = 0;
··· 136 list_add(&page->lru, &ballooned_pages); 137 balloon_stats.balloon_low++; 138 } 139 + 140 + totalram_pages--; 141 } 142 143 /* balloon_retrieve: rescue a page from the balloon, if it is not empty. */ ··· 155 } 156 else 157 balloon_stats.balloon_low--; 158 + 159 + totalram_pages++; 160 161 return page; 162 } ··· 260 } 261 262 balloon_stats.current_pages += nr_pages; 263 264 out: 265 spin_unlock_irqrestore(&balloon_lock, flags); ··· 323 BUG_ON(ret != nr_pages); 324 325 balloon_stats.current_pages -= nr_pages; 326 327 spin_unlock_irqrestore(&balloon_lock, flags); 328 ··· 422 pr_info("xen_balloon: Initialising balloon driver.\n"); 423 424 balloon_stats.current_pages = min(xen_start_info->nr_pages, max_pfn); 425 balloon_stats.target_pages = balloon_stats.current_pages; 426 balloon_stats.balloon_low = 0; 427 balloon_stats.balloon_high = 0;