ia64/linux-2.6.18-xen.hg

view drivers/mtd/maps/netsc520.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 /* netsc520.c -- MTD map driver for AMD NetSc520 Demonstration Board
2 *
3 * Copyright (C) 2001 Mark Langsdorf (mark.langsdorf@amd.com)
4 * based on sc520cdp.c by Sysgo Real-Time Solutions GmbH
5 *
6 * $Id: netsc520.c,v 1.14 2005/11/07 11:14:27 gleixner Exp $
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 *
22 * The NetSc520 is a demonstration board for the Elan Sc520 processor available
23 * from AMD. It has a single back of 16 megs of 32-bit Flash ROM and another
24 * 16 megs of SDRAM.
25 */
27 #include <linux/module.h>
28 #include <linux/types.h>
29 #include <linux/kernel.h>
30 #include <linux/init.h>
31 #include <asm/io.h>
32 #include <linux/mtd/mtd.h>
33 #include <linux/mtd/map.h>
34 #include <linux/mtd/partitions.h>
37 /*
38 ** The single, 16 megabyte flash bank is divided into four virtual
39 ** partitions. The first partition is 768 KiB and is intended to
40 ** store the kernel image loaded by the bootstrap loader. The second
41 ** partition is 256 KiB and holds the BIOS image. The third
42 ** partition is 14.5 MiB and is intended for the flash file system
43 ** image. The last partition is 512 KiB and contains another copy
44 ** of the BIOS image and the reset vector.
45 **
46 ** Only the third partition should be mounted. The first partition
47 ** should not be mounted, but it can erased and written to using the
48 ** MTD character routines. The second and fourth partitions should
49 ** not be touched - it is possible to corrupt the BIOS image by
50 ** mounting these partitions, and potentially the board will not be
51 ** recoverable afterwards.
52 */
54 /* partition_info gives details on the logical partitions that the split the
55 * single flash device into. If the size if zero we use up to the end of the
56 * device. */
57 static struct mtd_partition partition_info[]={
58 {
59 .name = "NetSc520 boot kernel",
60 .offset = 0,
61 .size = 0xc0000
62 },
63 {
64 .name = "NetSc520 Low BIOS",
65 .offset = 0xc0000,
66 .size = 0x40000
67 },
68 {
69 .name = "NetSc520 file system",
70 .offset = 0x100000,
71 .size = 0xe80000
72 },
73 {
74 .name = "NetSc520 High BIOS",
75 .offset = 0xf80000,
76 .size = 0x80000
77 },
78 };
79 #define NUM_PARTITIONS ARRAY_SIZE(partition_info)
81 #define WINDOW_SIZE 0x00100000
82 #define WINDOW_ADDR 0x00200000
84 static struct map_info netsc520_map = {
85 .name = "netsc520 Flash Bank",
86 .size = WINDOW_SIZE,
87 .bankwidth = 4,
88 .phys = WINDOW_ADDR,
89 };
91 #define NUM_FLASH_BANKS ARRAY_SIZE(netsc520_map)
93 static struct mtd_info *mymtd;
95 static int __init init_netsc520(void)
96 {
97 printk(KERN_NOTICE "NetSc520 flash device: 0x%lx at 0x%lx\n", netsc520_map.size, netsc520_map.phys);
98 netsc520_map.virt = ioremap_nocache(netsc520_map.phys, netsc520_map.size);
100 if (!netsc520_map.virt) {
101 printk("Failed to ioremap_nocache\n");
102 return -EIO;
103 }
105 simple_map_init(&netsc520_map);
107 mymtd = do_map_probe("cfi_probe", &netsc520_map);
108 if(!mymtd)
109 mymtd = do_map_probe("map_ram", &netsc520_map);
110 if(!mymtd)
111 mymtd = do_map_probe("map_rom", &netsc520_map);
113 if (!mymtd) {
114 iounmap(netsc520_map.virt);
115 return -ENXIO;
116 }
118 mymtd->owner = THIS_MODULE;
119 add_mtd_partitions( mymtd, partition_info, NUM_PARTITIONS );
120 return 0;
121 }
123 static void __exit cleanup_netsc520(void)
124 {
125 if (mymtd) {
126 del_mtd_partitions(mymtd);
127 map_destroy(mymtd);
128 }
129 if (netsc520_map.virt) {
130 iounmap(netsc520_map.virt);
131 netsc520_map.virt = NULL;
132 }
133 }
135 module_init(init_netsc520);
136 module_exit(cleanup_netsc520);
138 MODULE_LICENSE("GPL");
139 MODULE_AUTHOR("Mark Langsdorf <mark.langsdorf@amd.com>");
140 MODULE_DESCRIPTION("MTD map driver for AMD NetSc520 Demonstration Board");