ia64/linux-2.6.18-xen.hg

view drivers/mtd/maps/impa7.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: impa7.c,v 1.14 2005/11/07 11:14:27 gleixner Exp $
3 *
4 * Handle mapping of the NOR flash on implementa A7 boards
5 *
6 * Copyright 2002 SYSGO Real-Time Solutions GmbH
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
13 #include <linux/module.h>
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <asm/io.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/map.h>
21 #ifdef CONFIG_MTD_PARTITIONS
22 #include <linux/mtd/partitions.h>
23 #endif
25 #define WINDOW_ADDR0 0x00000000 /* physical properties of flash */
26 #define WINDOW_SIZE0 0x00800000
27 #define WINDOW_ADDR1 0x10000000 /* physical properties of flash */
28 #define WINDOW_SIZE1 0x00800000
29 #define NUM_FLASHBANKS 2
30 #define BUSWIDTH 4
32 /* can be { "cfi_probe", "jedec_probe", "map_rom", NULL } */
33 #define PROBETYPES { "jedec_probe", NULL }
35 #define MSG_PREFIX "impA7:" /* prefix for our printk()'s */
36 #define MTDID "impa7-%d" /* for mtdparts= partitioning */
38 static struct mtd_info *impa7_mtd[NUM_FLASHBANKS];
41 static struct map_info impa7_map[NUM_FLASHBANKS] = {
42 {
43 .name = "impA7 NOR Flash Bank #0",
44 .size = WINDOW_SIZE0,
45 .bankwidth = BUSWIDTH,
46 },
47 {
48 .name = "impA7 NOR Flash Bank #1",
49 .size = WINDOW_SIZE1,
50 .bankwidth = BUSWIDTH,
51 },
52 };
54 #ifdef CONFIG_MTD_PARTITIONS
56 /*
57 * MTD partitioning stuff
58 */
59 static struct mtd_partition static_partitions[] =
60 {
61 {
62 .name = "FileSystem",
63 .size = 0x800000,
64 .offset = 0x00000000
65 },
66 };
68 static int mtd_parts_nb[NUM_FLASHBANKS];
69 static struct mtd_partition *mtd_parts[NUM_FLASHBANKS];
71 #endif
73 static const char *probes[] = { "cmdlinepart", NULL };
75 int __init init_impa7(void)
76 {
77 static const char *rom_probe_types[] = PROBETYPES;
78 const char **type;
79 const char *part_type = 0;
80 int i;
81 static struct { u_long addr; u_long size; } pt[NUM_FLASHBANKS] = {
82 { WINDOW_ADDR0, WINDOW_SIZE0 },
83 { WINDOW_ADDR1, WINDOW_SIZE1 },
84 };
85 int devicesfound = 0;
87 for(i=0; i<NUM_FLASHBANKS; i++)
88 {
89 printk(KERN_NOTICE MSG_PREFIX "probing 0x%08lx at 0x%08lx\n",
90 pt[i].size, pt[i].addr);
92 impa7_map[i].phys = pt[i].addr;
93 impa7_map[i].virt = ioremap(pt[i].addr, pt[i].size);
94 if (!impa7_map[i].virt) {
95 printk(MSG_PREFIX "failed to ioremap\n");
96 return -EIO;
97 }
98 simple_map_init(&impa7_map[i]);
100 impa7_mtd[i] = 0;
101 type = rom_probe_types;
102 for(; !impa7_mtd[i] && *type; type++) {
103 impa7_mtd[i] = do_map_probe(*type, &impa7_map[i]);
104 }
106 if (impa7_mtd[i]) {
107 impa7_mtd[i]->owner = THIS_MODULE;
108 devicesfound++;
109 #ifdef CONFIG_MTD_PARTITIONS
110 mtd_parts_nb[i] = parse_mtd_partitions(impa7_mtd[i],
111 probes,
112 &mtd_parts[i],
113 0);
114 if (mtd_parts_nb[i] > 0) {
115 part_type = "command line";
116 } else {
117 mtd_parts[i] = static_partitions;
118 mtd_parts_nb[i] = ARRAY_SIZE(static_partitions);
119 part_type = "static";
120 }
122 printk(KERN_NOTICE MSG_PREFIX
123 "using %s partition definition\n",
124 part_type);
125 add_mtd_partitions(impa7_mtd[i],
126 mtd_parts[i], mtd_parts_nb[i]);
127 #else
128 add_mtd_device(impa7_mtd[i]);
130 #endif
131 }
132 else
133 iounmap((void *)impa7_map[i].virt);
134 }
135 return devicesfound == 0 ? -ENXIO : 0;
136 }
138 static void __exit cleanup_impa7(void)
139 {
140 int i;
141 for (i=0; i<NUM_FLASHBANKS; i++) {
142 if (impa7_mtd[i]) {
143 #ifdef CONFIG_MTD_PARTITIONS
144 del_mtd_partitions(impa7_mtd[i]);
145 #else
146 del_mtd_device(impa7_mtd[i]);
147 #endif
148 map_destroy(impa7_mtd[i]);
149 iounmap((void *)impa7_map[i].virt);
150 impa7_map[i].virt = 0;
151 }
152 }
153 }
155 module_init(init_impa7);
156 module_exit(cleanup_impa7);
158 MODULE_LICENSE("GPL");
159 MODULE_AUTHOR("Pavel Bartusek <pba@sysgo.de>");
160 MODULE_DESCRIPTION("MTD map driver for implementa impA7");