bootstat write timing to the kernel.
BUG=chromium-os:19176
TEST=Test it on ChromeOS, and /sys/kernel/debug/bootstat/report contains
all timings written by bootstat.
Change-Id: I25a2e0aec1b24f52047c7bc97f0ad40f78009a8b
Reviewed-on: http://gerrit.chromium.org/gerrit/6598
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Da Zheng <zhengda@chromium.org>
diff --git a/bootstat_log.c b/bootstat_log.c
index a0ba760..2d72c77 100644
--- a/bootstat_log.c
+++ b/bootstat_log.c
@@ -11,6 +11,7 @@
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
+#include <string.h>
#include <sys/fcntl.h>
#include <sys/param.h>
@@ -18,6 +19,8 @@
#include <sys/types.h>
#include <unistd.h>
+static const char kBootstageMarkFile[] = "/sys/kernel/debug/bootstage/mark";
+
//
// Default path to directory where output statistics will be stored.
//
@@ -90,9 +93,26 @@
(void)close(ifd);
}
+static void write_mark(const char *event_name)
+{
+ ssize_t ret __attribute__((unused));
+ int fd = open(kBootstageMarkFile, O_WRONLY);
+
+ if (fd < 0) {
+ return;
+ }
+
+ /*
+ * It's not necessary to check the return value,
+ * but the compiler will generate a warning if we don't.
+ */
+ ret = write(fd, event_name, strlen(event_name));
+ close(fd);
+}
void bootstat_log(const char* event_name)
{
+ write_mark(event_name);
append_logdata(uptime_statistics_file_name, "uptime", event_name);
append_logdata(disk_statistics_file_name, "disk", event_name);
}