ia64/linux-2.6.18-xen.hg

view drivers/mtd/maps/wr_sbc82xx_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: wr_sbc82xx_flash.c,v 1.8 2005/11/07 11:14:29 gleixner Exp $
3 *
4 * Map for flash chips on Wind River PowerQUICC II SBC82xx board.
5 *
6 * Copyright (C) 2004 Red Hat, Inc.
7 *
8 * Author: David Woodhouse <dwmw2@infradead.org>
9 *
10 */
12 #include <linux/module.h>
13 #include <linux/types.h>
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/slab.h>
17 #include <asm/io.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/map.h>
20 #include <linux/mtd/partitions.h>
22 #include <asm/immap_cpm2.h>
24 static struct mtd_info *sbcmtd[3];
25 static struct mtd_partition *sbcmtd_parts[3];
27 struct map_info sbc82xx_flash_map[3] = {
28 {.name = "Boot flash"},
29 {.name = "Alternate boot flash"},
30 {.name = "User flash"}
31 };
33 static struct mtd_partition smallflash_parts[] = {
34 {
35 .name = "space",
36 .size = 0x100000,
37 .offset = 0,
38 }, {
39 .name = "bootloader",
40 .size = MTDPART_SIZ_FULL,
41 .offset = MTDPART_OFS_APPEND,
42 }
43 };
45 static struct mtd_partition bigflash_parts[] = {
46 {
47 .name = "bootloader",
48 .size = 0x00100000,
49 .offset = 0,
50 }, {
51 .name = "file system",
52 .size = 0x01f00000,
53 .offset = MTDPART_OFS_APPEND,
54 }, {
55 .name = "boot config",
56 .size = 0x00100000,
57 .offset = MTDPART_OFS_APPEND,
58 }, {
59 .name = "space",
60 .size = 0x01f00000,
61 .offset = MTDPART_OFS_APPEND,
62 }
63 };
65 static const char *part_probes[] __initdata = {"cmdlinepart", "RedBoot", NULL};
67 #define init_sbc82xx_one_flash(map, br, or) \
68 do { \
69 (map).phys = (br & 1) ? (br & 0xffff8000) : 0; \
70 (map).size = (br & 1) ? (~(or & 0xffff8000) + 1) : 0; \
71 switch (br & 0x00001800) { \
72 case 0x00000000: \
73 case 0x00000800: (map).bankwidth = 1; break; \
74 case 0x00001000: (map).bankwidth = 2; break; \
75 case 0x00001800: (map).bankwidth = 4; break; \
76 } \
77 } while (0);
79 int __init init_sbc82xx_flash(void)
80 {
81 volatile memctl_cpm2_t *mc = &cpm2_immr->im_memctl;
82 int bigflash;
83 int i;
85 #ifdef CONFIG_SBC8560
86 mc = ioremap(0xff700000 + 0x5000, sizeof(memctl_cpm2_t));
87 #else
88 mc = &cpm2_immr->im_memctl;
89 #endif
91 bigflash = 1;
92 if ((mc->memc_br0 & 0x00001800) == 0x00001800)
93 bigflash = 0;
95 init_sbc82xx_one_flash(sbc82xx_flash_map[0], mc->memc_br0, mc->memc_or0);
96 init_sbc82xx_one_flash(sbc82xx_flash_map[1], mc->memc_br6, mc->memc_or6);
97 init_sbc82xx_one_flash(sbc82xx_flash_map[2], mc->memc_br1, mc->memc_or1);
99 #ifdef CONFIG_SBC8560
100 iounmap((void *) mc);
101 #endif
103 for (i=0; i<3; i++) {
104 int8_t flashcs[3] = { 0, 6, 1 };
105 int nr_parts;
107 printk(KERN_NOTICE "PowerQUICC II %s (%ld MiB on CS%d",
108 sbc82xx_flash_map[i].name,
109 (sbc82xx_flash_map[i].size >> 20),
110 flashcs[i]);
111 if (!sbc82xx_flash_map[i].phys) {
112 /* We know it can't be at zero. */
113 printk("): disabled by bootloader.\n");
114 continue;
115 }
116 printk(" at %08lx)\n", sbc82xx_flash_map[i].phys);
118 sbc82xx_flash_map[i].virt = ioremap(sbc82xx_flash_map[i].phys, sbc82xx_flash_map[i].size);
120 if (!sbc82xx_flash_map[i].virt) {
121 printk("Failed to ioremap\n");
122 continue;
123 }
125 simple_map_init(&sbc82xx_flash_map[i]);
127 sbcmtd[i] = do_map_probe("cfi_probe", &sbc82xx_flash_map[i]);
129 if (!sbcmtd[i])
130 continue;
132 sbcmtd[i]->owner = THIS_MODULE;
134 nr_parts = parse_mtd_partitions(sbcmtd[i], part_probes,
135 &sbcmtd_parts[i], 0);
136 if (nr_parts > 0) {
137 add_mtd_partitions (sbcmtd[i], sbcmtd_parts[i], nr_parts);
138 continue;
139 }
141 /* No partitioning detected. Use default */
142 if (i == 2) {
143 add_mtd_device(sbcmtd[i]);
144 } else if (i == bigflash) {
145 add_mtd_partitions (sbcmtd[i], bigflash_parts, ARRAY_SIZE(bigflash_parts));
146 } else {
147 add_mtd_partitions (sbcmtd[i], smallflash_parts, ARRAY_SIZE(smallflash_parts));
148 }
149 }
150 return 0;
151 }
153 static void __exit cleanup_sbc82xx_flash(void)
154 {
155 int i;
157 for (i=0; i<3; i++) {
158 if (!sbcmtd[i])
159 continue;
161 if (i<2 || sbcmtd_parts[i])
162 del_mtd_partitions(sbcmtd[i]);
163 else
164 del_mtd_device(sbcmtd[i]);
166 kfree(sbcmtd_parts[i]);
167 map_destroy(sbcmtd[i]);
169 iounmap((void *)sbc82xx_flash_map[i].virt);
170 sbc82xx_flash_map[i].virt = 0;
171 }
172 }
174 module_init(init_sbc82xx_flash);
175 module_exit(cleanup_sbc82xx_flash);
178 MODULE_LICENSE("GPL");
179 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
180 MODULE_DESCRIPTION("Flash map driver for WindRiver PowerQUICC II");