ia64/linux-2.6.18-xen.hg

view drivers/mtd/maps/mainstone-flash.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 * $Id: $
3 *
4 * Map driver for the Mainstone developer platform.
5 *
6 * Author: Nicolas Pitre
7 * Copyright: (C) 2001 MontaVista Software Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
14 #include <linux/module.h>
15 #include <linux/types.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/dma-mapping.h>
19 #include <linux/slab.h>
21 #include <linux/mtd/mtd.h>
22 #include <linux/mtd/map.h>
23 #include <linux/mtd/partitions.h>
25 #include <asm/io.h>
26 #include <asm/hardware.h>
27 #include <asm/arch/pxa-regs.h>
28 #include <asm/arch/mainstone.h>
31 #define ROM_ADDR 0x00000000
32 #define FLASH_ADDR 0x04000000
34 #define WINDOW_SIZE 0x04000000
36 static void mainstone_map_inval_cache(struct map_info *map, unsigned long from,
37 ssize_t len)
38 {
39 consistent_sync((char *)map->cached + from, len, DMA_FROM_DEVICE);
40 }
42 static struct map_info mainstone_maps[2] = { {
43 .size = WINDOW_SIZE,
44 .phys = PXA_CS0_PHYS,
45 .inval_cache = mainstone_map_inval_cache,
46 }, {
47 .size = WINDOW_SIZE,
48 .phys = PXA_CS1_PHYS,
49 .inval_cache = mainstone_map_inval_cache,
50 } };
52 static struct mtd_partition mainstone_partitions[] = {
53 {
54 .name = "Bootloader",
55 .size = 0x00040000,
56 .offset = 0,
57 .mask_flags = MTD_WRITEABLE /* force read-only */
58 },{
59 .name = "Kernel",
60 .size = 0x00400000,
61 .offset = 0x00040000,
62 },{
63 .name = "Filesystem",
64 .size = MTDPART_SIZ_FULL,
65 .offset = 0x00440000
66 }
67 };
69 static struct mtd_info *mymtds[2];
70 static struct mtd_partition *parsed_parts[2];
71 static int nr_parsed_parts[2];
73 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
75 static int __init init_mainstone(void)
76 {
77 int SW7 = 0; /* FIXME: get from SCR (Mst doc section 3.2.1.1) */
78 int ret = 0, i;
80 mainstone_maps[0].bankwidth = (BOOT_DEF & 1) ? 2 : 4;
81 mainstone_maps[1].bankwidth = 4;
83 /* Compensate for SW7 which swaps the flash banks */
84 mainstone_maps[SW7].name = "processor flash";
85 mainstone_maps[SW7 ^ 1].name = "main board flash";
87 printk(KERN_NOTICE "Mainstone configured to boot from %s\n",
88 mainstone_maps[0].name);
90 for (i = 0; i < 2; i++) {
91 mainstone_maps[i].virt = ioremap(mainstone_maps[i].phys,
92 WINDOW_SIZE);
93 if (!mainstone_maps[i].virt) {
94 printk(KERN_WARNING "Failed to ioremap %s\n",
95 mainstone_maps[i].name);
96 if (!ret)
97 ret = -ENOMEM;
98 continue;
99 }
100 mainstone_maps[i].cached =
101 ioremap_cached(mainstone_maps[i].phys, WINDOW_SIZE);
102 if (!mainstone_maps[i].cached)
103 printk(KERN_WARNING "Failed to ioremap cached %s\n",
104 mainstone_maps[i].name);
105 simple_map_init(&mainstone_maps[i]);
107 printk(KERN_NOTICE
108 "Probing %s at physical address 0x%08lx"
109 " (%d-bit bankwidth)\n",
110 mainstone_maps[i].name, mainstone_maps[i].phys,
111 mainstone_maps[i].bankwidth * 8);
113 mymtds[i] = do_map_probe("cfi_probe", &mainstone_maps[i]);
115 if (!mymtds[i]) {
116 iounmap((void *)mainstone_maps[i].virt);
117 if (mainstone_maps[i].cached)
118 iounmap(mainstone_maps[i].cached);
119 if (!ret)
120 ret = -EIO;
121 continue;
122 }
123 mymtds[i]->owner = THIS_MODULE;
125 ret = parse_mtd_partitions(mymtds[i], probes,
126 &parsed_parts[i], 0);
128 if (ret > 0)
129 nr_parsed_parts[i] = ret;
130 }
132 if (!mymtds[0] && !mymtds[1])
133 return ret;
135 for (i = 0; i < 2; i++) {
136 if (!mymtds[i]) {
137 printk(KERN_WARNING "%s is absent. Skipping\n",
138 mainstone_maps[i].name);
139 } else if (nr_parsed_parts[i]) {
140 add_mtd_partitions(mymtds[i], parsed_parts[i],
141 nr_parsed_parts[i]);
142 } else if (!i) {
143 printk("Using static partitions on %s\n",
144 mainstone_maps[i].name);
145 add_mtd_partitions(mymtds[i], mainstone_partitions,
146 ARRAY_SIZE(mainstone_partitions));
147 } else {
148 printk("Registering %s as whole device\n",
149 mainstone_maps[i].name);
150 add_mtd_device(mymtds[i]);
151 }
152 }
153 return 0;
154 }
156 static void __exit cleanup_mainstone(void)
157 {
158 int i;
159 for (i = 0; i < 2; i++) {
160 if (!mymtds[i])
161 continue;
163 if (nr_parsed_parts[i] || !i)
164 del_mtd_partitions(mymtds[i]);
165 else
166 del_mtd_device(mymtds[i]);
168 map_destroy(mymtds[i]);
169 iounmap((void *)mainstone_maps[i].virt);
170 if (mainstone_maps[i].cached)
171 iounmap(mainstone_maps[i].cached);
172 kfree(parsed_parts[i]);
173 }
174 }
176 module_init(init_mainstone);
177 module_exit(cleanup_mainstone);
179 MODULE_LICENSE("GPL");
180 MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>");
181 MODULE_DESCRIPTION("MTD map driver for Intel Mainstone");