ia64/linux-2.6.18-xen.hg

view drivers/mtd/chips/map_rom.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 * Common code to handle map devices which are simple ROM
3 * (C) 2000 Red Hat. GPL'd.
4 * $Id: map_rom.c,v 1.23 2005/01/05 18:05:12 dwmw2 Exp $
5 */
7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <asm/io.h>
11 #include <asm/byteorder.h>
12 #include <linux/errno.h>
13 #include <linux/slab.h>
14 #include <linux/init.h>
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/map.h>
17 #include <linux/mtd/compatmac.h>
19 static int maprom_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
20 static int maprom_write (struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
21 static void maprom_nop (struct mtd_info *);
22 static struct mtd_info *map_rom_probe(struct map_info *map);
24 static struct mtd_chip_driver maprom_chipdrv = {
25 .probe = map_rom_probe,
26 .name = "map_rom",
27 .module = THIS_MODULE
28 };
30 static struct mtd_info *map_rom_probe(struct map_info *map)
31 {
32 struct mtd_info *mtd;
34 mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
35 if (!mtd)
36 return NULL;
38 memset(mtd, 0, sizeof(*mtd));
40 map->fldrv = &maprom_chipdrv;
41 mtd->priv = map;
42 mtd->name = map->name;
43 mtd->type = MTD_ROM;
44 mtd->size = map->size;
45 mtd->read = maprom_read;
46 mtd->write = maprom_write;
47 mtd->sync = maprom_nop;
48 mtd->flags = MTD_CAP_ROM;
49 mtd->erasesize = map->size;
50 mtd->writesize = 1;
52 __module_get(THIS_MODULE);
53 return mtd;
54 }
57 static int maprom_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
58 {
59 struct map_info *map = mtd->priv;
61 map_copy_from(map, buf, from, len);
62 *retlen = len;
63 return 0;
64 }
66 static void maprom_nop(struct mtd_info *mtd)
67 {
68 /* Nothing to see here */
69 }
71 static int maprom_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
72 {
73 printk(KERN_NOTICE "maprom_write called\n");
74 return -EIO;
75 }
77 static int __init map_rom_init(void)
78 {
79 register_mtd_chip_driver(&maprom_chipdrv);
80 return 0;
81 }
83 static void __exit map_rom_exit(void)
84 {
85 unregister_mtd_chip_driver(&maprom_chipdrv);
86 }
88 module_init(map_rom_init);
89 module_exit(map_rom_exit);
91 MODULE_LICENSE("GPL");
92 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
93 MODULE_DESCRIPTION("MTD chip driver for ROM chips");