| 1 | |
| 2 |
|
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 |
|
| 25 |
|
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 |
|
| 40 | my %start, %end;
|
| 41 | my $done = 0;
|
| 42 | my $maxtime = 0;
|
| 43 | my $firsttime = 100;
|
| 44 | my $count = 0;
|
| 45 | my %pids;
|
| 46 |
|
| 47 | while (<>) {
|
| 48 | my $line = $_;
|
| 49 | if ($line =~ /([0-9\.]+)\] calling ([a-zA-Z0-9\_]+)\+/) {
|
| 50 | my $func = $2;
|
| 51 | if ($done == 0) {
|
| 52 | $start{$func} = $1;
|
| 53 | if ($1 < $firsttime) {
|
| 54 | $firsttime = $1;
|
| 55 | }
|
| 56 | }
|
| 57 | if ($line =~ /\@ ([0-9]+)/) {
|
| 58 | $pids{$func} = $1;
|
| 59 | }
|
| 60 | $count = $count + 1;
|
| 61 | }
|
| 62 |
|
| 63 | if ($line =~ /([0-9\.]+)\] initcall ([a-zA-Z0-9\_]+)\+.*returned/) {
|
| 64 | if ($done == 0) {
|
| 65 | $end{$2} = $1;
|
| 66 | $maxtime = $1;
|
| 67 | }
|
| 68 | }
|
| 69 | if ($line =~ /Write protecting the/) {
|
| 70 | $done = 1;
|
| 71 | }
|
| 72 | if ($line =~ /Freeing unused kernel memory/) {
|
| 73 | $done = 1;
|
| 74 | }
|
| 75 | }
|
| 76 |
|
| 77 | if ($count == 0) {
|
| 78 | print "No data found in the dmesg. Make sure that 'printk.time=1' and\n";
|
| 79 | print "'initcall_debug' are passed on the kernel command line.\n\n";
|
| 80 | print "Usage: \n";
|
| 81 | print " dmesg | perl scripts/bootgraph.pl > output.svg\n\n";
|
| 82 | exit;
|
| 83 | }
|
| 84 |
|
| 85 | print "<?xml version=\"1.0\" standalone=\"no\"?> \n";
|
| 86 | print "<svg width=\"1000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n";
|
| 87 |
|
| 88 | my @styles;
|
| 89 |
|
| 90 | $styles[0] = "fill:rgb(0,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
|
| 91 | $styles[1] = "fill:rgb(0,255,0);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
|
| 92 | $styles[2] = "fill:rgb(255,0,20);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
|
| 93 | $styles[3] = "fill:rgb(255,255,20);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
|
| 94 | $styles[4] = "fill:rgb(255,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
|
| 95 | $styles[5] = "fill:rgb(0,255,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
|
| 96 | $styles[6] = "fill:rgb(0,128,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
|
| 97 | $styles[7] = "fill:rgb(0,255,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
|
| 98 | $styles[8] = "fill:rgb(255,0,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
|
| 99 | $styles[9] = "fill:rgb(255,255,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
|
| 100 | $styles[10] = "fill:rgb(255,128,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
|
| 101 | $styles[11] = "fill:rgb(128,255,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
|
| 102 |
|
| 103 | my $mult = 950.0 / ($maxtime - $firsttime);
|
| 104 | my $threshold = ($maxtime - $firsttime) / 60.0;
|
| 105 | my $stylecounter = 0;
|
| 106 | my %rows;
|
| 107 | my $rowscount = 1;
|
| 108 | while (($key,$value) = each %start) {
|
| 109 | my $duration = $end{$key} - $start{$key};
|
| 110 |
|
| 111 | if ($duration >= $threshold) {
|
| 112 | my $s, $s2, $e, $y;
|
| 113 | $pid = $pids{$key};
|
| 114 |
|
| 115 | if (!defined($rows{$pid})) {
|
| 116 | $rows{$pid} = $rowscount;
|
| 117 | $rowscount = $rowscount + 1;
|
| 118 | }
|
| 119 | $s = ($value - $firsttime) * $mult;
|
| 120 | $s2 = $s + 6;
|
| 121 | $e = ($end{$key} - $firsttime) * $mult;
|
| 122 | $w = $e - $s;
|
| 123 |
|
| 124 | $y = $rows{$pid} * 150;
|
| 125 | $y2 = $y + 4;
|
| 126 |
|
| 127 | $style = $styles[$stylecounter];
|
| 128 | $stylecounter = $stylecounter + 1;
|
| 129 | if ($stylecounter > 11) {
|
| 130 | $stylecounter = 0;
|
| 131 | };
|
| 132 |
|
| 133 | print "<rect x=\"$s\" width=\"$w\" y=\"$y\" height=\"145\" style=\"$style\"/>\n";
|
| 134 | print "<text transform=\"translate($s2,$y2) rotate(90)\">$key</text>\n";
|
| 135 | }
|
| 136 | }
|
| 137 |
|
| 138 |
|
| 139 | |
| 140 | my $time = $firsttime;
|
| 141 | my $step = ($maxtime - $firsttime) / 15;
|
| 142 | while ($time < $maxtime) {
|
| 143 | my $s2 = ($time - $firsttime) * $mult;
|
| 144 | my $tm = int($time * 100) / 100.0;
|
| 145 | print "<text transform=\"translate($s2,89) rotate(90)\">$tm</text>\n";
|
| 146 | $time = $time + $step;
|
| 147 | }
|
| 148 |
|
| 149 | print "</svg>\n";
|