ia64/linux-2.6.18-xen.hg

view drivers/zorro/zorro-driver.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 * Zorro Driver Services
3 *
4 * Copyright (C) 2003 Geert Uytterhoeven
5 *
6 * Loosely based on drivers/pci/pci-driver.c
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive
10 * for more details.
11 */
13 #include <linux/init.h>
14 #include <linux/module.h>
15 #include <linux/zorro.h>
18 /**
19 * zorro_match_device - Tell if a Zorro device structure has a matching
20 * Zorro device id structure
21 * @ids: array of Zorro device id structures to search in
22 * @dev: the Zorro device structure to match against
23 *
24 * Used by a driver to check whether a Zorro device present in the
25 * system is in its list of supported devices. Returns the matching
26 * zorro_device_id structure or %NULL if there is no match.
27 */
29 const struct zorro_device_id *
30 zorro_match_device(const struct zorro_device_id *ids,
31 const struct zorro_dev *z)
32 {
33 while (ids->id) {
34 if (ids->id == ZORRO_WILDCARD || ids->id == z->id)
35 return ids;
36 ids++;
37 }
38 return NULL;
39 }
42 static int zorro_device_probe(struct device *dev)
43 {
44 int error = 0;
45 struct zorro_driver *drv = to_zorro_driver(dev->driver);
46 struct zorro_dev *z = to_zorro_dev(dev);
48 if (!z->driver && drv->probe) {
49 const struct zorro_device_id *id;
51 id = zorro_match_device(drv->id_table, z);
52 if (id)
53 error = drv->probe(z, id);
54 if (error >= 0) {
55 z->driver = drv;
56 error = 0;
57 }
58 }
59 return error;
60 }
63 /**
64 * zorro_register_driver - register a new Zorro driver
65 * @drv: the driver structure to register
66 *
67 * Adds the driver structure to the list of registered drivers
68 * Returns zero or a negative error value.
69 */
71 int zorro_register_driver(struct zorro_driver *drv)
72 {
73 /* initialize common driver fields */
74 drv->driver.name = drv->name;
75 drv->driver.bus = &zorro_bus_type;
77 /* register with core */
78 return driver_register(&drv->driver);
79 }
82 /**
83 * zorro_unregister_driver - unregister a zorro driver
84 * @drv: the driver structure to unregister
85 *
86 * Deletes the driver structure from the list of registered Zorro drivers,
87 * gives it a chance to clean up by calling its remove() function for
88 * each device it was responsible for, and marks those devices as
89 * driverless.
90 */
92 void zorro_unregister_driver(struct zorro_driver *drv)
93 {
94 driver_unregister(&drv->driver);
95 }
98 /**
99 * zorro_bus_match - Tell if a Zorro device structure has a matching Zorro
100 * device id structure
101 * @ids: array of Zorro device id structures to search in
102 * @dev: the Zorro device structure to match against
103 *
104 * Used by a driver to check whether a Zorro device present in the
105 * system is in its list of supported devices.Returns the matching
106 * zorro_device_id structure or %NULL if there is no match.
107 */
109 static int zorro_bus_match(struct device *dev, struct device_driver *drv)
110 {
111 struct zorro_dev *z = to_zorro_dev(dev);
112 struct zorro_driver *zorro_drv = to_zorro_driver(drv);
113 const struct zorro_device_id *ids = zorro_drv->id_table;
115 if (!ids)
116 return 0;
118 while (ids->id) {
119 if (ids->id == ZORRO_WILDCARD || ids->id == z->id)
120 return 1;
121 ids++;
122 }
123 return 0;
124 }
127 struct bus_type zorro_bus_type = {
128 .name = "zorro",
129 .match = zorro_bus_match,
130 .probe = zorro_device_probe,
131 };
134 static int __init zorro_driver_init(void)
135 {
136 return bus_register(&zorro_bus_type);
137 }
139 postcore_initcall(zorro_driver_init);
141 EXPORT_SYMBOL(zorro_match_device);
142 EXPORT_SYMBOL(zorro_register_driver);
143 EXPORT_SYMBOL(zorro_unregister_driver);
144 EXPORT_SYMBOL(zorro_dev_driver);
145 EXPORT_SYMBOL(zorro_bus_type);