mirror of
https://github.com/systemd/systemd.git
synced 2024-11-06 08:26:52 +03:00
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 <watanabe.yu+github@gmail.com>) v3: fixes one more condition (by Kirill Marinushkin <kmarinushkin@de.adit-jv.com>)
This commit is contained in:
parent
eddb5037f1
commit
02be0ccad2
@ -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++;
|
||||
|
Loading…
Reference in New Issue
Block a user