ia64/linux-2.6.18-xen.hg

view drivers/mtd/chips/chipreg.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: chipreg.c,v 1.17 2004/11/16 18:29:00 dwmw2 Exp $
3 *
4 * Registration for chip drivers
5 *
6 */
8 #include <linux/kernel.h>
9 #include <linux/module.h>
10 #include <linux/kmod.h>
11 #include <linux/spinlock.h>
12 #include <linux/slab.h>
13 #include <linux/mtd/map.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/compatmac.h>
17 static DEFINE_SPINLOCK(chip_drvs_lock);
18 static LIST_HEAD(chip_drvs_list);
20 void register_mtd_chip_driver(struct mtd_chip_driver *drv)
21 {
22 spin_lock(&chip_drvs_lock);
23 list_add(&drv->list, &chip_drvs_list);
24 spin_unlock(&chip_drvs_lock);
25 }
27 void unregister_mtd_chip_driver(struct mtd_chip_driver *drv)
28 {
29 spin_lock(&chip_drvs_lock);
30 list_del(&drv->list);
31 spin_unlock(&chip_drvs_lock);
32 }
34 static struct mtd_chip_driver *get_mtd_chip_driver (const char *name)
35 {
36 struct list_head *pos;
37 struct mtd_chip_driver *ret = NULL, *this;
39 spin_lock(&chip_drvs_lock);
41 list_for_each(pos, &chip_drvs_list) {
42 this = list_entry(pos, typeof(*this), list);
44 if (!strcmp(this->name, name)) {
45 ret = this;
46 break;
47 }
48 }
49 if (ret && !try_module_get(ret->module))
50 ret = NULL;
52 spin_unlock(&chip_drvs_lock);
54 return ret;
55 }
57 /* Hide all the horrid details, like some silly person taking
58 get_module_symbol() away from us, from the caller. */
60 struct mtd_info *do_map_probe(const char *name, struct map_info *map)
61 {
62 struct mtd_chip_driver *drv;
63 struct mtd_info *ret;
65 drv = get_mtd_chip_driver(name);
67 if (!drv && !request_module("%s", name))
68 drv = get_mtd_chip_driver(name);
70 if (!drv)
71 return NULL;
73 ret = drv->probe(map);
75 /* We decrease the use count here. It may have been a
76 probe-only module, which is no longer required from this
77 point, having given us a handle on (and increased the use
78 count of) the actual driver code.
79 */
80 module_put(drv->module);
82 if (ret)
83 return ret;
85 return NULL;
86 }
87 /*
88 * Destroy an MTD device which was created for a map device.
89 * Make sure the MTD device is already unregistered before calling this
90 */
91 void map_destroy(struct mtd_info *mtd)
92 {
93 struct map_info *map = mtd->priv;
95 if (map->fldrv->destroy)
96 map->fldrv->destroy(mtd);
98 module_put(map->fldrv->module);
100 kfree(mtd);
101 }
103 EXPORT_SYMBOL(register_mtd_chip_driver);
104 EXPORT_SYMBOL(unregister_mtd_chip_driver);
105 EXPORT_SYMBOL(do_map_probe);
106 EXPORT_SYMBOL(map_destroy);
108 MODULE_LICENSE("GPL");
109 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
110 MODULE_DESCRIPTION("Core routines for registering and invoking MTD chip drivers");