diff options
author | Luca Boccassi <bluca@debian.org> | 2024-03-27 17:35:20 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2024-03-27 23:25:45 +0100 |
commit | e6bd341e7d94c8e73175ba58efcf7681d687d60f (patch) | |
tree | 553986ac2e8793d64d6b07b04e8fb6c30ca9a11d /src/analyze | |
parent | timedated: Respond on org.freedesktop.timedate1.SetNTP only when really finished (diff) | |
download | systemd-e6bd341e7d94c8e73175ba58efcf7681d687d60f.tar.xz systemd-e6bd341e7d94c8e73175ba58efcf7681d687d60f.zip |
analyze: fix plot with soft-reboot
Clamp times and start counting from when soft-reboot is started
to avoid creating a huge graph, like it's done for the user
instance.
Diffstat (limited to 'src/analyze')
-rw-r--r-- | src/analyze/analyze-plot.c | 10 | ||||
-rw-r--r-- | src/analyze/analyze-time-data.c | 48 |
2 files changed, 51 insertions, 7 deletions
diff --git a/src/analyze/analyze-plot.c b/src/analyze/analyze-plot.c index 6201b4facc..797f23ae85 100644 --- a/src/analyze/analyze-plot.c +++ b/src/analyze/analyze-plot.c @@ -316,7 +316,10 @@ static int produce_plot_as_svg( strempty(host->virtualization)); svg("<g transform=\"translate(%.3f,100)\">\n", 20.0 + (SCALE_X * boot->firmware_time)); - svg_graph_box(m, -(double) boot->firmware_time, boot->finish_time); + if (timestamp_is_set(boot->softreboot_start_time)) + svg_graph_box(m, 0, boot->finish_time); + else + svg_graph_box(m, -(double) boot->firmware_time, boot->finish_time); if (timestamp_is_set(boot->firmware_time)) { svg_bar("firmware", -(double) boot->firmware_time, -(double) boot->loader_time, y); @@ -344,6 +347,11 @@ static int produce_plot_as_svg( svg_text(true, boot->initrd_time, y, "initrd"); y++; } + if (timestamp_is_set(boot->softreboot_start_time)) { + svg_bar("soft-reboot", 0, boot->userspace_time, y); + svg_text(true, 0, y, "soft-reboot"); + y++; + } for (u = times; u->has_data; u++) { if (u->activating >= boot->userspace_time) diff --git a/src/analyze/analyze-time-data.c b/src/analyze/analyze-time-data.c index 7f8bcae999..bc03b4cbf7 100644 --- a/src/analyze/analyze-time-data.c +++ b/src/analyze/analyze-time-data.c @@ -82,10 +82,22 @@ int acquire_boot_times(sd_bus *bus, bool require_finished, BootTimes **ret) { if (require_finished && times.finish_time <= 0) return log_not_finished(times.finish_time); - if (arg_runtime_scope == RUNTIME_SCOPE_SYSTEM && times.softreboot_start_time > 0) + if (arg_runtime_scope == RUNTIME_SCOPE_SYSTEM && timestamp_is_set(times.softreboot_start_time)) { /* On soft-reboot ignore kernel/firmware/initrd times as they are from the previous boot */ times.firmware_time = times.loader_time = times.kernel_time = times.initrd_time = 0; - else if (arg_runtime_scope == RUNTIME_SCOPE_SYSTEM && times.security_start_time > 0) { + times.reverse_offset = times.softreboot_start_time; + + /* Clamp all timestamps to avoid showing huge graphs */ + if (timestamp_is_set(times.finish_time)) + subtract_timestamp(×.finish_time, times.reverse_offset); + subtract_timestamp(×.userspace_time, times.reverse_offset); + + subtract_timestamp(×.generators_start_time, times.reverse_offset); + subtract_timestamp(×.generators_finish_time, times.reverse_offset); + + subtract_timestamp(×.unitsload_start_time, times.reverse_offset); + subtract_timestamp(×.unitsload_finish_time, times.reverse_offset); + } else if (arg_runtime_scope == RUNTIME_SCOPE_SYSTEM && timestamp_is_set(times.security_start_time)) { /* security_start_time is set when systemd is not running under container environment. */ if (times.initrd_time > 0) times.kernel_done_time = times.initrd_time; @@ -187,7 +199,7 @@ int pretty_boot_time(sd_bus *bus, char **ret) { return log_oom(); if (timestamp_is_set(t->initrd_time) && !strextend(&text, FORMAT_TIMESPAN(t->userspace_time - t->initrd_time, USEC_PER_MSEC), " (initrd) + ")) return log_oom(); - if (timestamp_is_set(t->softreboot_start_time) && !strextend(&text, FORMAT_TIMESPAN(t->userspace_time - t->softreboot_start_time, USEC_PER_MSEC), " (soft reboot) + ")) + if (timestamp_is_set(t->softreboot_start_time) && !strextend(&text, FORMAT_TIMESPAN(t->userspace_time, USEC_PER_MSEC), " (soft reboot) + ")) return log_oom(); if (!strextend(&text, FORMAT_TIMESPAN(t->finish_time - t->userspace_time, USEC_PER_MSEC), " (userspace) ")) @@ -198,7 +210,13 @@ int pretty_boot_time(sd_bus *bus, char **ret) { return log_oom(); if (unit_id && timestamp_is_set(activated_time)) { - usec_t base = timestamp_is_set(t->userspace_time) ? t->userspace_time : t->reverse_offset; + usec_t base; + + /* On soft-reboot times are clamped to avoid showing huge graphs */ + if (timestamp_is_set(t->softreboot_start_time) && timestamp_is_set(t->userspace_time)) + base = t->userspace_time + t->reverse_offset; + else + base = timestamp_is_set(t->userspace_time) ? t->userspace_time : t->reverse_offset; if (!strextend(&text, "\n", unit_id, " reached after ", FORMAT_TIMESPAN(activated_time - base, USEC_PER_MSEC), " in userspace.")) return log_oom(); @@ -305,10 +323,28 @@ int acquire_time_data(sd_bus *bus, bool require_finished, UnitTimes **out) { return log_error_errno(r, "Failed to get timestamp properties of unit %s: %s", u.id, bus_error_message(&error, r)); + /* Activated in the previous soft-reboot iteration? Ignore it, we want new activations */ + if ((t->activated > 0 && t->activated < boot_times->softreboot_start_time) || + (t->activating > 0 && t->activating < boot_times->softreboot_start_time)) + continue; + subtract_timestamp(&t->activating, boot_times->reverse_offset); subtract_timestamp(&t->activated, boot_times->reverse_offset); - subtract_timestamp(&t->deactivating, boot_times->reverse_offset); - subtract_timestamp(&t->deactivated, boot_times->reverse_offset); + + /* If the last deactivation was in the previous soft-reboot, ignore it */ + if (timestamp_is_set(boot_times->softreboot_start_time)) { + if (t->deactivating < boot_times->reverse_offset) + t->deactivating = 0; + else + subtract_timestamp(&t->deactivating, boot_times->reverse_offset); + if (t->deactivated < boot_times->reverse_offset) + t->deactivated = 0; + else + subtract_timestamp(&t->deactivated, boot_times->reverse_offset); + } else { + subtract_timestamp(&t->deactivating, boot_times->reverse_offset); + subtract_timestamp(&t->deactivated, boot_times->reverse_offset); + } if (t->activated >= t->activating) t->time = t->activated - t->activating; |