ia64/linux-2.6.18-xen.hg

view drivers/mtd/maps/cfi_flagadm.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 © 2001 Flaga hf. Medical Devices, Kári Davíðsson <kd@flaga.is>
3 *
4 * $Id: cfi_flagadm.c,v 1.15 2005/11/07 11:14:26 gleixner Exp $
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
14 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
15 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
18 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
27 #include <linux/module.h>
28 #include <linux/types.h>
29 #include <linux/kernel.h>
30 #include <linux/init.h>
31 #include <asm/io.h>
32 #include <linux/mtd/mtd.h>
33 #include <linux/mtd/map.h>
34 #include <linux/mtd/partitions.h>
37 /* We split the flash chip up into four parts.
38 * 1: bootloader firts 128k (0x00000000 - 0x0001FFFF) size 0x020000
39 * 2: kernel 640k (0x00020000 - 0x000BFFFF) size 0x0A0000
40 * 3: compressed 1536k root ramdisk (0x000C0000 - 0x0023FFFF) size 0x180000
41 * 4: writeable diskpartition (jffs)(0x00240000 - 0x003FFFFF) size 0x1C0000
42 */
44 #define FLASH_PHYS_ADDR 0x40000000
45 #define FLASH_SIZE 0x400000
47 #define FLASH_PARTITION0_ADDR 0x00000000
48 #define FLASH_PARTITION0_SIZE 0x00020000
50 #define FLASH_PARTITION1_ADDR 0x00020000
51 #define FLASH_PARTITION1_SIZE 0x000A0000
53 #define FLASH_PARTITION2_ADDR 0x000C0000
54 #define FLASH_PARTITION2_SIZE 0x00180000
56 #define FLASH_PARTITION3_ADDR 0x00240000
57 #define FLASH_PARTITION3_SIZE 0x001C0000
60 struct map_info flagadm_map = {
61 .name = "FlagaDM flash device",
62 .size = FLASH_SIZE,
63 .bankwidth = 2,
64 };
66 struct mtd_partition flagadm_parts[] = {
67 {
68 .name = "Bootloader",
69 .offset = FLASH_PARTITION0_ADDR,
70 .size = FLASH_PARTITION0_SIZE
71 },
72 {
73 .name = "Kernel image",
74 .offset = FLASH_PARTITION1_ADDR,
75 .size = FLASH_PARTITION1_SIZE
76 },
77 {
78 .name = "Initial ramdisk image",
79 .offset = FLASH_PARTITION2_ADDR,
80 .size = FLASH_PARTITION2_SIZE
81 },
82 {
83 .name = "Persistant storage",
84 .offset = FLASH_PARTITION3_ADDR,
85 .size = FLASH_PARTITION3_SIZE
86 }
87 };
89 #define PARTITION_COUNT ARRAY_SIZE(flagadm_parts)
91 static struct mtd_info *mymtd;
93 int __init init_flagadm(void)
94 {
95 printk(KERN_NOTICE "FlagaDM flash device: %x at %x\n",
96 FLASH_SIZE, FLASH_PHYS_ADDR);
98 flagadm_map.phys = FLASH_PHYS_ADDR;
99 flagadm_map.virt = ioremap(FLASH_PHYS_ADDR,
100 FLASH_SIZE);
102 if (!flagadm_map.virt) {
103 printk("Failed to ioremap\n");
104 return -EIO;
105 }
107 simple_map_init(&flagadm_map);
109 mymtd = do_map_probe("cfi_probe", &flagadm_map);
110 if (mymtd) {
111 mymtd->owner = THIS_MODULE;
112 add_mtd_partitions(mymtd, flagadm_parts, PARTITION_COUNT);
113 printk(KERN_NOTICE "FlagaDM flash device initialized\n");
114 return 0;
115 }
117 iounmap((void *)flagadm_map.virt);
118 return -ENXIO;
119 }
121 static void __exit cleanup_flagadm(void)
122 {
123 if (mymtd) {
124 del_mtd_partitions(mymtd);
125 map_destroy(mymtd);
126 }
127 if (flagadm_map.virt) {
128 iounmap((void *)flagadm_map.virt);
129 flagadm_map.virt = 0;
130 }
131 }
133 module_init(init_flagadm);
134 module_exit(cleanup_flagadm);
137 MODULE_LICENSE("GPL");
138 MODULE_AUTHOR("Kári Davíðsson <kd@flaga.is>");
139 MODULE_DESCRIPTION("MTD map driver for Flaga digital module");