balloon.c (a1078e821b605813b63bf6bca414a85f804d5c66) balloon.c (eec4844fae7c033a0c1fc1eb3b8517aeb8b6cc49)
1/******************************************************************************
2 * Xen balloon driver - enables returning/claiming memory to/from Xen.
3 *
4 * Copyright (c) 2003, B Dragovic
5 * Copyright (c) 2003-2004, M Williamson, K Fraser
6 * Copyright (c) 2005 Dan M. Smith, IBM Corporation
7 * Copyright (c) 2010 Daniel Kiper
8 *

--- 63 unchanged lines hidden (view full) ---

72#include <xen/features.h>
73#include <xen/page.h>
74#include <xen/mem-reservation.h>
75
76static int xen_hotplug_unpopulated;
77
78#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
79
1/******************************************************************************
2 * Xen balloon driver - enables returning/claiming memory to/from Xen.
3 *
4 * Copyright (c) 2003, B Dragovic
5 * Copyright (c) 2003-2004, M Williamson, K Fraser
6 * Copyright (c) 2005 Dan M. Smith, IBM Corporation
7 * Copyright (c) 2010 Daniel Kiper
8 *

--- 63 unchanged lines hidden (view full) ---

72#include <xen/features.h>
73#include <xen/page.h>
74#include <xen/mem-reservation.h>
75
76static int xen_hotplug_unpopulated;
77
78#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
79
80static int zero;
81static int one = 1;
82
83static struct ctl_table balloon_table[] = {
84 {
85 .procname = "hotplug_unpopulated",
86 .data = &xen_hotplug_unpopulated,
87 .maxlen = sizeof(int),
88 .mode = 0644,
89 .proc_handler = proc_dointvec_minmax,
80static struct ctl_table balloon_table[] = {
81 {
82 .procname = "hotplug_unpopulated",
83 .data = &xen_hotplug_unpopulated,
84 .maxlen = sizeof(int),
85 .mode = 0644,
86 .proc_handler = proc_dointvec_minmax,
90 .extra1 = &zero,
91 .extra2 = &one,
87 .extra1 = SYSCTL_ZERO,
88 .extra2 = SYSCTL_ONE,
92 },
93 { }
94};
95
96static struct ctl_table balloon_root[] = {
97 {
98 .procname = "balloon",
99 .mode = 0555,

--- 433 unchanged lines hidden (view full) ---

533
534 if (credit > 0) {
535 if (balloon_is_inflated())
536 state = increase_reservation(credit);
537 else
538 state = reserve_additional_memory();
539 }
540
89 },
90 { }
91};
92
93static struct ctl_table balloon_root[] = {
94 {
95 .procname = "balloon",
96 .mode = 0555,

--- 433 unchanged lines hidden (view full) ---

530
531 if (credit > 0) {
532 if (balloon_is_inflated())
533 state = increase_reservation(credit);
534 else
535 state = reserve_additional_memory();
536 }
537
541 if (credit < 0) {
542 long n_pages;
538 if (credit < 0)
539 state = decrease_reservation(-credit, GFP_BALLOON);
543
540
544 n_pages = min(-credit, si_mem_available());
545 state = decrease_reservation(n_pages, GFP_BALLOON);
546 if (state == BP_DONE && n_pages != -credit &&
547 n_pages < totalreserve_pages)
548 state = BP_EAGAIN;
549 }
550
551 state = update_schedule(state);
552
553 mutex_unlock(&balloon_mutex);
554
555 cond_resched();
556
557 } while (credit && state == BP_DONE);
558

--- 21 unchanged lines hidden (view full) ---

580 mutex_unlock(&balloon_mutex);
581 wait_event(balloon_wq,
582 !list_empty(&ballooned_pages));
583 mutex_lock(&balloon_mutex);
584 return 0;
585 }
586 }
587
541 state = update_schedule(state);
542
543 mutex_unlock(&balloon_mutex);
544
545 cond_resched();
546
547 } while (credit && state == BP_DONE);
548

--- 21 unchanged lines hidden (view full) ---

570 mutex_unlock(&balloon_mutex);
571 wait_event(balloon_wq,
572 !list_empty(&ballooned_pages));
573 mutex_lock(&balloon_mutex);
574 return 0;
575 }
576 }
577
588 if (si_mem_available() < nr_pages)
589 return -ENOMEM;
590
591 st = decrease_reservation(nr_pages, GFP_USER);
592 if (st != BP_DONE)
593 return -ENOMEM;
594
595 return 0;
596}
597
598/**

--- 116 unchanged lines hidden (view full) ---

715 balloon_stats.target_pages = balloon_stats.current_pages;
716 balloon_stats.balloon_low = 0;
717 balloon_stats.balloon_high = 0;
718 balloon_stats.total_pages = balloon_stats.current_pages;
719
720 balloon_stats.schedule_delay = 1;
721 balloon_stats.max_schedule_delay = 32;
722 balloon_stats.retry_count = 1;
578 st = decrease_reservation(nr_pages, GFP_USER);
579 if (st != BP_DONE)
580 return -ENOMEM;
581
582 return 0;
583}
584
585/**

--- 116 unchanged lines hidden (view full) ---

702 balloon_stats.target_pages = balloon_stats.current_pages;
703 balloon_stats.balloon_low = 0;
704 balloon_stats.balloon_high = 0;
705 balloon_stats.total_pages = balloon_stats.current_pages;
706
707 balloon_stats.schedule_delay = 1;
708 balloon_stats.max_schedule_delay = 32;
709 balloon_stats.retry_count = 1;
723 balloon_stats.max_retry_count = 4;
710 balloon_stats.max_retry_count = RETRY_UNLIMITED;
724
725#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
726 set_online_page_callback(&xen_online_page);
727 register_memory_notifier(&xen_memory_nb);
728 register_sysctl_table(xen_root);
729#endif
730
731#ifdef CONFIG_XEN_PV

--- 20 unchanged lines hidden ---
711
712#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
713 set_online_page_callback(&xen_online_page);
714 register_memory_notifier(&xen_memory_nb);
715 register_sysctl_table(xen_root);
716#endif
717
718#ifdef CONFIG_XEN_PV

--- 20 unchanged lines hidden ---