chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sd-rtnl: don't assign to unused variable
[elogind.git]
/
src
/
bootchart
/
store.c
diff --git
a/src/bootchart/store.c
b/src/bootchart/store.c
index 3e0052d212813309aa3e38ebb3f26ae2cde92df3..2d2ea428fa570804e1c467727c2a6abd4657fe9c 100644
(file)
--- a/
src/bootchart/store.c
+++ b/
src/bootchart/store.c
@@
-34,9
+34,11
@@
#include <time.h>
#include "util.h"
#include <time.h>
#include "util.h"
+#include "time-util.h"
#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
@@
-53,30
+55,25
@@
double gettime_ns(void) {
clock_gettime(CLOCK_MONOTONIC, &n);
clock_gettime(CLOCK_MONOTONIC, &n);
- return (n.tv_sec + (n.tv_nsec /
1000000000.0
));
+ return (n.tv_sec + (n.tv_nsec /
(double) NSEC_PER_SEC
));
}
}
-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 / (double) NSEC_PER_SEC));
+}
- /* 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
+312,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);