ia64/linux-2.6.18-xen.hg

view arch/sparc/lib/memscan.S @ 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 /* $Id: memscan.S,v 1.4 1996/09/08 02:01:20 davem Exp $
2 * memscan.S: Optimized memscan for the Sparc.
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
7 /* In essence, this is just a fancy strlen. */
9 #define LO_MAGIC 0x01010101
10 #define HI_MAGIC 0x80808080
12 .text
13 .align 4
14 .globl __memscan_zero, __memscan_generic
15 .globl memscan
16 __memscan_zero:
17 /* %o0 = addr, %o1 = size */
18 cmp %o1, 0
19 bne,a 1f
20 andcc %o0, 3, %g0
22 retl
23 nop
25 1:
26 be mzero_scan_word
27 sethi %hi(HI_MAGIC), %g2
29 ldsb [%o0], %g3
30 mzero_still_not_word_aligned:
31 cmp %g3, 0
32 bne 1f
33 add %o0, 1, %o0
35 retl
36 sub %o0, 1, %o0
38 1:
39 subcc %o1, 1, %o1
40 bne,a 1f
41 andcc %o0, 3, %g0
43 retl
44 nop
46 1:
47 bne,a mzero_still_not_word_aligned
48 ldsb [%o0], %g3
50 sethi %hi(HI_MAGIC), %g2
51 mzero_scan_word:
52 or %g2, %lo(HI_MAGIC), %o3
53 sethi %hi(LO_MAGIC), %g3
54 or %g3, %lo(LO_MAGIC), %o2
55 mzero_next_word:
56 ld [%o0], %g2
57 mzero_next_word_preloaded:
58 sub %g2, %o2, %g2
59 mzero_next_word_preloaded_next:
60 andcc %g2, %o3, %g0
61 bne mzero_byte_zero
62 add %o0, 4, %o0
64 mzero_check_out_of_fuel:
65 subcc %o1, 4, %o1
66 bg,a 1f
67 ld [%o0], %g2
69 retl
70 nop
72 1:
73 b mzero_next_word_preloaded_next
74 sub %g2, %o2, %g2
76 /* Check every byte. */
77 mzero_byte_zero:
78 ldsb [%o0 - 4], %g2
79 cmp %g2, 0
80 bne mzero_byte_one
81 sub %o0, 4, %g3
83 retl
84 mov %g3, %o0
86 mzero_byte_one:
87 ldsb [%o0 - 3], %g2
88 cmp %g2, 0
89 bne,a mzero_byte_two_and_three
90 ldsb [%o0 - 2], %g2
92 retl
93 sub %o0, 3, %o0
95 mzero_byte_two_and_three:
96 cmp %g2, 0
97 bne,a 1f
98 ldsb [%o0 - 1], %g2
100 retl
101 sub %o0, 2, %o0
103 1:
104 cmp %g2, 0
105 bne,a mzero_next_word_preloaded
106 ld [%o0], %g2
108 retl
109 sub %o0, 1, %o0
111 mzero_found_it:
112 retl
113 sub %o0, 2, %o0
115 memscan:
116 __memscan_generic:
117 /* %o0 = addr, %o1 = c, %o2 = size */
118 cmp %o2, 0
119 bne,a 0f
120 ldub [%o0], %g2
122 b,a 2f
123 1:
124 ldub [%o0], %g2
125 0:
126 cmp %g2, %o1
127 be 2f
128 addcc %o2, -1, %o2
129 bne 1b
130 add %o0, 1, %o0
131 2:
132 retl
133 nop