aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-14 15:28:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-14 15:28:02 -0400
commit2d51b75370d83535883c66521b03fcd6a1f1f68d (patch)
tree68e7bb018a80207781719795828434dfcf3b9bf6
parent93f78da405685a756beeaeae4b5e41fcec39eab3 (diff)
parentce52aebd0219edc7a783278fbe80a6ccca0556c0 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arjan/linux-2.6-fastboot
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arjan/linux-2.6-fastboot: raid, fastboot: hide RAID autodetect option if MD is compiled as a module raid: make RAID autodetect default a KConfig option warning: fix init do_mounts_md c fastboot: make the RAID autostart code print a message just before waiting fastboot: make the raid autodetect code wait for all devices to init fastboot: Fix bootgraph.pl initcall name regexp fastboot: fix issues and improve output of bootgraph.pl Add a script to visualize the kernel boot process / time
-rw-r--r--drivers/md/Kconfig14
-rw-r--r--init/do_mounts_md.c40
-rw-r--r--init/main.c2
-rw-r--r--scripts/bootgraph.pl147
4 files changed, 193 insertions, 10 deletions
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index 07d92c11b5d8..2281b5098e95 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -30,6 +30,20 @@ config BLK_DEV_MD
30 30
31 If unsure, say N. 31 If unsure, say N.
32 32
33config MD_AUTODETECT
34 bool "Autodetect RAID arrays during kernel boot"
35 depends on BLK_DEV_MD=y
36 default y
37 ---help---
38 If you say Y here, then the kernel will try to autodetect raid
39 arrays as part of its boot process.
40
41 If you don't use raid and say Y, this autodetection can cause
42 a several-second delay in the boot time due to various
43 synchronisation steps that are part of this step.
44
45 If unsure, say Y.
46
33config MD_LINEAR 47config MD_LINEAR
34 tristate "Linear (append) mode" 48 tristate "Linear (append) mode"
35 depends on BLK_DEV_MD 49 depends on BLK_DEV_MD
diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
index 693d24694a6c..48b3fadd83ed 100644
--- a/init/do_mounts_md.c
+++ b/init/do_mounts_md.c
@@ -12,7 +12,12 @@
12 * The code for that is here. 12 * The code for that is here.
13 */ 13 */
14 14
15static int __initdata raid_noautodetect, raid_autopart; 15#ifdef CONFIG_MD_AUTODETECT
16static int __initdata raid_noautodetect;
17#else
18static int __initdata raid_noautodetect=1;
19#endif
20static int __initdata raid_autopart;
16 21
17static struct { 22static struct {
18 int minor; 23 int minor;
@@ -252,6 +257,8 @@ static int __init raid_setup(char *str)
252 257
253 if (!strncmp(str, "noautodetect", wlen)) 258 if (!strncmp(str, "noautodetect", wlen))
254 raid_noautodetect = 1; 259 raid_noautodetect = 1;
260 if (!strncmp(str, "autodetect", wlen))
261 raid_noautodetect = 0;
255 if (strncmp(str, "partitionable", wlen)==0) 262 if (strncmp(str, "partitionable", wlen)==0)
256 raid_autopart = 1; 263 raid_autopart = 1;
257 if (strncmp(str, "part", wlen)==0) 264 if (strncmp(str, "part", wlen)==0)
@@ -264,17 +271,32 @@ static int __init raid_setup(char *str)
264__setup("raid=", raid_setup); 271__setup("raid=", raid_setup);
265__setup("md=", md_setup); 272__setup("md=", md_setup);
266 273
274static void autodetect_raid(void)
275{
276 int fd;
277
278 /*
279 * Since we don't want to detect and use half a raid array, we need to
280 * wait for the known devices to complete their probing
281 */
282 printk(KERN_INFO "md: Waiting for all devices to be available before autodetect\n");
283 printk(KERN_INFO "md: If you don't use raid, use raid=noautodetect\n");
284 while (driver_probe_done() < 0)
285 msleep(100);
286 fd = sys_open("/dev/md0", 0, 0);
287 if (fd >= 0) {
288 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
289 sys_close(fd);
290 }
291}
292
267void __init md_run_setup(void) 293void __init md_run_setup(void)
268{ 294{
269 create_dev("/dev/md0", MKDEV(MD_MAJOR, 0)); 295 create_dev("/dev/md0", MKDEV(MD_MAJOR, 0));
296
270 if (raid_noautodetect) 297 if (raid_noautodetect)
271 printk(KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=noautodetect)\n"); 298 printk(KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=autodetect will force)\n");
272 else { 299 else
273 int fd = sys_open("/dev/md0", 0, 0); 300 autodetect_raid();
274 if (fd >= 0) {
275 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
276 sys_close(fd);
277 }
278 }
279 md_setup_drive(); 301 md_setup_drive();
280} 302}
diff --git a/init/main.c b/init/main.c
index 3820323c4c84..27f6bf6108e9 100644
--- a/init/main.c
+++ b/init/main.c
@@ -708,7 +708,7 @@ int do_one_initcall(initcall_t fn)
708 int result; 708 int result;
709 709
710 if (initcall_debug) { 710 if (initcall_debug) {
711 printk("calling %pF\n", fn); 711 printk("calling %pF @ %i\n", fn, task_pid_nr(current));
712 t0 = ktime_get(); 712 t0 = ktime_get();
713 } 713 }
714 714
diff --git a/scripts/bootgraph.pl b/scripts/bootgraph.pl
new file mode 100644
index 000000000000..2243353fe55d
--- /dev/null
+++ b/scripts/bootgraph.pl
@@ -0,0 +1,147 @@
1#!/usr/bin/perl
2
3# Copyright 2008, Intel Corporation
4#
5# This file is part of the Linux kernel
6#
7# This program file is free software; you can redistribute it and/or modify it
8# under the terms of the GNU General Public License as published by the
9# Free Software Foundation; version 2 of the License.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14# for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program in a file named COPYING; if not, write to the
18# Free Software Foundation, Inc.,
19# 51 Franklin Street, Fifth Floor,
20# Boston, MA 02110-1301 USA
21#
22# Authors:
23# Arjan van de Ven <arjan@linux.intel.com>
24
25
26#
27# This script turns a dmesg output into a SVG graphic that shows which
28# functions take how much time. You can view SVG graphics with various
29# programs, including Inkscape, The Gimp and Firefox.
30#
31#
32# For this script to work, the kernel needs to be compiled with the
33# CONFIG_PRINTK_TIME configuration option enabled, and with
34# "initcall_debug" passed on the kernel command line.
35#
36# usage:
37# dmesg | perl scripts/bootgraph.pl > output.svg
38#
39
40my @rows;
41my %start, %end, %row;
42my $done = 0;
43my $rowcount = 0;
44my $maxtime = 0;
45my $firsttime = 100;
46my $count = 0;
47while (<>) {
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 $row{$func} = 1;
58 if ($line =~ /\@ ([0-9]+)/) {
59 my $pid = $1;
60 if (!defined($rows[$pid])) {
61 $rowcount = $rowcount + 1;
62 $rows[$pid] = $rowcount;
63 }
64 $row{$func} = $rows[$pid];
65 }
66 $count = $count + 1;
67 }
68
69 if ($line =~ /([0-9\.]+)\] initcall ([a-zA-Z0-9\_]+)\+.*returned/) {
70 if ($done == 0) {
71 $end{$2} = $1;
72 $maxtime = $1;
73 }
74 }
75 if ($line =~ /Write protecting the/) {
76 $done = 1;
77 }
78 if ($line =~ /Freeing unused kernel memory/) {
79 $done = 1;
80 }
81}
82
83if ($count == 0) {
84 print "No data found in the dmesg. Make sure that 'printk.time=1' and\n";
85 print "'initcall_debug' are passed on the kernel command line.\n\n";
86 print "Usage: \n";
87 print " dmesg | perl scripts/bootgraph.pl > output.svg\n\n";
88 exit;
89}
90
91print "<?xml version=\"1.0\" standalone=\"no\"?> \n";
92print "<svg width=\"1000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n";
93
94my @styles;
95
96$styles[0] = "fill:rgb(0,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
97$styles[1] = "fill:rgb(0,255,0);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
98$styles[2] = "fill:rgb(255,0,20);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
99$styles[3] = "fill:rgb(255,255,20);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
100$styles[4] = "fill:rgb(255,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
101$styles[5] = "fill:rgb(0,255,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
102$styles[6] = "fill:rgb(0,128,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
103$styles[7] = "fill:rgb(0,255,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
104$styles[8] = "fill:rgb(255,0,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
105$styles[9] = "fill:rgb(255,255,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
106$styles[10] = "fill:rgb(255,128,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
107$styles[11] = "fill:rgb(128,255,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
108
109my $mult = 950.0 / ($maxtime - $firsttime);
110my $threshold = ($maxtime - $firsttime) / 60.0;
111my $stylecounter = 0;
112while (($key,$value) = each %start) {
113 my $duration = $end{$key} - $start{$key};
114
115 if ($duration >= $threshold) {
116 my $s, $s2, $e, $y;
117 $s = ($value - $firsttime) * $mult;
118 $s2 = $s + 6;
119 $e = ($end{$key} - $firsttime) * $mult;
120 $w = $e - $s;
121
122 $y = $row{$key} * 150;
123 $y2 = $y + 4;
124
125 $style = $styles[$stylecounter];
126 $stylecounter = $stylecounter + 1;
127 if ($stylecounter > 11) {
128 $stylecounter = 0;
129 };
130
131 print "<rect x=\"$s\" width=\"$w\" y=\"$y\" height=\"145\" style=\"$style\"/>\n";
132 print "<text transform=\"translate($s2,$y2) rotate(90)\">$key</text>\n";
133 }
134}
135
136
137# print the time line on top
138my $time = $firsttime;
139my $step = ($maxtime - $firsttime) / 15;
140while ($time < $maxtime) {
141 my $s2 = ($time - $firsttime) * $mult;
142 my $tm = int($time * 100) / 100.0;
143 print "<text transform=\"translate($s2,89) rotate(90)\">$tm</text>\n";
144 $time = $time + $step;
145}
146
147print "</svg>\n";