ia64/linux-2.6.18-xen.hg

view drivers/zorro/gen-devlist.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 * Generate devlist.h from the Zorro ID file.
3 *
4 * (c) 2000 Geert Uytterhoeven <geert@linux-m68k.org>
5 *
6 * Based on the PCI version:
7 *
8 * (c) 1999--2000 Martin Mares <mj@ucw.cz>
9 */
11 #include <stdio.h>
12 #include <string.h>
14 #define MAX_NAME_SIZE 63
16 static void
17 pq(FILE *f, const char *c)
18 {
19 while (*c) {
20 if (*c == '"')
21 fprintf(f, "\\\"");
22 else
23 fputc(*c, f);
24 c++;
25 }
26 }
28 int
29 main(void)
30 {
31 char line[1024], *c, *bra, manuf[8];
32 int manufs = 0;
33 int mode = 0;
34 int lino = 0;
35 int manuf_len = 0;
36 FILE *devf;
38 devf = fopen("devlist.h", "w");
39 if (!devf) {
40 fprintf(stderr, "Cannot create output file!\n");
41 return 1;
42 }
44 while (fgets(line, sizeof(line)-1, stdin)) {
45 lino++;
46 if ((c = strchr(line, '\n')))
47 *c = 0;
48 if (!line[0] || line[0] == '#')
49 continue;
50 if (line[0] == '\t') {
51 switch (mode) {
52 case 1:
53 if (strlen(line) > 5 && line[5] == ' ') {
54 c = line + 5;
55 while (*c == ' ')
56 *c++ = 0;
57 if (manuf_len + strlen(c) + 1 > MAX_NAME_SIZE) {
58 /* Too long, try cutting off long description */
59 bra = strchr(c, '[');
60 if (bra && bra > c && bra[-1] == ' ')
61 bra[-1] = 0;
62 if (manuf_len + strlen(c) + 1 > MAX_NAME_SIZE) {
63 fprintf(stderr, "Line %d: Product name too long\n", lino);
64 return 1;
65 }
66 }
67 fprintf(devf, "\tPRODUCT(%s,%s,\"", manuf, line+1);
68 pq(devf, c);
69 fputs("\")\n", devf);
70 } else goto err;
71 break;
72 default:
73 goto err;
74 }
75 } else if (strlen(line) > 4 && line[4] == ' ') {
76 c = line + 4;
77 while (*c == ' ')
78 *c++ = 0;
79 if (manufs)
80 fputs("ENDMANUF()\n\n", devf);
81 manufs++;
82 strcpy(manuf, line);
83 manuf_len = strlen(c);
84 if (manuf_len + 24 > MAX_NAME_SIZE) {
85 fprintf(stderr, "Line %d: manufacturer name too long\n", lino);
86 return 1;
87 }
88 fprintf(devf, "MANUF(%s,\"", manuf);
89 pq(devf, c);
90 fputs("\")\n", devf);
91 mode = 1;
92 } else {
93 err:
94 fprintf(stderr, "Line %d: Syntax error in mode %d: %s\n", lino, mode, line);
95 return 1;
96 }
97 }
98 fputs("ENDMANUF()\n\
99 \n\
100 #undef MANUF\n\
101 #undef PRODUCT\n\
102 #undef ENDMANUF\n", devf);
104 fclose(devf);
106 return 0;
107 }