ia64/linux-2.6.18-xen.hg

view drivers/atm/fore200e_mkfirm.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 $Id: fore200e_mkfirm.c,v 1.1 2000/02/21 16:04:32 davem Exp $
4 mkfirm.c: generates a C readable file from a binary firmware image
6 Christophe Lizzi (lizzi@{csti.fr, cnam.fr}), June 1999.
8 This software may be used and distributed according to the terms
9 of the GNU General Public License, incorporated herein by reference.
10 */
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <sys/types.h>
15 #include <time.h>
17 char* default_basename = "pca200e"; /* was initially written for the PCA-200E firmware */
18 char* default_infname = "<stdin>";
19 char* default_outfname = "<stdout>";
21 char* progname;
22 int verbose = 0;
23 int inkernel = 0;
26 void usage(void)
27 {
28 fprintf(stderr,
29 "%s: [-v] [-k] [-b basename ] [-i firmware.bin] [-o firmware.c]\n",
30 progname);
31 exit(-1);
32 }
35 int main(int argc, char** argv)
36 {
37 time_t now;
38 char* infname = NULL;
39 char* outfname = NULL;
40 char* basename = NULL;
41 FILE* infile;
42 FILE* outfile;
43 unsigned firmsize;
44 int c;
46 progname = *(argv++);
48 while (argc > 1) {
49 if ((*argv)[0] == '-') {
50 switch ((*argv)[1]) {
51 case 'i':
52 if (argc-- < 3)
53 usage();
54 infname = *(++argv);
55 break;
56 case 'o':
57 if (argc-- < 3)
58 usage();
59 outfname = *(++argv);
60 break;
61 case 'b':
62 if (argc-- < 3)
63 usage();
64 basename = *(++argv);
65 break;
66 case 'v':
67 verbose = 1;
68 break;
69 case 'k':
70 inkernel = 1;
71 break;
72 default:
73 usage();
74 }
75 }
76 else {
77 usage();
78 }
79 argc--;
80 argv++;
81 }
83 if (infname != NULL) {
84 infile = fopen(infname, "r");
85 if (infile == NULL) {
86 fprintf(stderr, "%s: can't open %s for reading\n",
87 progname, infname);
88 exit(-2);
89 }
90 }
91 else {
92 infile = stdin;
93 infname = default_infname;
94 }
96 if (outfname) {
97 outfile = fopen(outfname, "w");
98 if (outfile == NULL) {
99 fprintf(stderr, "%s: can't open %s for writing\n",
100 progname, outfname);
101 exit(-3);
102 }
103 }
104 else {
105 outfile = stdout;
106 outfname = default_outfname;
107 }
109 if (basename == NULL)
110 basename = default_basename;
112 if (verbose) {
113 fprintf(stderr, "%s: input file = %s\n", progname, infname );
114 fprintf(stderr, "%s: output file = %s\n", progname, outfname );
115 fprintf(stderr, "%s: firmware basename = %s\n", progname, basename );
116 }
118 time(&now);
119 fprintf(outfile, "/*\n generated by %s from %s on %s"
120 " DO NOT EDIT!\n*/\n\n",
121 progname, infname, ctime(&now));
123 if (inkernel)
124 fprintf(outfile, "#include <linux/init.h>\n\n" );
126 /* XXX force 32 bit alignment? */
127 fprintf(outfile, "const unsigned char%s %s_data[] = {\n",
128 inkernel ? " __initdata" : "", basename );
130 c = getc(infile);
131 fprintf(outfile,"\t0x%02x", c);
132 firmsize = 1;
134 while ((c = getc(infile)) >= 0) {
136 if (firmsize++ % 8)
137 fprintf(outfile,", 0x%02x", c);
138 else
139 fprintf(outfile,",\n\t0x%02x", c);
140 }
142 fprintf(outfile, "\n};\n\n");
144 fprintf(outfile, "const unsigned int%s %s_size = %u;\n",
145 inkernel ? " __initdata" : "", basename, firmsize );
147 if (infile != stdin)
148 fclose(infile);
149 if (outfile != stdout)
150 fclose(outfile);
152 if(verbose)
153 fprintf(stderr, "%s: firmware size = %u\n", progname, firmsize);
155 exit(0);
156 }