ia64/linux-2.6.18-xen.hg

view drivers/acpi/utilities/utstate.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 * Module Name: utstate - state object support procedures
4 *
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2006, R. Byron Moore
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
44 #include <acpi/acpi.h>
46 #define _COMPONENT ACPI_UTILITIES
47 ACPI_MODULE_NAME("utstate")
49 /*******************************************************************************
50 *
51 * FUNCTION: acpi_ut_create_pkg_state_and_push
52 *
53 * PARAMETERS: Object - Object to be added to the new state
54 * Action - Increment/Decrement
55 * state_list - List the state will be added to
56 *
57 * RETURN: Status
58 *
59 * DESCRIPTION: Create a new state and push it
60 *
61 ******************************************************************************/
62 acpi_status
63 acpi_ut_create_pkg_state_and_push(void *internal_object,
64 void *external_object,
65 u16 index,
66 union acpi_generic_state **state_list)
67 {
68 union acpi_generic_state *state;
70 ACPI_FUNCTION_ENTRY();
72 state =
73 acpi_ut_create_pkg_state(internal_object, external_object, index);
74 if (!state) {
75 return (AE_NO_MEMORY);
76 }
78 acpi_ut_push_generic_state(state_list, state);
79 return (AE_OK);
80 }
82 /*******************************************************************************
83 *
84 * FUNCTION: acpi_ut_push_generic_state
85 *
86 * PARAMETERS: list_head - Head of the state stack
87 * State - State object to push
88 *
89 * RETURN: None
90 *
91 * DESCRIPTION: Push a state object onto a state stack
92 *
93 ******************************************************************************/
95 void
96 acpi_ut_push_generic_state(union acpi_generic_state **list_head,
97 union acpi_generic_state *state)
98 {
99 ACPI_FUNCTION_TRACE(ut_push_generic_state);
101 /* Push the state object onto the front of the list (stack) */
103 state->common.next = *list_head;
104 *list_head = state;
106 return_VOID;
107 }
109 /*******************************************************************************
110 *
111 * FUNCTION: acpi_ut_pop_generic_state
112 *
113 * PARAMETERS: list_head - Head of the state stack
114 *
115 * RETURN: The popped state object
116 *
117 * DESCRIPTION: Pop a state object from a state stack
118 *
119 ******************************************************************************/
121 union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
122 **list_head)
123 {
124 union acpi_generic_state *state;
126 ACPI_FUNCTION_TRACE(ut_pop_generic_state);
128 /* Remove the state object at the head of the list (stack) */
130 state = *list_head;
131 if (state) {
133 /* Update the list head */
135 *list_head = state->common.next;
136 }
138 return_PTR(state);
139 }
141 /*******************************************************************************
142 *
143 * FUNCTION: acpi_ut_create_generic_state
144 *
145 * PARAMETERS: None
146 *
147 * RETURN: The new state object. NULL on failure.
148 *
149 * DESCRIPTION: Create a generic state object. Attempt to obtain one from
150 * the global state cache; If none available, create a new one.
151 *
152 ******************************************************************************/
154 union acpi_generic_state *acpi_ut_create_generic_state(void)
155 {
156 union acpi_generic_state *state;
158 ACPI_FUNCTION_ENTRY();
160 state = acpi_os_acquire_object(acpi_gbl_state_cache);
161 if (state) {
163 /* Initialize */
164 memset(state, 0, sizeof(union acpi_generic_state));
165 state->common.descriptor_type = ACPI_DESC_TYPE_STATE;
166 }
168 return (state);
169 }
171 /*******************************************************************************
172 *
173 * FUNCTION: acpi_ut_create_thread_state
174 *
175 * PARAMETERS: None
176 *
177 * RETURN: New Thread State. NULL on failure
178 *
179 * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
180 * to track per-thread info during method execution
181 *
182 ******************************************************************************/
184 struct acpi_thread_state *acpi_ut_create_thread_state(void)
185 {
186 union acpi_generic_state *state;
188 ACPI_FUNCTION_TRACE(ut_create_thread_state);
190 /* Create the generic state object */
192 state = acpi_ut_create_generic_state();
193 if (!state) {
194 return_PTR(NULL);
195 }
197 /* Init fields specific to the update struct */
199 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_THREAD;
200 state->thread.thread_id = acpi_os_get_thread_id();
202 /* Check for invalid thread ID - zero is very bad, it will break things */
204 if (!state->thread.thread_id) {
205 ACPI_ERROR((AE_INFO, "Invalid zero ID from AcpiOsGetThreadId"));
206 state->thread.thread_id = (acpi_thread_id) 1;
207 }
209 return_PTR((struct acpi_thread_state *)state);
210 }
212 /*******************************************************************************
213 *
214 * FUNCTION: acpi_ut_create_update_state
215 *
216 * PARAMETERS: Object - Initial Object to be installed in the state
217 * Action - Update action to be performed
218 *
219 * RETURN: New state object, null on failure
220 *
221 * DESCRIPTION: Create an "Update State" - a flavor of the generic state used
222 * to update reference counts and delete complex objects such
223 * as packages.
224 *
225 ******************************************************************************/
227 union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
228 *object, u16 action)
229 {
230 union acpi_generic_state *state;
232 ACPI_FUNCTION_TRACE_PTR(ut_create_update_state, object);
234 /* Create the generic state object */
236 state = acpi_ut_create_generic_state();
237 if (!state) {
238 return_PTR(NULL);
239 }
241 /* Init fields specific to the update struct */
243 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_UPDATE;
244 state->update.object = object;
245 state->update.value = action;
247 return_PTR(state);
248 }
250 /*******************************************************************************
251 *
252 * FUNCTION: acpi_ut_create_pkg_state
253 *
254 * PARAMETERS: Object - Initial Object to be installed in the state
255 * Action - Update action to be performed
256 *
257 * RETURN: New state object, null on failure
258 *
259 * DESCRIPTION: Create a "Package State"
260 *
261 ******************************************************************************/
263 union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
264 void *external_object,
265 u16 index)
266 {
267 union acpi_generic_state *state;
269 ACPI_FUNCTION_TRACE_PTR(ut_create_pkg_state, internal_object);
271 /* Create the generic state object */
273 state = acpi_ut_create_generic_state();
274 if (!state) {
275 return_PTR(NULL);
276 }
278 /* Init fields specific to the update struct */
280 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_PACKAGE;
281 state->pkg.source_object = (union acpi_operand_object *)internal_object;
282 state->pkg.dest_object = external_object;
283 state->pkg.index = index;
284 state->pkg.num_packages = 1;
286 return_PTR(state);
287 }
289 /*******************************************************************************
290 *
291 * FUNCTION: acpi_ut_create_control_state
292 *
293 * PARAMETERS: None
294 *
295 * RETURN: New state object, null on failure
296 *
297 * DESCRIPTION: Create a "Control State" - a flavor of the generic state used
298 * to support nested IF/WHILE constructs in the AML.
299 *
300 ******************************************************************************/
302 union acpi_generic_state *acpi_ut_create_control_state(void)
303 {
304 union acpi_generic_state *state;
306 ACPI_FUNCTION_TRACE(ut_create_control_state);
308 /* Create the generic state object */
310 state = acpi_ut_create_generic_state();
311 if (!state) {
312 return_PTR(NULL);
313 }
315 /* Init fields specific to the control struct */
317 state->common.descriptor_type = ACPI_DESC_TYPE_STATE_CONTROL;
318 state->common.state = ACPI_CONTROL_CONDITIONAL_EXECUTING;
320 return_PTR(state);
321 }
323 /*******************************************************************************
324 *
325 * FUNCTION: acpi_ut_delete_generic_state
326 *
327 * PARAMETERS: State - The state object to be deleted
328 *
329 * RETURN: None
330 *
331 * DESCRIPTION: Release a state object to the state cache. NULL state objects
332 * are ignored.
333 *
334 ******************************************************************************/
336 void acpi_ut_delete_generic_state(union acpi_generic_state *state)
337 {
338 ACPI_FUNCTION_TRACE(ut_delete_generic_state);
340 /* Ignore null state */
342 if (state) {
343 (void)acpi_os_release_object(acpi_gbl_state_cache, state);
344 }
345 return_VOID;
346 }