]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
analyze: show soft-reboot counter next to time deltas 32289/head
authorLuca Boccassi <bluca@debian.org>
Mon, 15 Apr 2024 23:23:59 +0000 (00:23 +0100)
committerLuca Boccassi <bluca@debian.org>
Mon, 15 Apr 2024 23:26:05 +0000 (00:26 +0100)
src/analyze/analyze-time-data.c
src/analyze/analyze-time-data.h

index 36f479db7d51ecb7448f2900ace597a57d1b06e1..94f6031893d6141e00ca5b998c50330818580cc8 100644 (file)
@@ -49,6 +49,7 @@ int acquire_boot_times(sd_bus *bus, bool require_finished, BootTimes **ret) {
                 { "InitRDGeneratorsFinishTimestampMonotonic", "t", NULL, offsetof(BootTimes, initrd_generators_finish_time) },
                 { "InitRDUnitsLoadStartTimestampMonotonic",   "t", NULL, offsetof(BootTimes, initrd_unitsload_start_time)   },
                 { "InitRDUnitsLoadFinishTimestampMonotonic",  "t", NULL, offsetof(BootTimes, initrd_unitsload_finish_time)  },
+                { "SoftRebootsCount",                         "t", NULL, offsetof(BootTimes, soft_reboots_count)            },
                 {},
         };
         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -85,9 +86,9 @@ int acquire_boot_times(sd_bus *bus, bool require_finished, BootTimes **ret) {
         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 =
-                                initrd_security_start_time = initrd_security_finish_time =
-                                initrd_generators_start_time = initrd_generators_finish_time =
-                                initrd_unitsload_start_time = initrd_unitsload_finish_time = 0;
+                                times.initrd_security_start_time = times.initrd_security_finish_time =
+                                times.initrd_generators_start_time = times.initrd_generators_finish_time =
+                                times.initrd_unitsload_start_time = times.initrd_unitsload_finish_time = 0;
                 times.reverse_offset = times.softreboot_start_time;
 
                 /* Clamp all timestamps to avoid showing huge graphs */
@@ -202,7 +203,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, USEC_PER_MSEC), " (soft reboot) + "))
+        if (timestamp_is_set(t->softreboot_start_time) && strextendf(&text, "%s (soft reboot #%" PRIu64 ") + ", FORMAT_TIMESPAN(t->userspace_time, USEC_PER_MSEC), t->soft_reboots_count) < 0)
                 return log_oom();
 
         if (!strextend(&text, FORMAT_TIMESPAN(t->finish_time - t->userspace_time, USEC_PER_MSEC), " (userspace) "))
index 72b1ede40246ada98f5439ddbf5ac3e299138d03..1932d59c3d4c6bafd50a4e379a194628c2e121c2 100644 (file)
@@ -27,6 +27,8 @@ typedef struct BootTimes {
         usec_t initrd_generators_finish_time;
         usec_t initrd_unitsload_start_time;
         usec_t initrd_unitsload_finish_time;
+        /* Not strictly a timestamp, but we are going to show it next to the other timestamps */
+        uint64_t soft_reboots_count;
 
         /*
          * If we're analyzing the user instance, all timestamps will be offset by its own start-up timestamp,