ia64/linux-2.6.18-xen.hg

view lib/gen_crc32table.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 #include <stdio.h>
2 #include "crc32defs.h"
3 #include <inttypes.h>
5 #define ENTRIES_PER_LINE 4
7 #define LE_TABLE_SIZE (1 << CRC_LE_BITS)
8 #define BE_TABLE_SIZE (1 << CRC_BE_BITS)
10 static uint32_t crc32table_le[LE_TABLE_SIZE];
11 static uint32_t crc32table_be[BE_TABLE_SIZE];
13 /**
14 * crc32init_le() - allocate and initialize LE table data
15 *
16 * crc is the crc of the byte i; other entries are filled in based on the
17 * fact that crctable[i^j] = crctable[i] ^ crctable[j].
18 *
19 */
20 static void crc32init_le(void)
21 {
22 unsigned i, j;
23 uint32_t crc = 1;
25 crc32table_le[0] = 0;
27 for (i = 1 << (CRC_LE_BITS - 1); i; i >>= 1) {
28 crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
29 for (j = 0; j < LE_TABLE_SIZE; j += 2 * i)
30 crc32table_le[i + j] = crc ^ crc32table_le[j];
31 }
32 }
34 /**
35 * crc32init_be() - allocate and initialize BE table data
36 */
37 static void crc32init_be(void)
38 {
39 unsigned i, j;
40 uint32_t crc = 0x80000000;
42 crc32table_be[0] = 0;
44 for (i = 1; i < BE_TABLE_SIZE; i <<= 1) {
45 crc = (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE : 0);
46 for (j = 0; j < i; j++)
47 crc32table_be[i + j] = crc ^ crc32table_be[j];
48 }
49 }
51 static void output_table(uint32_t table[], int len, char *trans)
52 {
53 int i;
55 for (i = 0; i < len - 1; i++) {
56 if (i % ENTRIES_PER_LINE == 0)
57 printf("\n");
58 printf("%s(0x%8.8xL), ", trans, table[i]);
59 }
60 printf("%s(0x%8.8xL)\n", trans, table[len - 1]);
61 }
63 int main(int argc, char** argv)
64 {
65 printf("/* this file is generated - do not edit */\n\n");
67 if (CRC_LE_BITS > 1) {
68 crc32init_le();
69 printf("static const u32 crc32table_le[] = {");
70 output_table(crc32table_le, LE_TABLE_SIZE, "tole");
71 printf("};\n");
72 }
74 if (CRC_BE_BITS > 1) {
75 crc32init_be();
76 printf("static const u32 crc32table_be[] = {");
77 output_table(crc32table_be, BE_TABLE_SIZE, "tobe");
78 printf("};\n");
79 }
81 return 0;
82 }