Implement boot time analysis framework.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-03-19 20:25:09 +01:00
parent e5a2dd7b55
commit e744219bb6
14 changed files with 232 additions and 8 deletions

View file

@ -648,7 +648,10 @@ grub_dl_load_core (void *addr, grub_size_t size)
grub_dprintf ("modules", "module name: %s\n", mod->name);
grub_dprintf ("modules", "init function: %p\n", mod->init);
grub_boot_time ("Initing module %s", mod->name);
grub_dl_call_init (mod);
grub_boot_time ("Module %s inited", mod->name);
if (grub_dl_add (mod))
{

View file

@ -254,6 +254,8 @@ grub_main (void)
/* First of all, initialize the machine. */
grub_machine_init ();
grub_boot_time ("After machine init.");
/* Hello. */
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
grub_printf ("Welcome to GRUB!\n\n");
@ -261,6 +263,8 @@ grub_main (void)
grub_load_config ();
grub_boot_time ("Before loading embedded modules.");
/* Load pre-loaded modules and free the space. */
grub_register_exported_symbols ();
#ifdef GRUB_LINKER_HAVE_INIT
@ -268,6 +272,8 @@ grub_main (void)
#endif
grub_load_modules ();
grub_boot_time ("After loading embedded modules.");
/* It is better to set the root device as soon as possible,
for convenience. */
grub_set_prefix_and_root ();
@ -277,11 +283,17 @@ grub_main (void)
/* Reclaim space used for modules. */
reclaim_module_space ();
grub_boot_time ("After reclaiming module space.");
grub_register_core_commands ();
grub_boot_time ("Before execution of embedded config.");
if (load_config)
grub_parser_execute (load_config);
grub_boot_time ("After execution of embedded config. Attempt to go to normal mode");
grub_load_normal_mode ();
grub_rescue_run ();
}

View file

@ -1130,3 +1130,42 @@ void __deregister_frame_info (void)
}
#endif
#if BOOT_TIME_STATS
#include <grub/time.h>
struct grub_boot_time *grub_boot_time_head;
static struct grub_boot_time **boot_time_last = &grub_boot_time_head;
void
grub_real_boot_time (const char *file,
const int line,
const char *fmt, ...)
{
struct grub_boot_time *n;
va_list args;
grub_error_push ();
n = grub_malloc (sizeof (*n));
if (!n)
{
grub_errno = 0;
grub_error_pop ();
return;
}
n->file = file;
n->line = line;
n->tp = grub_get_time_ms ();
n->next = 0;
va_start (args, fmt);
n->msg = grub_xvasprintf (fmt, args);
va_end (args);
*boot_time_last = n;
boot_time_last = &n->next;
grub_errno = 0;
grub_error_pop ();
}
#endif