ia64/linux-2.6.18-xen.hg

view drivers/acpi/cm_sbs.c @ 897:329ea0ccb344

balloon: try harder to balloon up under memory pressure.

Currently if the balloon driver is unable to increase the guest's
reservation it assumes the failure was due to reaching its full
allocation, gives up on the ballooning operation and records the limit
it reached as the "hard limit". The driver will not try again until
the target is set again (even to the same value).

However it is possible that ballooning has in fact failed due to
memory pressure in the host and therefore it is desirable to keep
attempting to reach the target in case memory becomes available. The
most likely scenario is that some guests are ballooning down while
others are ballooning up and therefore there is temporary memory
pressure while things stabilise. You would not expect a well behaved
toolstack to ask a domain to balloon to more than its allocation nor
would you expect it to deliberately over-commit memory by setting
balloon targets which exceed the total host memory.

This patch drops the concept of a hard limit and causes the balloon
driver to retry increasing the reservation on a timer in the same
manner as when decreasing the reservation.

Also if we partially succeed in increasing the reservation
(i.e. receive less pages than we asked for) then we may as well keep
those pages rather than returning them to Xen.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 05 14:01:20 2009 +0100 (2009-06-05)
parents 831230e53067
children
line source
1 /*
2 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or (at
7 * your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 *
18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 */
21 #include <linux/kernel.h>
22 #include <linux/module.h>
23 #include <linux/init.h>
24 #include <linux/acpi.h>
25 #include <linux/types.h>
26 #include <linux/proc_fs.h>
27 #include <linux/seq_file.h>
28 #include <acpi/acpi_bus.h>
29 #include <acpi/acpi_drivers.h>
30 #include <acpi/acmacros.h>
31 #include <acpi/actypes.h>
32 #include <acpi/acutils.h>
34 ACPI_MODULE_NAME("cm_sbs")
35 #define ACPI_AC_CLASS "ac_adapter"
36 #define ACPI_BATTERY_CLASS "battery"
37 #define ACPI_SBS_COMPONENT 0x00080000
38 #define _COMPONENT ACPI_SBS_COMPONENT
39 static struct proc_dir_entry *acpi_ac_dir;
40 static struct proc_dir_entry *acpi_battery_dir;
42 static DEFINE_MUTEX(cm_sbs_mutex);
44 static int lock_ac_dir_cnt;
45 static int lock_battery_dir_cnt;
47 struct proc_dir_entry *acpi_lock_ac_dir(void)
48 {
49 mutex_lock(&cm_sbs_mutex);
50 if (!acpi_ac_dir)
51 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
52 if (acpi_ac_dir) {
53 lock_ac_dir_cnt++;
54 } else {
55 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
56 "Cannot create %s\n", ACPI_AC_CLASS));
57 }
58 mutex_unlock(&cm_sbs_mutex);
59 return acpi_ac_dir;
60 }
61 EXPORT_SYMBOL(acpi_lock_ac_dir);
63 void acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir_param)
64 {
65 mutex_lock(&cm_sbs_mutex);
66 if (acpi_ac_dir_param)
67 lock_ac_dir_cnt--;
68 if (lock_ac_dir_cnt == 0 && acpi_ac_dir_param && acpi_ac_dir) {
69 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
70 acpi_ac_dir = 0;
71 }
72 mutex_unlock(&cm_sbs_mutex);
73 }
74 EXPORT_SYMBOL(acpi_unlock_ac_dir);
76 struct proc_dir_entry *acpi_lock_battery_dir(void)
77 {
78 mutex_lock(&cm_sbs_mutex);
79 if (!acpi_battery_dir) {
80 acpi_battery_dir =
81 proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
82 }
83 if (acpi_battery_dir) {
84 lock_battery_dir_cnt++;
85 } else {
86 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
87 "Cannot create %s\n", ACPI_BATTERY_CLASS));
88 }
89 mutex_unlock(&cm_sbs_mutex);
90 return acpi_battery_dir;
91 }
92 EXPORT_SYMBOL(acpi_lock_battery_dir);
94 void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir_param)
95 {
96 mutex_lock(&cm_sbs_mutex);
97 if (acpi_battery_dir_param)
98 lock_battery_dir_cnt--;
99 if (lock_battery_dir_cnt == 0 && acpi_battery_dir_param
100 && acpi_battery_dir) {
101 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
102 acpi_battery_dir = 0;
103 }
104 mutex_unlock(&cm_sbs_mutex);
105 return;
106 }
107 EXPORT_SYMBOL(acpi_unlock_battery_dir);
109 static int __init acpi_cm_sbs_init(void)
110 {
111 return 0;
112 }
113 subsys_initcall(acpi_cm_sbs_init);