ia64/linux-2.6.18-xen.hg

view drivers/mtd/maps/edb7312.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: edb7312.c,v 1.14 2005/11/07 11:14:27 gleixner Exp $
3 *
4 * Handle mapping of the NOR flash on Cogent EDB7312 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_ADDR 0x00000000 /* physical properties of flash */
26 #define WINDOW_SIZE 0x01000000
27 #define BUSWIDTH 2
28 #define FLASH_BLOCKSIZE_MAIN 0x20000
29 #define FLASH_NUMBLOCKS_MAIN 128
30 /* can be "cfi_probe", "jedec_probe", "map_rom", NULL }; */
31 #define PROBETYPES { "cfi_probe", NULL }
33 #define MSG_PREFIX "EDB7312-NOR:" /* prefix for our printk()'s */
34 #define MTDID "edb7312-nor" /* for mtdparts= partitioning */
36 static struct mtd_info *mymtd;
38 struct map_info edb7312nor_map = {
39 .name = "NOR flash on EDB7312",
40 .size = WINDOW_SIZE,
41 .bankwidth = BUSWIDTH,
42 .phys = WINDOW_ADDR,
43 };
45 #ifdef CONFIG_MTD_PARTITIONS
47 /*
48 * MTD partitioning stuff
49 */
50 static struct mtd_partition static_partitions[3] =
51 {
52 {
53 .name = "ARMboot",
54 .size = 0x40000,
55 .offset = 0
56 },
57 {
58 .name = "Kernel",
59 .size = 0x200000,
60 .offset = 0x40000
61 },
62 {
63 .name = "RootFS",
64 .size = 0xDC0000,
65 .offset = 0x240000
66 },
67 };
69 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
71 #endif
73 static int mtd_parts_nb = 0;
74 static struct mtd_partition *mtd_parts = 0;
76 int __init init_edb7312nor(void)
77 {
78 static const char *rom_probe_types[] = PROBETYPES;
79 const char **type;
80 const char *part_type = 0;
82 printk(KERN_NOTICE MSG_PREFIX "0x%08x at 0x%08x\n",
83 WINDOW_SIZE, WINDOW_ADDR);
84 edb7312nor_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
86 if (!edb7312nor_map.virt) {
87 printk(MSG_PREFIX "failed to ioremap\n");
88 return -EIO;
89 }
91 simple_map_init(&edb7312nor_map);
93 mymtd = 0;
94 type = rom_probe_types;
95 for(; !mymtd && *type; type++) {
96 mymtd = do_map_probe(*type, &edb7312nor_map);
97 }
98 if (mymtd) {
99 mymtd->owner = THIS_MODULE;
101 #ifdef CONFIG_MTD_PARTITIONS
102 mtd_parts_nb = parse_mtd_partitions(mymtd, probes, &mtd_parts, MTDID);
103 if (mtd_parts_nb > 0)
104 part_type = "detected";
106 if (mtd_parts_nb == 0)
107 {
108 mtd_parts = static_partitions;
109 mtd_parts_nb = ARRAY_SIZE(static_partitions);
110 part_type = "static";
111 }
112 #endif
113 add_mtd_device(mymtd);
114 if (mtd_parts_nb == 0)
115 printk(KERN_NOTICE MSG_PREFIX "no partition info available\n");
116 else
117 {
118 printk(KERN_NOTICE MSG_PREFIX
119 "using %s partition definition\n", part_type);
120 add_mtd_partitions(mymtd, mtd_parts, mtd_parts_nb);
121 }
122 return 0;
123 }
125 iounmap((void *)edb7312nor_map.virt);
126 return -ENXIO;
127 }
129 static void __exit cleanup_edb7312nor(void)
130 {
131 if (mymtd) {
132 del_mtd_device(mymtd);
133 map_destroy(mymtd);
134 }
135 if (edb7312nor_map.virt) {
136 iounmap((void *)edb7312nor_map.virt);
137 edb7312nor_map.virt = 0;
138 }
139 }
141 module_init(init_edb7312nor);
142 module_exit(cleanup_edb7312nor);
144 MODULE_LICENSE("GPL");
145 MODULE_AUTHOR("Marius Groeger <mag@sysgo.de>");
146 MODULE_DESCRIPTION("Generic configurable MTD map driver");