ia64/linux-2.6.18-xen.hg

view drivers/serial/8250_acorn.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 * linux/drivers/serial/acorn.c
3 *
4 * Copyright (C) 1996-2003 Russell King.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10 #include <linux/module.h>
11 #include <linux/types.h>
12 #include <linux/tty.h>
13 #include <linux/serial_core.h>
14 #include <linux/errno.h>
15 #include <linux/ioport.h>
16 #include <linux/slab.h>
17 #include <linux/device.h>
18 #include <linux/init.h>
20 #include <asm/io.h>
21 #include <asm/ecard.h>
22 #include <asm/string.h>
24 #include "8250.h"
26 #define MAX_PORTS 3
28 struct serial_card_type {
29 unsigned int num_ports;
30 unsigned int uartclk;
31 unsigned int type;
32 unsigned int offset[MAX_PORTS];
33 };
35 struct serial_card_info {
36 unsigned int num_ports;
37 int ports[MAX_PORTS];
38 };
40 static int __devinit
41 serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)
42 {
43 struct serial_card_info *info;
44 struct serial_card_type *type = id->data;
45 struct uart_port port;
46 unsigned long bus_addr;
47 unsigned char __iomem *virt_addr;
48 unsigned int i;
50 info = kmalloc(sizeof(struct serial_card_info), GFP_KERNEL);
51 if (!info)
52 return -ENOMEM;
54 memset(info, 0, sizeof(struct serial_card_info));
55 info->num_ports = type->num_ports;
57 bus_addr = ecard_resource_start(ec, type->type);
58 virt_addr = ioremap(bus_addr, ecard_resource_len(ec, type->type));
59 if (!virt_addr) {
60 kfree(info);
61 return -ENOMEM;
62 }
64 ecard_set_drvdata(ec, info);
66 memset(&port, 0, sizeof(struct uart_port));
67 port.irq = ec->irq;
68 port.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
69 port.uartclk = type->uartclk;
70 port.iotype = UPIO_MEM;
71 port.regshift = 2;
72 port.dev = &ec->dev;
74 for (i = 0; i < info->num_ports; i ++) {
75 port.membase = virt_addr + type->offset[i];
76 port.mapbase = bus_addr + type->offset[i];
78 info->ports[i] = serial8250_register_port(&port);
79 }
81 return 0;
82 }
84 static void __devexit serial_card_remove(struct expansion_card *ec)
85 {
86 struct serial_card_info *info = ecard_get_drvdata(ec);
87 int i;
89 ecard_set_drvdata(ec, NULL);
91 for (i = 0; i < info->num_ports; i++)
92 if (info->ports[i] > 0)
93 serial8250_unregister_port(info->ports[i]);
95 kfree(info);
96 }
98 static struct serial_card_type atomwide_type = {
99 .num_ports = 3,
100 .uartclk = 7372800,
101 .type = ECARD_RES_IOCSLOW,
102 .offset = { 0x2800, 0x2400, 0x2000 },
103 };
105 static struct serial_card_type serport_type = {
106 .num_ports = 2,
107 .uartclk = 3686400,
108 .type = ECARD_RES_IOCSLOW,
109 .offset = { 0x2000, 0x2020 },
110 };
112 static const struct ecard_id serial_cids[] = {
113 { MANU_ATOMWIDE, PROD_ATOMWIDE_3PSERIAL, &atomwide_type },
114 { MANU_SERPORT, PROD_SERPORT_DSPORT, &serport_type },
115 { 0xffff, 0xffff }
116 };
118 static struct ecard_driver serial_card_driver = {
119 .probe = serial_card_probe,
120 .remove = __devexit_p(serial_card_remove),
121 .id_table = serial_cids,
122 .drv = {
123 .name = "8250_acorn",
124 },
125 };
127 static int __init serial_card_init(void)
128 {
129 return ecard_register_driver(&serial_card_driver);
130 }
132 static void __exit serial_card_exit(void)
133 {
134 ecard_remove_driver(&serial_card_driver);
135 }
137 MODULE_AUTHOR("Russell King");
138 MODULE_DESCRIPTION("Acorn 8250-compatible serial port expansion card driver");
139 MODULE_LICENSE("GPL");
141 module_init(serial_card_init);
142 module_exit(serial_card_exit);