Commit 19001c8c5bfa032ed45b10dfe48e355f5df88c61
Committed by
Konrad Rzeszutek Wilk
1 parent
7347b4082e
Exists in
master
and in
7 other branches
xen: Rename the balloon lock
* xen_create_contiguous_region needs access to the balloon lock to ensure memory doesn't change under its feet, so expose the balloon lock * Change the name of the lock to xen_reservation_lock, to imply it's now less-specific usage. [ Impact: cleanup ] Signed-off-by: Alex Nixon <alex.nixon@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Showing 3 changed files with 19 additions and 11 deletions Side-by-side Diff
arch/x86/xen/mmu.c
... | ... | @@ -70,6 +70,13 @@ |
70 | 70 | |
71 | 71 | #define MMU_UPDATE_HISTO 30 |
72 | 72 | |
73 | +/* | |
74 | + * Protects atomic reservation decrease/increase against concurrent increases. | |
75 | + * Also protects non-atomic updates of current_pages and driver_pages, and | |
76 | + * balloon lists. | |
77 | + */ | |
78 | +DEFINE_SPINLOCK(xen_reservation_lock); | |
79 | + | |
73 | 80 | #ifdef CONFIG_XEN_DEBUG_FS |
74 | 81 | |
75 | 82 | static struct { |
drivers/xen/balloon.c
... | ... | @@ -85,13 +85,6 @@ |
85 | 85 | |
86 | 86 | static 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 | - */ | |
93 | -static DEFINE_SPINLOCK(balloon_lock); | |
94 | - | |
95 | 88 | static struct balloon_stats balloon_stats; |
96 | 89 | |
97 | 90 | /* We increase/decrease in batches which fit in a page */ |
... | ... | @@ -210,7 +203,7 @@ |
210 | 203 | if (nr_pages > ARRAY_SIZE(frame_list)) |
211 | 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 | 208 | page = balloon_first_page(); |
216 | 209 | for (i = 0; i < nr_pages; i++) { |
... | ... | @@ -254,7 +247,7 @@ |
254 | 247 | balloon_stats.current_pages += rc; |
255 | 248 | |
256 | 249 | out: |
257 | - spin_unlock_irqrestore(&balloon_lock, flags); | |
250 | + spin_unlock_irqrestore(&xen_reservation_lock, flags); | |
258 | 251 | |
259 | 252 | return rc < 0 ? rc : rc != nr_pages; |
260 | 253 | } |
... | ... | @@ -299,7 +292,7 @@ |
299 | 292 | kmap_flush_unused(); |
300 | 293 | flush_tlb_all(); |
301 | 294 | |
302 | - spin_lock_irqsave(&balloon_lock, flags); | |
295 | + spin_lock_irqsave(&xen_reservation_lock, flags); | |
303 | 296 | |
304 | 297 | /* No more mappings: invalidate P2M and add to balloon. */ |
305 | 298 | for (i = 0; i < nr_pages; i++) { |
... | ... | @@ -315,7 +308,7 @@ |
315 | 308 | |
316 | 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 | 313 | return need_sleep; |
321 | 314 | } |
include/xen/interface/memory.h
... | ... | @@ -9,6 +9,8 @@ |
9 | 9 | #ifndef __XEN_PUBLIC_MEMORY_H__ |
10 | 10 | #define __XEN_PUBLIC_MEMORY_H__ |
11 | 11 | |
12 | +#include <linux/spinlock.h> | |
13 | + | |
12 | 14 | /* |
13 | 15 | * Increase or decrease the specified domain's memory reservation. Returns a |
14 | 16 | * -ve errcode on failure, or the # extents successfully allocated or freed. |
... | ... | @@ -142,5 +144,11 @@ |
142 | 144 | }; |
143 | 145 | DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list); |
144 | 146 | |
147 | + | |
148 | +/* | |
149 | + * Prevent the balloon driver from changing the memory reservation | |
150 | + * during a driver critical region. | |
151 | + */ | |
152 | +extern spinlock_t xen_reservation_lock; | |
145 | 153 | #endif /* __XEN_PUBLIC_MEMORY_H__ */ |