ia64/linux-2.6.18-xen.hg

view scripts/checkstack.pl @ 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 #!/usr/bin/perl
3 # Check the stack usage of functions
4 #
5 # Copyright Joern Engel <joern@wh.fh-wedel.de>
6 # Inspired by Linus Torvalds
7 # Original idea maybe from Keith Owens
8 # s390 port and big speedup by Arnd Bergmann <arnd@bergmann-dalldorf.de>
9 # Mips port by Juan Quintela <quintela@mandrakesoft.com>
10 # IA64 port via Andreas Dilger
11 # Arm port by Holger Schurig
12 # sh64 port by Paul Mundt
13 # Random bits by Matt Mackall <mpm@selenic.com>
14 # M68k port by Geert Uytterhoeven and Andreas Schwab
15 #
16 # Usage:
17 # objdump -d vmlinux | stackcheck.pl [arch]
18 #
19 # TODO : Port to all architectures (one regex per arch)
21 # check for arch
22 #
23 # $re is used for two matches:
24 # $& (whole re) matches the complete objdump line with the stack growth
25 # $1 (first bracket) matches the size of the stack growth
26 #
27 # use anything else and feel the pain ;)
28 my (@stack, $re, $x, $xs);
29 {
30 my $arch = shift;
31 if ($arch eq "") {
32 $arch = `uname -m`;
33 }
35 $x = "[0-9a-f]"; # hex character
36 $xs = "[0-9a-f ]"; # hex character or space
37 if ($arch eq 'arm') {
38 #c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64
39 $re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o;
40 } elsif ($arch =~ /^i[3456]86$/) {
41 #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp
42 $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%esp$/o;
43 } elsif ($arch eq 'x86_64') {
44 # 2f60: 48 81 ec e8 05 00 00 sub $0x5e8,%rsp
45 $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%rsp$/o;
46 } elsif ($arch eq 'ia64') {
47 #e0000000044011fc: 01 0f fc 8c adds r12=-384,r12
48 $re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o;
49 } elsif ($arch eq 'm68k') {
50 # 2b6c: 4e56 fb70 linkw %fp,#-1168
51 # 1df770: defc ffe4 addaw #-28,%sp
52 $re = qr/.*(?:linkw %fp,|addaw )#-([0-9]{1,4})(?:,%sp)?$/o;
53 } elsif ($arch eq 'mips64') {
54 #8800402c: 67bdfff0 daddiu sp,sp,-16
55 $re = qr/.*daddiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
56 } elsif ($arch eq 'mips') {
57 #88003254: 27bdffe0 addiu sp,sp,-32
58 $re = qr/.*addiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
59 } elsif ($arch eq 'ppc') {
60 #c00029f4: 94 21 ff 30 stwu r1,-208(r1)
61 $re = qr/.*stwu.*r1,-($x{1,8})\(r1\)/o;
62 } elsif ($arch eq 'ppc64') {
63 #XXX
64 $re = qr/.*stdu.*r1,-($x{1,8})\(r1\)/o;
65 } elsif ($arch =~ /^s390x?$/) {
66 # 11160: a7 fb ff 60 aghi %r15,-160
67 $re = qr/.*ag?hi.*\%r15,-(([0-9]{2}|[3-9])[0-9]{2})/o;
68 } elsif ($arch =~ /^sh64$/) {
69 #XXX: we only check for the immediate case presently,
70 # though we will want to check for the movi/sub
71 # pair for larger users. -- PFM.
72 #a00048e0: d4fc40f0 addi.l r15,-240,r15
73 $re = qr/.*addi\.l.*r15,-(([0-9]{2}|[3-9])[0-9]{2}),r15/o;
74 } else {
75 print("wrong or unknown architecture\n");
76 exit
77 }
78 }
80 sub bysize($) {
81 my ($asize, $bsize);
82 ($asize = $a) =~ s/.*: *(.*)$/$1/;
83 ($bsize = $b) =~ s/.*: *(.*)$/$1/;
84 $bsize <=> $asize
85 }
87 #
88 # main()
89 #
90 my $funcre = qr/^$x* <(.*)>:$/;
91 my $func;
92 my $file, $lastslash;
94 while (my $line = <STDIN>) {
95 if ($line =~ m/$funcre/) {
96 $func = $1;
97 }
98 elsif ($line =~ m/(.*):\s*file format/) {
99 $file = $1;
100 $file =~ s/\.ko//;
101 $lastslash = rindex($file, "/");
102 if ($lastslash != -1) {
103 $file = substr($file, $lastslash + 1);
104 }
105 }
106 elsif ($line =~ m/$re/) {
107 my $size = $1;
108 $size = hex($size) if ($size =~ /^0x/);
110 if ($size > 0xf0000000) {
111 $size = - $size;
112 $size += 0x80000000;
113 $size += 0x80000000;
114 }
115 next if ($size > 0x10000000);
117 next if $line !~ m/^($xs*)/;
118 my $addr = $1;
119 $addr =~ s/ /0/g;
120 $addr = "0x$addr";
122 my $intro = "$addr $func [$file]:";
123 my $padlen = 56 - length($intro);
124 while ($padlen > 0) {
125 $intro .= ' ';
126 $padlen -= 8;
127 }
128 next if ($size < 100);
129 push @stack, "$intro$size\n";
130 }
131 }
133 print sort bysize @stack;