From 02be0ccad2fbf36a585b0374bf220e5477983cf2 Mon Sep 17 00:00:00 2001 From: Kirill Marinushkin Date: Mon, 6 Aug 2018 18:27:33 +0900 Subject: [PATCH] analyze: fix condition for pretty printing kernel time On target boards without RTC, `t->kernel_time` is 0 or 1 usec. `systemd-analyze` reads this value over D-Bus from `org.freedesktop.systemd1.Manager`, property `KernelTimestamp`. The issue is: if `t->kernel_time` is 0, `systemd-analyze` does not print the kernel time: ~~~~ $ systemd-analyze Startup finished in 1.860s (userspace) = 5.957s ~~~~ This commit fixes the misbehaviour: ~~~~ $ systemd-analyze Startup finished in 3.866s (kernel) + 2.015s (userspace) = 5.881s ~~~~ Fixes #7721. v2: fixes one more condition (by Yu Watanabe ) v3: fixes one more condition (by Kirill Marinushkin ) --- src/analyze/analyze.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index a2f85a64471..1becf759c31 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -528,13 +528,13 @@ static int pretty_boot_time(sd_bus *bus, char **_buf) { size = strpcpyf(&ptr, size, "%s (firmware) + ", format_timespan(ts, sizeof(ts), t->firmware_time - t->loader_time, USEC_PER_MSEC)); if (t->loader_time > 0) size = strpcpyf(&ptr, size, "%s (loader) + ", format_timespan(ts, sizeof(ts), t->loader_time, USEC_PER_MSEC)); - if (t->kernel_time > 0) + if (t->kernel_done_time > 0) size = strpcpyf(&ptr, size, "%s (kernel) + ", format_timespan(ts, sizeof(ts), t->kernel_done_time, USEC_PER_MSEC)); if (t->initrd_time > 0) size = strpcpyf(&ptr, size, "%s (initrd) + ", format_timespan(ts, sizeof(ts), t->userspace_time - t->initrd_time, USEC_PER_MSEC)); size = strpcpyf(&ptr, size, "%s (userspace) ", format_timespan(ts, sizeof(ts), t->finish_time - t->userspace_time, USEC_PER_MSEC)); - if (t->kernel_time > 0) + if (t->kernel_done_time > 0) strpcpyf(&ptr, size, "= %s ", format_timespan(ts, sizeof(ts), t->firmware_time + t->finish_time, USEC_PER_MSEC)); if (unit_id && activated_time > 0 && activated_time != USEC_INFINITY) { @@ -650,7 +650,7 @@ static int analyze_plot(int argc, char *argv[], void *userdata) { } if (boot->initrd_time > 0) m++; - if (boot->kernel_time > 0) + if (boot->kernel_done_time > 0) m++; for (u = times; u->has_data; u++) { @@ -750,7 +750,7 @@ static int analyze_plot(int argc, char *argv[], void *userdata) { svg_text(true, -(double) boot->loader_time, y, "loader"); y++; } - if (boot->kernel_time > 0) { + if (boot->kernel_done_time > 0) { svg_bar("kernel", 0, boot->kernel_done_time, y); svg_text(true, 0, y, "kernel"); y++;