[systemd-commits] 4 commits - man/systemd-bootchart.xml src/bootchart src/journal-remote units/ldconfig.service
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Sat Aug 2 22:15:55 PDT 2014
man/systemd-bootchart.xml | 4 +++-
src/bootchart/bootchart.c | 19 +++++++++++++++----
src/bootchart/store.c | 29 ++++++++++++-----------------
src/journal-remote/journal-remote.c | 12 ++++++------
src/journal-remote/journal-upload.c | 8 ++++----
units/ldconfig.service | 1 +
6 files changed, 41 insertions(+), 32 deletions(-)
New commits:
commit 9a6f36c08f1ff93ff861e6371e081122a564c900
Author: Karel Zak <kzak at redhat.com>
Date: Thu Jul 31 10:15:40 2014 +0200
bootchart: ask for --rel when failed to initialize graph start time
We always read system uptime before log start time. So the uptime
should be always smaller number, except it includes system suspend
time. It seems better to ask for --rel and exit() than try to be
smart and try to recovery from this situation or generate huge
messy graphs.
diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
index fc00b4e..5683025 100644
--- a/src/bootchart/bootchart.c
+++ b/src/bootchart/bootchart.c
@@ -350,6 +350,14 @@ int main(int argc, char *argv[]) {
log_uptime();
+ if (graph_start < 0.0) {
+ fprintf(stderr,
+ "Failed to setup graph start time.\n\nThe system uptime "
+ "probably includes time that the system was suspended. "
+ "Use --rel to bypass this issue.\n");
+ exit (EXIT_FAILURE);
+ }
+
has_procfs = access("/proc/vmstat", F_OK) == 0;
LIST_HEAD_INIT(head);
commit c358d728e7d6bf38a0176a9d5d013c6e972cddbf
Author: Karel Zak <kzak at redhat.com>
Date: Thu Jul 31 10:15:39 2014 +0200
bootchart: don't parse /proc/uptime, use CLOCK_BOOTTIME
* systemd-bootchart always parses /proc/uptime, although the
information is unnecessary when --rel specified
* use /proc/uptime is overkill, since Linux 2.6.39 we have
clock_gettime(CLOCK_BOOTTIME, ...). The backend on kernel side is
get_monotonic_boottime() in both cases.
* main() uses "if (graph_start <= 0.0)" to detect that /proc is
available.
This is fragile solution as graph_start is always smaller than zero
on all systems after suspend/resume (e.g. laptops), because in this
case the system uptime includes suspend time and uptime is always
greater number than monotonic time. For example right now difference
between uptime and monotonic time is 37 hours on my laptop.
Note that main() calls log_uptime() (to parse /proc/uptime) for each
sample when it believes that /proc is not available. So on my laptop
systemd-boochars spends all live with /proc/uptime parsing +
nanosleep(), try
strace /usr/lib/systemd/systemd-bootchart
to see the never ending loop.
This patch uses access("/proc/vmstat", F_OK) to detect procfs.
diff --git a/man/systemd-bootchart.xml b/man/systemd-bootchart.xml
index e19bbc1..150ca48 100644
--- a/man/systemd-bootchart.xml
+++ b/man/systemd-bootchart.xml
@@ -131,7 +131,9 @@
not graph the time elapsed since boot
and before systemd-bootchart was
started, as it may result in extremely
- large graphs. </para></listitem>
+ large graphs. The time elapsed since boot
+ might also include any time that the system
+ was suspended.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
index 0ae72c2..fc00b4e 100644
--- a/src/bootchart/bootchart.c
+++ b/src/bootchart/bootchart.c
@@ -310,6 +310,7 @@ int main(int argc, char *argv[]) {
time_t t = 0;
int r;
struct rlimit rlim;
+ bool has_procfs = false;
parse_conf();
@@ -349,6 +350,8 @@ int main(int argc, char *argv[]) {
log_uptime();
+ has_procfs = access("/proc/vmstat", F_OK) == 0;
+
LIST_HEAD_INIT(head);
/* main program loop */
@@ -385,11 +388,11 @@ int main(int argc, char *argv[]) {
parse_env_file("/usr/lib/os-release", NEWLINE, "PRETTY_NAME", &build, NULL);
}
- /* wait for /proc to become available, discarding samples */
- if (graph_start <= 0.0)
- log_uptime();
- else
+ if (has_procfs)
log_sample(samples, &sampledata);
+ else
+ /* wait for /proc to become available, discarding samples */
+ has_procfs = access("/proc/vmstat", F_OK) == 0;
sample_stop = gettime_ns();
diff --git a/src/bootchart/store.c b/src/bootchart/store.c
index e071983..cedcba8 100644
--- a/src/bootchart/store.c
+++ b/src/bootchart/store.c
@@ -57,27 +57,22 @@ double gettime_ns(void) {
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", "re");
-
- 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)
- 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;
+ }
}
static char *bufgetline(char *buf) {
commit 799a8f39d8eb9ea725e85a598c0f5dbd658c8ba7
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Aug 3 01:12:30 2014 -0400
journal-remote: rename KEY_FILE to avoid confict with <linux/input.h>
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index bc36efa..1df1786 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -52,9 +52,9 @@
#define REMOTE_JOURNAL_PATH "/var/log/journal/remote"
-#define KEY_FILE CERTIFICATE_ROOT "/private/journal-remote.pem"
-#define CERT_FILE CERTIFICATE_ROOT "/certs/journal-remote.pem"
-#define TRUST_FILE CERTIFICATE_ROOT "/ca/trusted.pem"
+#define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-remote.pem"
+#define CERT_FILE CERTIFICATE_ROOT "/certs/journal-remote.pem"
+#define TRUST_FILE CERTIFICATE_ROOT "/ca/trusted.pem"
static char* arg_url = NULL;
static char* arg_getter = NULL;
@@ -1144,7 +1144,7 @@ static void help(void) {
" --[no-]compress Use XZ-compression in the output journal (default: yes)\n"
" --[no-]seal Use Event sealing in the output journal (default: no)\n"
" --key=FILENAME Specify key in PEM format (default:\n"
- " \"" KEY_FILE "\")\n"
+ " \"" PRIV_KEY_FILE "\")\n"
" --cert=FILENAME Specify certificate in PEM format (default:\n"
" \"" CERT_FILE "\")\n"
" --trust=FILENAME|all Specify CA certificate or disable checking (default:\n"
@@ -1420,10 +1420,10 @@ static int parse_argv(int argc, char *argv[]) {
static int load_certificates(char **key, char **cert, char **trust) {
int r;
- r = read_full_file(arg_key ?: KEY_FILE, key, NULL);
+ r = read_full_file(arg_key ?: PRIV_KEY_FILE, key, NULL);
if (r < 0) {
log_error("Failed to read key from file '%s': %s",
- arg_key ?: KEY_FILE, strerror(-r));
+ arg_key ?: PRIV_KEY_FILE, strerror(-r));
return r;
}
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index 72396bf..b178df2 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -34,9 +34,9 @@
#include "conf-parser.h"
#include "journal-upload.h"
-#define KEY_FILE CERTIFICATE_ROOT "/private/journal-upload.pem"
-#define CERT_FILE CERTIFICATE_ROOT "/certs/journal-upload.pem"
-#define TRUST_FILE CERTIFICATE_ROOT "/ca/trusted.pem"
+#define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-upload.pem"
+#define CERT_FILE CERTIFICATE_ROOT "/certs/journal-upload.pem"
+#define TRUST_FILE CERTIFICATE_ROOT "/ca/trusted.pem"
static const char* arg_url;
@@ -222,7 +222,7 @@ int start_upload(Uploader *u,
if (arg_key || startswith(u->url, "https://")) {
assert(arg_cert);
- easy_setopt(curl, CURLOPT_SSLKEY, arg_key ?: KEY_FILE,
+ easy_setopt(curl, CURLOPT_SSLKEY, arg_key ?: PRIV_KEY_FILE,
LOG_ERR, return -EXFULL);
easy_setopt(curl, CURLOPT_SSLCERT, arg_cert ?: CERT_FILE,
LOG_ERR, return -EXFULL);
commit e72f054eb531418f99cd6d1d48d3542d1f95e07d
Author: Umut Tezduyar Lindskog <umut.tezduyar at axis.com>
Date: Wed Jul 30 09:02:14 2014 +0200
ldconfig: dont run it if ldconfig is not installed
diff --git a/units/ldconfig.service b/units/ldconfig.service
index 43c145b..09a2b74 100644
--- a/units/ldconfig.service
+++ b/units/ldconfig.service
@@ -13,6 +13,7 @@ Conflicts=shutdown.target
After=systemd-readahead-collect.service systemd-readahead-replay.service systemd-remount-fs.service
Before=sysinit.target shutdown.target systemd-update-done.service
ConditionNeedsUpdate=/etc
+ConditionFileIsExecutable=/sbin/ldconfig
[Service]
Type=oneshot
More information about the systemd-commits
mailing list