ia64/linux-2.6.18-xen.hg

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