chiark / gitweb /
Revert "socket: add support for TCP fast Open"
[elogind.git] / src / bootchart / store.c
index 3e0052d212813309aa3e38ebb3f26ae2cde92df3..cedcba88ed1b8059c03281c75cd2a8fc1c52f992 100644 (file)
@@ -37,6 +37,7 @@
 #include "strxcpyx.h"
 #include "store.h"
 #include "bootchart.h"
 #include "strxcpyx.h"
 #include "store.h"
 #include "bootchart.h"
+#include "cgroup-util.h"
 
 /*
  * Alloc a static 4k buffer for stdio - primarily used to increase
 
 /*
  * Alloc a static 4k buffer for stdio - primarily used to increase
@@ -56,27 +57,22 @@ double gettime_ns(void) {
         return (n.tv_sec + (n.tv_nsec / 1000000000.0));
 }
 
         return (n.tv_sec + (n.tv_nsec / 1000000000.0));
 }
 
-void log_uptime(void) {
-        _cleanup_fclose_ FILE *f = NULL;
-        char str[32];
-        double uptime;
-
-        f = fopen("/proc/uptime", "r");
-
-        if (!f)
-                return;
-        if (!fscanf(f, "%s %*s", str))
-                return;
-
-        uptime = strtod(str, NULL);
+static double gettime_up(void) {
+        struct timespec n;
 
 
-        log_start = gettime_ns();
+        clock_gettime(CLOCK_BOOTTIME, &n);
+        return (n.tv_sec + (n.tv_nsec / 1000000000.0));
+}
 
 
-        /* start graph at kernel boot time */
+void log_uptime(void) {
         if (arg_relative)
         if (arg_relative)
-                graph_start = log_start;
-        else
+                graph_start = log_start = gettime_ns();
+        else {
+                double uptime = gettime_up();
+
+                log_start = gettime_ns();
                 graph_start = log_start - uptime;
                 graph_start = log_start - uptime;
+        }
 }
 
 static char *bufgetline(char *buf) {
 }
 
 static char *bufgetline(char *buf) {
@@ -315,6 +311,11 @@ schedstat_next:
 
                         ps->starttime = strtod(t, NULL) / 1000.0;
 
 
                         ps->starttime = strtod(t, NULL) / 1000.0;
 
+                        if (arg_show_cgroup)
+                                /* if this fails, that's OK */
+                                cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER,
+                                                ps->pid, &ps->cgroup);
+
                         /* ppid */
                         sprintf(filename, "%d/stat", pid);
                         fd = openat(procfd, filename, O_RDONLY);
                         /* ppid */
                         sprintf(filename, "%d/stat", pid);
                         fd = openat(procfd, filename, O_RDONLY);