From: eLinux.org

Tims Fastboot Tools

This page has materials to support Tim Bird’s presentation “Tools and
Techniques for Reducing Bootup
Time
“.
This presentation was first delivered at the Embedded Linux Conference,
Europe, in November of 2008.

Contents

safe-to-call-sched-clock.patch

This patch was used by Tim for several kernel versions, to address
problems with the printk-times feature on ARM platforms. It is very
simple, and consists of just adding a flag to avoid calling
sched_clock() too early.

This patch appears (as of kernel version 2.6.27) to be obsolete. The
2.6.27 kernel now calls cpu_clock() for printk_times. This uses a
similar mechanism to flag when it is safe to call.

Here’s the patch:

  1. On most platforms, printk_clock() calls sched_clock(), which provides good
  2. timestamp resolution. However, most ARM boards use a timer source for
  3. sched_clock() which must be initialized at boot. If sched_clock() is called
  4. too early, the machine hangs. This code utilizes the default jiffies-based
  5. value for printk_clock, until told that sched_clock() is safe. This is
  6. almost always 0 before the clock is initialized, so this patch causes
  7. no loss of timing data, or confusing time switchover mid-boot.
  8. OMAP support is included.
  9. To utilize this on other ARM platforms, just add "safe_to_call_sched_clock=1"
  10. in the timer initialization code for your platform, when it is safe to call
  11. sched_clock().
  12. Signed-off-by: Tim Bird <tim.bird@am.sony.com>
  13. ChangeLog:
  14. 2008/02/05
  15. Location: alp@oak--linux-3/alp-linux--dev-3--3.1
  16. First changelog version.
  17. ---
  18. arch/arm/kernel/time.c | 8 7 + 1 - 0 !
  19. arch/arm/mach-omap1/time.c | 3 3 + 0 - 0 !
  20. include/asm-arm/mach/time.h | 2 2 + 0 - 0 !
  21. 3 files changed, 12 insertions(+), 1 deletion(-)
  22. Index: alp-linux/arch/arm/kernel/time.c
  23. ===================================================================
  24. --- alp-linux.orig/arch/arm/kernel/time.c
  25. +++ alp-linux/arch/arm/kernel/time.c
  26. @@ -84,10 +84,16 @@ static unsigned long dummy_gettimeoffset
  27. * sched_clock(). This avoids non-bootable kernels when
  28. * printk_clock is enabled.
  29. */
  30. +int safe_to_call_sched_clock = 0;
  31. +
  32. unsigned long long printk_clock(void)
  33. {
  34. - return (unsigned long long)(jiffies - INITIAL_JIFFIES) *
  35. + if (likely(safe_to_call_sched_clock)) {
  36. + return sched_clock();
  37. + } else {
  38. + return (unsigned long long)(jiffies - INITIAL_JIFFIES) *
  39. (1000000000 / HZ);
  40. + }
  41. }
  42. static unsigned long next_rtc_update;
  43. Index: alp-linux/arch/arm/mach-omap1/time.c
  44. ===================================================================
  45. --- alp-linux.orig/arch/arm/mach-omap1/time.c
  46. +++ alp-linux/arch/arm/mach-omap1/time.c
  47. @@ -255,6 +255,9 @@ static void __init omap_init_clocksource
  48. setup_irq(INT_TIMER2, &omap_mpu_timer2_irq);
  49. omap_mpu_timer_start(1, ~0, 1);
  50. + /* allow calls to sched_clock now */
  51. + safe_to_call_sched_clock = 1;
  52. +
  53. if (clocksource_register(&clocksource_mpu))
  54. printk(err, clocksource_mpu.name);
  55. }
  56. Index: alp-linux/include/asm-arm/mach/time.h
  57. ===================================================================
  58. --- alp-linux.orig/include/asm-arm/mach/time.h
  59. +++ alp-linux/include/asm-arm/mach/time.h
  60. @@ -76,4 +76,6 @@ extern int (*set_rtc)(void);
  61. extern void save_time_delta(struct timespec *delta, struct timespec *rtc);
  62. extern void restore_time_delta(struct timespec *delta, struct timespec *rtc);
  63. +extern int safe_to_call_sched_clock;
  64. +
  65. #endif

grabserial

“grabserial” is a simple program to grab and display data from a
specified serial port. It can place a timestamp on each line received,
which makes it useful for reporting timing of events seen on a booting
system’s serial console output.

See Grabserial for detailed information,
sample output and download instructions.

Tim’s quick and dirty process trace

Process trace is Tim’s quick and dirty method of tracing early boot
processes. As I write this (Oct, 2008), an boot tracer is being written
and is available in the fastboot git tree on kernel.org. This will
likely be mainlined, and should supersede this work. However, this tool
has worked for me.

This is really quite simple. The “system” consists of a patch which adds
printks to fork, exec and exit, and a script which parses those printks
and prints information about the reported processes.

Patch Download

Here is the patch: Media:
tims_process_trace.patch

This patch was written against Linux kernel version 2.6.27.

Usage

To use this patch, apply it to your kernel, with something like:

  1. cd linux_src ; patch -p1 </path/to/patch/tims_process_trace.patch

You should also increase the size of your kernel log buffer (this is the
buffer where printk messages are stored in the kernel.) I recommend a
value of 18, which is 256K. This is CONFIG_LOG_BUF_SHIFT, and is
found in the “General Setup” menu of the kernel configuration system.

Compile, build and install your kernel. Boot the kernel.

After booting, use dmesg to collect the messages. Note that you need to
specify the (increased) size of the message buffer with the ‘-s’ option:

  1. dmesg -s 256000 >/tmp/bootlog.txt

Now, process the bootlog with the scripts/procgraph program.

  1. linux_src/scripts/proc_graph /tmp/bootlog.txt

This script is somewhat badly named. It does not generate a graph, but
just allows you to sort the processes by various attributes (start time,
duration, idle time, etc.) Actual graphing should be added “real soon
now”.

Deferred initcall

Using a short patch (available for kernel version 2.6.27) it is possible
to avoid running certain initcalls at bootup time. This can save time
during the critical, early portion of bootup. Later, deferred initcalls
can be run by triggering them from user space.

See Deferred Initcalls.

Categories: