Merge pull request #32289 from bluca/counter

soft-reboot counter follow-ups
This commit is contained in:
Luca Boccassi 2024-04-16 10:44:25 +02:00 committed by GitHub
commit 3721f9620c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 4 deletions

View file

@ -1792,7 +1792,7 @@ node /org/freedesktop/systemd1 {
file system paths encoded as strings.</para>
<para><varname>SoftRebootsCount</varname> encodes how many soft-reboots were successfully completed
since the last full boot.</para>
since the last full boot. Starts at <literal>0</literal>.</para>
<para><varname>Virtualization</varname> contains a short ID string describing the virtualization
technology the system runs in. On bare-metal hardware this is the empty string. Otherwise, it contains

View 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;
@ -84,7 +85,10 @@ 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 = 0;
times.firmware_time = times.loader_time = times.kernel_time = times.initrd_time =
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 */
@ -199,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) "))

View 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,

View file

@ -3692,7 +3692,7 @@ static void manager_notify_finished(Manager *m) {
if (MANAGER_IS_SYSTEM(m) && dual_timestamp_is_set(&m->timestamps[MANAGER_TIMESTAMP_SOFTREBOOT_START])) {
/* The soft-reboot case, where we only report data for the last reboot */
firmware_usec = loader_usec = initrd_usec = kernel_usec = 0;
total_usec = userspace_usec = m->timestamps[MANAGER_TIMESTAMP_FINISH].monotonic - m->timestamps[MANAGER_TIMESTAMP_SOFTREBOOT_START].monotonic;
total_usec = userspace_usec = usec_sub_unsigned(m->timestamps[MANAGER_TIMESTAMP_FINISH].monotonic, m->timestamps[MANAGER_TIMESTAMP_SOFTREBOOT_START].monotonic);
log_struct(LOG_INFO,
"MESSAGE_ID=" SD_MESSAGE_STARTUP_FINISHED_STR,