ia64/linux-2.6.18-xen.hg

view drivers/md/mktables.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 #ident "$Id: mktables.c,v 1.2 2002/12/12 22:41:27 hpa Exp $"
2 /* ----------------------------------------------------------------------- *
3 *
4 * Copyright 2002 H. Peter Anvin - All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 * Bostom MA 02111-1307, USA; either version 2 of the License, or
10 * (at your option) any later version; incorporated herein by reference.
11 *
12 * ----------------------------------------------------------------------- */
14 /*
15 * mktables.c
16 *
17 * Make RAID-6 tables. This is a host user space program to be run at
18 * compile time.
19 */
21 #include <stdio.h>
22 #include <string.h>
23 #include <inttypes.h>
24 #include <stdlib.h>
25 #include <time.h>
27 static uint8_t gfmul(uint8_t a, uint8_t b)
28 {
29 uint8_t v = 0;
31 while ( b ) {
32 if ( b & 1 ) v ^= a;
33 a = (a << 1) ^ (a & 0x80 ? 0x1d : 0);
34 b >>= 1;
35 }
36 return v;
37 }
39 static uint8_t gfpow(uint8_t a, int b)
40 {
41 uint8_t v = 1;
43 b %= 255;
44 if ( b < 0 )
45 b += 255;
47 while ( b ) {
48 if ( b & 1 ) v = gfmul(v,a);
49 a = gfmul(a,a);
50 b >>= 1;
51 }
52 return v;
53 }
55 int main(int argc, char *argv[])
56 {
57 int i, j, k;
58 uint8_t v;
59 uint8_t exptbl[256], invtbl[256];
61 printf("#include \"raid6.h\"\n");
63 /* Compute multiplication table */
64 printf("\nconst u8 __attribute__((aligned(256)))\n"
65 "raid6_gfmul[256][256] =\n"
66 "{\n");
67 for ( i = 0 ; i < 256 ; i++ ) {
68 printf("\t{\n");
69 for ( j = 0 ; j < 256 ; j += 8 ) {
70 printf("\t\t");
71 for ( k = 0 ; k < 8 ; k++ ) {
72 printf("0x%02x, ", gfmul(i,j+k));
73 }
74 printf("\n");
75 }
76 printf("\t},\n");
77 }
78 printf("};\n");
80 /* Compute power-of-2 table (exponent) */
81 v = 1;
82 printf("\nconst u8 __attribute__((aligned(256)))\n"
83 "raid6_gfexp[256] =\n"
84 "{\n");
85 for ( i = 0 ; i < 256 ; i += 8 ) {
86 printf("\t");
87 for ( j = 0 ; j < 8 ; j++ ) {
88 exptbl[i+j] = v;
89 printf("0x%02x, ", v);
90 v = gfmul(v,2);
91 if ( v == 1 ) v = 0; /* For entry 255, not a real entry */
92 }
93 printf("\n");
94 }
95 printf("};\n");
97 /* Compute inverse table x^-1 == x^254 */
98 printf("\nconst u8 __attribute__((aligned(256)))\n"
99 "raid6_gfinv[256] =\n"
100 "{\n");
101 for ( i = 0 ; i < 256 ; i += 8 ) {
102 printf("\t");
103 for ( j = 0 ; j < 8 ; j++ ) {
104 invtbl[i+j] = v = gfpow(i+j,254);
105 printf("0x%02x, ", v);
106 }
107 printf("\n");
108 }
109 printf("};\n");
111 /* Compute inv(2^x + 1) (exponent-xor-inverse) table */
112 printf("\nconst u8 __attribute__((aligned(256)))\n"
113 "raid6_gfexi[256] =\n"
114 "{\n");
115 for ( i = 0 ; i < 256 ; i += 8 ) {
116 printf("\t");
117 for ( j = 0 ; j < 8 ; j++ ) {
118 printf("0x%02x, ", invtbl[exptbl[i+j]^1]);
119 }
120 printf("\n");
121 }
122 printf("};\n\n");
124 return 0;
125 }