aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/balloon.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/xen/balloon.c')
-rw-r--r--drivers/xen/balloon.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 1a0d8c2a0354..500290b150bb 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -85,13 +85,6 @@ static struct sys_device balloon_sysdev;
85 85
86static int register_balloon(struct sys_device *sysdev); 86static int register_balloon(struct sys_device *sysdev);
87 87
88/*
89 * Protects atomic reservation decrease/increase against concurrent increases.
90 * Also protects non-atomic updates of current_pages and driver_pages, and
91 * balloon lists.
92 */
93static DEFINE_SPINLOCK(balloon_lock);
94
95static struct balloon_stats balloon_stats; 88static struct balloon_stats balloon_stats;
96 89
97/* We increase/decrease in batches which fit in a page */ 90/* We increase/decrease in batches which fit in a page */
@@ -210,7 +203,7 @@ static int increase_reservation(unsigned long nr_pages)
210 if (nr_pages > ARRAY_SIZE(frame_list)) 203 if (nr_pages > ARRAY_SIZE(frame_list))
211 nr_pages = ARRAY_SIZE(frame_list); 204 nr_pages = ARRAY_SIZE(frame_list);
212 205
213 spin_lock_irqsave(&balloon_lock, flags); 206 spin_lock_irqsave(&xen_reservation_lock, flags);
214 207
215 page = balloon_first_page(); 208 page = balloon_first_page();
216 for (i = 0; i < nr_pages; i++) { 209 for (i = 0; i < nr_pages; i++) {
@@ -254,7 +247,7 @@ static int increase_reservation(unsigned long nr_pages)
254 balloon_stats.current_pages += rc; 247 balloon_stats.current_pages += rc;
255 248
256 out: 249 out:
257 spin_unlock_irqrestore(&balloon_lock, flags); 250 spin_unlock_irqrestore(&xen_reservation_lock, flags);
258 251
259 return rc < 0 ? rc : rc != nr_pages; 252 return rc < 0 ? rc : rc != nr_pages;
260} 253}
@@ -299,7 +292,7 @@ static int decrease_reservation(unsigned long nr_pages)
299 kmap_flush_unused(); 292 kmap_flush_unused();
300 flush_tlb_all(); 293 flush_tlb_all();
301 294
302 spin_lock_irqsave(&balloon_lock, flags); 295 spin_lock_irqsave(&xen_reservation_lock, flags);
303 296
304 /* No more mappings: invalidate P2M and add to balloon. */ 297 /* No more mappings: invalidate P2M and add to balloon. */
305 for (i = 0; i < nr_pages; i++) { 298 for (i = 0; i < nr_pages; i++) {
@@ -315,7 +308,7 @@ static int decrease_reservation(unsigned long nr_pages)
315 308
316 balloon_stats.current_pages -= nr_pages; 309 balloon_stats.current_pages -= nr_pages;
317 310
318 spin_unlock_irqrestore(&balloon_lock, flags); 311 spin_unlock_irqrestore(&xen_reservation_lock, flags);
319 312
320 return need_sleep; 313 return need_sleep;
321} 314}