ia64/linux-2.6.18-xen.hg

view arch/mips/basler/excite/excite_prom.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 * Copyright (C) 2004, 2005 by Thomas Koeller (thomas.koeller@baslerweb.com)
3 * Based on the PMC-Sierra Yosemite board support by Ralf Baechle and
4 * Manish Lachwani.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
21 #include <linux/init.h>
22 #include <linux/sched.h>
23 #include <linux/mm.h>
24 #include <linux/delay.h>
25 #include <linux/smp.h>
26 #include <linux/module.h>
27 #include <asm/io.h>
28 #include <asm/pgtable.h>
29 #include <asm/processor.h>
30 #include <asm/reboot.h>
31 #include <asm/system.h>
32 #include <asm/bootinfo.h>
33 #include <asm/string.h>
35 #include <excite.h>
37 /* This struct is used by Redboot to pass arguments to the kernel */
38 typedef struct
39 {
40 char *name;
41 char *val;
42 } t_env_var;
44 struct parmblock {
45 t_env_var memsize;
46 t_env_var modetty0;
47 t_env_var ethaddr;
48 t_env_var env_end;
49 char *argv[2];
50 char text[0];
51 };
53 static unsigned int prom_argc;
54 static const char ** prom_argv;
55 static const t_env_var * prom_env;
57 static void prom_halt(void) __attribute__((noreturn));
58 static void prom_exit(void) __attribute__((noreturn));
62 const char *get_system_type(void)
63 {
64 return "Basler eXcite";
65 }
67 /*
68 * Halt the system
69 */
70 static void prom_halt(void)
71 {
72 printk(KERN_NOTICE "\n** System halted.\n");
73 while (1)
74 asm volatile (
75 "\t.set\tmips3\n"
76 "\twait\n"
77 "\t.set\tmips0\n"
78 );
79 }
81 /*
82 * Reset the CPU and re-enter Redboot
83 */
84 static void prom_exit(void)
85 {
86 unsigned int i;
87 volatile unsigned char * const flg =
88 (volatile unsigned char *) (EXCITE_ADDR_FPGA + EXCITE_FPGA_DPR);
90 /* Clear the watchdog reset flag, set the reboot flag */
91 *flg &= ~0x01;
92 *flg |= 0x80;
94 for (i = 0; i < 10; i++) {
95 *(volatile unsigned char *) (EXCITE_ADDR_FPGA + EXCITE_FPGA_SYSCTL) = 0x02;
96 iob();
97 mdelay(1000);
98 }
100 printk(KERN_NOTICE "Reset failed\n");
101 prom_halt();
102 }
104 static const char __init *prom_getenv(char *name)
105 {
106 const t_env_var * p;
107 for (p = prom_env; p->name != NULL; p++)
108 if(strcmp(name, p->name) == 0)
109 break;
110 return p->val;
111 }
113 /*
114 * Init routine which accepts the variables from Redboot
115 */
116 void __init prom_init(void)
117 {
118 const struct parmblock * const pb = (struct parmblock *) fw_arg2;
120 prom_argc = fw_arg0;
121 prom_argv = (const char **) fw_arg1;
122 prom_env = &pb->memsize;
124 /* Callbacks for halt, restart */
125 _machine_restart = (void (*)(char *)) prom_exit;
126 _machine_halt = prom_halt;
128 #ifdef CONFIG_32BIT
129 /* copy command line */
130 strcpy(arcs_cmdline, prom_argv[1]);
131 memsize = simple_strtol(prom_getenv("memsize"), NULL, 16);
132 strcpy(modetty, prom_getenv("modetty0"));
133 #endif /* CONFIG_32BIT */
135 #ifdef CONFIG_64BIT
136 # error 64 bit support not implemented
137 #endif /* CONFIG_64BIT */
139 mips_machgroup = MACH_GROUP_TITAN;
140 mips_machtype = MACH_TITAN_EXCITE;
141 }
143 /* This is called from free_initmem(), so we need to provide it */
144 void __init prom_free_prom_memory(void)
145 {
146 /* Nothing to do */
147 }