diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2011-05-20 14:06:24 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2011-05-20 14:08:05 -0400 |
commit | 250f972d85effad5b6e10da4bbd877e6a4b503b6 (patch) | |
tree | 007393a6fc6439af7e0121dd99a6f9f9fb8405bc /drivers/xen/balloon.c | |
parent | 7372b0b122af0f6675f3ab65bfd91c8a438e0480 (diff) | |
parent | bbe7b8bef48c567f5ff3f6041c1fb011292e8f12 (diff) |
Merge branch 'timers/urgent' into timers/core
Reason: Get upstream fixes and kfree_rcu which is necessary for a
follow up patch.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/xen/balloon.c')
-rw-r--r-- | drivers/xen/balloon.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index 043af8ad6b60..f54290baa3db 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c | |||
@@ -114,7 +114,6 @@ static void __balloon_append(struct page *page) | |||
114 | if (PageHighMem(page)) { | 114 | if (PageHighMem(page)) { |
115 | list_add_tail(&page->lru, &ballooned_pages); | 115 | list_add_tail(&page->lru, &ballooned_pages); |
116 | balloon_stats.balloon_high++; | 116 | balloon_stats.balloon_high++; |
117 | dec_totalhigh_pages(); | ||
118 | } else { | 117 | } else { |
119 | list_add(&page->lru, &ballooned_pages); | 118 | list_add(&page->lru, &ballooned_pages); |
120 | balloon_stats.balloon_low++; | 119 | balloon_stats.balloon_low++; |
@@ -124,6 +123,8 @@ static void __balloon_append(struct page *page) | |||
124 | static void balloon_append(struct page *page) | 123 | static void balloon_append(struct page *page) |
125 | { | 124 | { |
126 | __balloon_append(page); | 125 | __balloon_append(page); |
126 | if (PageHighMem(page)) | ||
127 | dec_totalhigh_pages(); | ||
127 | totalram_pages--; | 128 | totalram_pages--; |
128 | } | 129 | } |
129 | 130 | ||
@@ -193,7 +194,7 @@ static enum bp_state update_schedule(enum bp_state state) | |||
193 | return BP_EAGAIN; | 194 | return BP_EAGAIN; |
194 | } | 195 | } |
195 | 196 | ||
196 | static unsigned long current_target(void) | 197 | static long current_credit(void) |
197 | { | 198 | { |
198 | unsigned long target = balloon_stats.target_pages; | 199 | unsigned long target = balloon_stats.target_pages; |
199 | 200 | ||
@@ -202,7 +203,7 @@ static unsigned long current_target(void) | |||
202 | balloon_stats.balloon_low + | 203 | balloon_stats.balloon_low + |
203 | balloon_stats.balloon_high); | 204 | balloon_stats.balloon_high); |
204 | 205 | ||
205 | return target; | 206 | return target - balloon_stats.current_pages; |
206 | } | 207 | } |
207 | 208 | ||
208 | static enum bp_state increase_reservation(unsigned long nr_pages) | 209 | static enum bp_state increase_reservation(unsigned long nr_pages) |
@@ -246,7 +247,7 @@ static enum bp_state increase_reservation(unsigned long nr_pages) | |||
246 | set_phys_to_machine(pfn, frame_list[i]); | 247 | set_phys_to_machine(pfn, frame_list[i]); |
247 | 248 | ||
248 | /* Link back into the page tables if not highmem. */ | 249 | /* Link back into the page tables if not highmem. */ |
249 | if (!xen_hvm_domain() && pfn < max_low_pfn) { | 250 | if (xen_pv_domain() && !PageHighMem(page)) { |
250 | int ret; | 251 | int ret; |
251 | ret = HYPERVISOR_update_va_mapping( | 252 | ret = HYPERVISOR_update_va_mapping( |
252 | (unsigned long)__va(pfn << PAGE_SHIFT), | 253 | (unsigned long)__va(pfn << PAGE_SHIFT), |
@@ -293,7 +294,7 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) | |||
293 | 294 | ||
294 | scrub_page(page); | 295 | scrub_page(page); |
295 | 296 | ||
296 | if (!xen_hvm_domain() && !PageHighMem(page)) { | 297 | if (xen_pv_domain() && !PageHighMem(page)) { |
297 | ret = HYPERVISOR_update_va_mapping( | 298 | ret = HYPERVISOR_update_va_mapping( |
298 | (unsigned long)__va(pfn << PAGE_SHIFT), | 299 | (unsigned long)__va(pfn << PAGE_SHIFT), |
299 | __pte_ma(0), 0); | 300 | __pte_ma(0), 0); |
@@ -337,7 +338,7 @@ static void balloon_process(struct work_struct *work) | |||
337 | mutex_lock(&balloon_mutex); | 338 | mutex_lock(&balloon_mutex); |
338 | 339 | ||
339 | do { | 340 | do { |
340 | credit = current_target() - balloon_stats.current_pages; | 341 | credit = current_credit(); |
341 | 342 | ||
342 | if (credit > 0) | 343 | if (credit > 0) |
343 | state = increase_reservation(credit); | 344 | state = increase_reservation(credit); |
@@ -420,7 +421,7 @@ void free_xenballooned_pages(int nr_pages, struct page** pages) | |||
420 | } | 421 | } |
421 | 422 | ||
422 | /* The balloon may be too large now. Shrink it if needed. */ | 423 | /* The balloon may be too large now. Shrink it if needed. */ |
423 | if (current_target() != balloon_stats.current_pages) | 424 | if (current_credit()) |
424 | schedule_delayed_work(&balloon_worker, 0); | 425 | schedule_delayed_work(&balloon_worker, 0); |
425 | 426 | ||
426 | mutex_unlock(&balloon_mutex); | 427 | mutex_unlock(&balloon_mutex); |
@@ -429,7 +430,7 @@ EXPORT_SYMBOL(free_xenballooned_pages); | |||
429 | 430 | ||
430 | static int __init balloon_init(void) | 431 | static int __init balloon_init(void) |
431 | { | 432 | { |
432 | unsigned long pfn, nr_pages, extra_pfn_end; | 433 | unsigned long pfn, extra_pfn_end; |
433 | struct page *page; | 434 | struct page *page; |
434 | 435 | ||
435 | if (!xen_domain()) | 436 | if (!xen_domain()) |
@@ -437,11 +438,7 @@ static int __init balloon_init(void) | |||
437 | 438 | ||
438 | pr_info("xen/balloon: Initialising balloon driver.\n"); | 439 | pr_info("xen/balloon: Initialising balloon driver.\n"); |
439 | 440 | ||
440 | if (xen_pv_domain()) | 441 | balloon_stats.current_pages = xen_pv_domain() ? min(xen_start_info->nr_pages, max_pfn) : max_pfn; |
441 | nr_pages = xen_start_info->nr_pages; | ||
442 | else | ||
443 | nr_pages = max_pfn; | ||
444 | balloon_stats.current_pages = min(nr_pages, max_pfn); | ||
445 | balloon_stats.target_pages = balloon_stats.current_pages; | 442 | balloon_stats.target_pages = balloon_stats.current_pages; |
446 | balloon_stats.balloon_low = 0; | 443 | balloon_stats.balloon_low = 0; |
447 | balloon_stats.balloon_high = 0; | 444 | balloon_stats.balloon_high = 0; |
@@ -466,7 +463,7 @@ static int __init balloon_init(void) | |||
466 | pfn < extra_pfn_end; | 463 | pfn < extra_pfn_end; |
467 | pfn++) { | 464 | pfn++) { |
468 | page = pfn_to_page(pfn); | 465 | page = pfn_to_page(pfn); |
469 | /* totalram_pages doesn't include the boot-time | 466 | /* totalram_pages and totalhigh_pages do not include the boot-time |
470 | balloon extension, so don't subtract from it. */ | 467 | balloon extension, so don't subtract from it. */ |
471 | __balloon_append(page); | 468 | __balloon_append(page); |
472 | } | 469 | } |