[systemd-devel] [PATCH] systemd: record the userspace timestamp early

harald at redhat.com harald at redhat.com
Wed Apr 24 08:19:22 PDT 2013


From: Harald Hoyer <harald at redhat.com>

The time for systemd initialization and selinux policy loading
is accounted to the initrd or the kernel, which is wrong.

Instead of:

Startup finished in 5.559s (firmware) + 36ms (loader) + 665ms (kernel) +
975ms (initrd) + 1.410s (userspace) = 8.647s

the more correct output is:

Startup finished in 5.559s (firmware) + 36ms (loader) + 665ms (kernel) +
475ms (initrd) + 1.910s (userspace) = 8.647s
---
 src/core/main.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/core/main.c b/src/core/main.c
index ab2ac00..0b65841 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1236,6 +1236,7 @@ int main(int argc, char *argv[]) {
         bool reexecute = false;
         const char *shutdown_verb = NULL;
         dual_timestamp initrd_timestamp = { 0ULL, 0ULL };
+        dual_timestamp userspace_timestamp = { 0ULL, 0ULL };
         static char systemd[] = "systemd";
         bool skip_setup = false;
         int j;
@@ -1281,6 +1282,7 @@ int main(int argc, char *argv[]) {
         log_show_color(isatty(STDERR_FILENO) > 0);
 
         if (getpid() == 1 && detect_container(NULL) <= 0) {
+                dual_timestamp_get(&userspace_timestamp);
 
                 /* Running outside of a container as PID 1 */
                 arg_running_as = SYSTEMD_SYSTEM;
@@ -1610,6 +1612,9 @@ int main(int argc, char *argv[]) {
 
         manager_set_default_rlimits(m, arg_default_rlimit);
 
+	if (dual_timestamp_is_set(&userspace_timestamp))
+                m->userspace_timestamp = userspace_timestamp;
+
         if (dual_timestamp_is_set(&initrd_timestamp))
                 m->initrd_timestamp = initrd_timestamp;
 
-- 
1.8.2.1



More information about the systemd-devel mailing list