ia64/linux-2.6.18-xen.hg

view drivers/net/netconsole.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/net/netconsole.c
3 *
4 * Copyright (C) 2001 Ingo Molnar <mingo@redhat.com>
5 *
6 * This file contains the implementation of an IRQ-safe, crash-safe
7 * kernel console implementation that outputs kernel messages to the
8 * network.
9 *
10 * Modification history:
11 *
12 * 2001-09-17 started by Ingo Molnar.
13 * 2003-08-11 2.6 port by Matt Mackall
14 * simplified options
15 * generic card hooks
16 * works non-modular
17 * 2003-09-07 rewritten with netpoll api
18 */
20 /****************************************************************
21 * This program is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation; either version 2, or (at your option)
24 * any later version.
25 *
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
30 *
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
34 *
35 ****************************************************************/
37 #include <linux/mm.h>
38 #include <linux/tty.h>
39 #include <linux/init.h>
40 #include <linux/module.h>
41 #include <linux/console.h>
42 #include <linux/tty_driver.h>
43 #include <linux/moduleparam.h>
44 #include <linux/string.h>
45 #include <linux/sysrq.h>
46 #include <linux/smp.h>
47 #include <linux/netpoll.h>
49 MODULE_AUTHOR("Maintainer: Matt Mackall <mpm@selenic.com>");
50 MODULE_DESCRIPTION("Console driver for network interfaces");
51 MODULE_LICENSE("GPL");
53 static char config[256];
54 module_param_string(netconsole, config, 256, 0);
55 MODULE_PARM_DESC(netconsole, " netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]\n");
57 static struct netpoll np = {
58 .name = "netconsole",
59 .dev_name = "eth0",
60 .local_port = 6665,
61 .remote_port = 6666,
62 .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
63 .drop = netpoll_queue,
64 };
65 static int configured = 0;
67 #define MAX_PRINT_CHUNK 1000
69 static void write_msg(struct console *con, const char *msg, unsigned int len)
70 {
71 int frag, left;
72 unsigned long flags;
74 if (!np.dev)
75 return;
77 local_irq_save(flags);
79 for(left = len; left; ) {
80 frag = min(left, MAX_PRINT_CHUNK);
81 netpoll_send_udp(&np, msg, frag);
82 msg += frag;
83 left -= frag;
84 }
86 local_irq_restore(flags);
87 }
89 static struct console netconsole = {
90 .name = "netcon",
91 .flags = CON_ENABLED | CON_PRINTBUFFER,
92 .write = write_msg
93 };
95 static int option_setup(char *opt)
96 {
97 configured = !netpoll_parse_options(&np, opt);
98 return 1;
99 }
101 __setup("netconsole=", option_setup);
103 static int init_netconsole(void)
104 {
105 if(strlen(config))
106 option_setup(config);
108 if(!configured) {
109 printk("netconsole: not configured, aborting\n");
110 return 0;
111 }
113 if(netpoll_setup(&np))
114 return -EINVAL;
116 register_console(&netconsole);
117 printk(KERN_INFO "netconsole: network logging started\n");
118 return 0;
119 }
121 static void cleanup_netconsole(void)
122 {
123 unregister_console(&netconsole);
124 netpoll_cleanup(&np);
125 }
127 module_init(init_netconsole);
128 module_exit(cleanup_netconsole);