ia64/linux-2.6.18-xen.hg

view drivers/zorro/zorro-sysfs.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 * File Attributes for Zorro Devices
3 *
4 * Copyright (C) 2003 Geert Uytterhoeven
5 *
6 * Loosely based on drivers/pci/pci-sysfs.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 */
14 #include <linux/kernel.h>
15 #include <linux/zorro.h>
16 #include <linux/stat.h>
17 #include <linux/string.h>
19 #include "zorro.h"
22 /* show configuration fields */
23 #define zorro_config_attr(name, field, format_string) \
24 static ssize_t \
25 show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
26 { \
27 struct zorro_dev *z; \
28 \
29 z = to_zorro_dev(dev); \
30 return sprintf(buf, format_string, z->field); \
31 } \
32 static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
34 zorro_config_attr(id, id, "0x%08x\n");
35 zorro_config_attr(type, rom.er_Type, "0x%02x\n");
36 zorro_config_attr(serial, rom.er_SerialNumber, "0x%08x\n");
37 zorro_config_attr(slotaddr, slotaddr, "0x%04x\n");
38 zorro_config_attr(slotsize, slotsize, "0x%04x\n");
40 static ssize_t zorro_show_resource(struct device *dev, struct device_attribute *attr, char *buf)
41 {
42 struct zorro_dev *z = to_zorro_dev(dev);
44 return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
45 zorro_resource_start(z), zorro_resource_end(z),
46 zorro_resource_flags(z));
47 }
49 static DEVICE_ATTR(resource, S_IRUGO, zorro_show_resource, NULL);
51 static ssize_t zorro_read_config(struct kobject *kobj, char *buf, loff_t off,
52 size_t count)
53 {
54 struct zorro_dev *z = to_zorro_dev(container_of(kobj, struct device,
55 kobj));
56 struct ConfigDev cd;
57 unsigned int size = sizeof(cd);
59 if (off > size)
60 return 0;
61 if (off+count > size)
62 count = size-off;
64 /* Construct a ConfigDev */
65 memset(&cd, 0, sizeof(cd));
66 cd.cd_Rom = z->rom;
67 cd.cd_SlotAddr = z->slotaddr;
68 cd.cd_SlotSize = z->slotsize;
69 cd.cd_BoardAddr = (void *)zorro_resource_start(z);
70 cd.cd_BoardSize = zorro_resource_len(z);
72 memcpy(buf, (void *)&cd+off, count);
73 return count;
74 }
76 static struct bin_attribute zorro_config_attr = {
77 .attr = {
78 .name = "config",
79 .mode = S_IRUGO | S_IWUSR,
80 .owner = THIS_MODULE
81 },
82 .size = sizeof(struct ConfigDev),
83 .read = zorro_read_config,
84 };
86 void zorro_create_sysfs_dev_files(struct zorro_dev *z)
87 {
88 struct device *dev = &z->dev;
90 /* current configuration's attributes */
91 device_create_file(dev, &dev_attr_id);
92 device_create_file(dev, &dev_attr_type);
93 device_create_file(dev, &dev_attr_serial);
94 device_create_file(dev, &dev_attr_slotaddr);
95 device_create_file(dev, &dev_attr_slotsize);
96 device_create_file(dev, &dev_attr_resource);
97 sysfs_create_bin_file(&dev->kobj, &zorro_config_attr);
98 }