ia64/linux-2.6.18-xen.hg

annotate arch/sparc/prom/ranges.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
rev   line source
ian@0 1 /* $Id: ranges.c,v 1.15 2001/12/19 00:29:51 davem Exp $
ian@0 2 * ranges.c: Handle ranges in newer proms for obio/sbus.
ian@0 3 *
ian@0 4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
ian@0 5 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
ian@0 6 */
ian@0 7
ian@0 8 #include <linux/init.h>
ian@0 9 #include <asm/openprom.h>
ian@0 10 #include <asm/oplib.h>
ian@0 11 #include <asm/types.h>
ian@0 12 #include <asm/sbus.h>
ian@0 13 #include <asm/system.h>
ian@0 14
ian@0 15 struct linux_prom_ranges promlib_obio_ranges[PROMREG_MAX];
ian@0 16 int num_obio_ranges;
ian@0 17
ian@0 18 /* Adjust register values based upon the ranges parameters. */
ian@0 19 static void
ian@0 20 prom_adjust_regs(struct linux_prom_registers *regp, int nregs,
ian@0 21 struct linux_prom_ranges *rangep, int nranges)
ian@0 22 {
ian@0 23 int regc, rngc;
ian@0 24
ian@0 25 for (regc = 0; regc < nregs; regc++) {
ian@0 26 for (rngc = 0; rngc < nranges; rngc++)
ian@0 27 if (regp[regc].which_io == rangep[rngc].ot_child_space)
ian@0 28 break; /* Fount it */
ian@0 29 if (rngc == nranges) /* oops */
ian@0 30 prom_printf("adjust_regs: Could not find range with matching bus type...\n");
ian@0 31 regp[regc].which_io = rangep[rngc].ot_parent_space;
ian@0 32 regp[regc].phys_addr -= rangep[rngc].ot_child_base;
ian@0 33 regp[regc].phys_addr += rangep[rngc].ot_parent_base;
ian@0 34 }
ian@0 35 }
ian@0 36
ian@0 37 void
ian@0 38 prom_adjust_ranges(struct linux_prom_ranges *ranges1, int nranges1,
ian@0 39 struct linux_prom_ranges *ranges2, int nranges2)
ian@0 40 {
ian@0 41 int rng1c, rng2c;
ian@0 42
ian@0 43 for(rng1c=0; rng1c < nranges1; rng1c++) {
ian@0 44 for(rng2c=0; rng2c < nranges2; rng2c++)
ian@0 45 if(ranges1[rng1c].ot_parent_space == ranges2[rng2c].ot_child_space &&
ian@0 46 ranges1[rng1c].ot_parent_base >= ranges2[rng2c].ot_child_base &&
ian@0 47 ranges2[rng2c].ot_child_base + ranges2[rng2c].or_size - ranges1[rng1c].ot_parent_base > 0U)
ian@0 48 break;
ian@0 49 if(rng2c == nranges2) /* oops */
ian@0 50 prom_printf("adjust_ranges: Could not find matching bus type...\n");
ian@0 51 else if (ranges1[rng1c].ot_parent_base + ranges1[rng1c].or_size > ranges2[rng2c].ot_child_base + ranges2[rng2c].or_size)
ian@0 52 ranges1[rng1c].or_size =
ian@0 53 ranges2[rng2c].ot_child_base + ranges2[rng2c].or_size - ranges1[rng1c].ot_parent_base;
ian@0 54 ranges1[rng1c].ot_parent_space = ranges2[rng2c].ot_parent_space;
ian@0 55 ranges1[rng1c].ot_parent_base += ranges2[rng2c].ot_parent_base;
ian@0 56 }
ian@0 57 }
ian@0 58
ian@0 59 /* Apply probed obio ranges to registers passed, if no ranges return. */
ian@0 60 void
ian@0 61 prom_apply_obio_ranges(struct linux_prom_registers *regs, int nregs)
ian@0 62 {
ian@0 63 if(num_obio_ranges)
ian@0 64 prom_adjust_regs(regs, nregs, promlib_obio_ranges, num_obio_ranges);
ian@0 65 }
ian@0 66
ian@0 67 void __init prom_ranges_init(void)
ian@0 68 {
ian@0 69 int node, obio_node;
ian@0 70 int success;
ian@0 71
ian@0 72 num_obio_ranges = 0;
ian@0 73
ian@0 74 /* Check for obio and sbus ranges. */
ian@0 75 node = prom_getchild(prom_root_node);
ian@0 76 obio_node = prom_searchsiblings(node, "obio");
ian@0 77
ian@0 78 if(obio_node) {
ian@0 79 success = prom_getproperty(obio_node, "ranges",
ian@0 80 (char *) promlib_obio_ranges,
ian@0 81 sizeof(promlib_obio_ranges));
ian@0 82 if(success != -1)
ian@0 83 num_obio_ranges = (success/sizeof(struct linux_prom_ranges));
ian@0 84 }
ian@0 85
ian@0 86 if(num_obio_ranges)
ian@0 87 prom_printf("PROMLIB: obio_ranges %d\n", num_obio_ranges);
ian@0 88
ian@0 89 return;
ian@0 90 }
ian@0 91
ian@0 92 void
ian@0 93 prom_apply_generic_ranges (int node, int parent, struct linux_prom_registers *regs, int nregs)
ian@0 94 {
ian@0 95 int success;
ian@0 96 int num_ranges;
ian@0 97 struct linux_prom_ranges ranges[PROMREG_MAX];
ian@0 98
ian@0 99 success = prom_getproperty(node, "ranges",
ian@0 100 (char *) ranges,
ian@0 101 sizeof (ranges));
ian@0 102 if (success != -1) {
ian@0 103 num_ranges = (success/sizeof(struct linux_prom_ranges));
ian@0 104 if (parent) {
ian@0 105 struct linux_prom_ranges parent_ranges[PROMREG_MAX];
ian@0 106 int num_parent_ranges;
ian@0 107
ian@0 108 success = prom_getproperty(parent, "ranges",
ian@0 109 (char *) parent_ranges,
ian@0 110 sizeof (parent_ranges));
ian@0 111 if (success != -1) {
ian@0 112 num_parent_ranges = (success/sizeof(struct linux_prom_ranges));
ian@0 113 prom_adjust_ranges (ranges, num_ranges, parent_ranges, num_parent_ranges);
ian@0 114 }
ian@0 115 }
ian@0 116 prom_adjust_regs(regs, nregs, ranges, num_ranges);
ian@0 117 }
ian@0 118 }