Skip to content

Commit

Permalink
timeval: Correctly report usage statistics in log_poll_interval().
Browse files Browse the repository at this point in the history
Most of the information that timeval was reporting for long poll intervals
was comparing per-thread with per-process statistics, which yielded
nonsense a lot of the time.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
  • Loading branch information
blp committed Feb 11, 2015
1 parent 843298e commit 4f948a1
Showing 1 changed file with 31 additions and 26 deletions.
57 changes: 31 additions & 26 deletions lib/timeval.c
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -74,6 +74,7 @@ static void block_sigalrm(sigset_t *);
static void unblock_sigalrm(const sigset_t *);
static void log_poll_interval(long long int last_wakeup);
static struct rusage *get_recent_rusage(void);
static int getrusage_thread(struct rusage *);
static void refresh_rusage(void);
static void timespec_add(struct timespec *sum,
const struct timespec *a, const struct timespec *b);
Expand Down Expand Up @@ -448,31 +449,35 @@ log_poll_interval(long long int last_wakeup)
const struct rusage *last_rusage = get_recent_rusage();
struct rusage rusage;

getrusage(RUSAGE_SELF, &rusage);
VLOG_WARN("Unreasonably long %lldms poll interval"
" (%lldms user, %lldms system)",
interval,
timeval_diff_msec(&rusage.ru_utime,
&last_rusage->ru_utime),
timeval_diff_msec(&rusage.ru_stime,
&last_rusage->ru_stime));
if (rusage.ru_minflt > last_rusage->ru_minflt
|| rusage.ru_majflt > last_rusage->ru_majflt) {
VLOG_WARN("faults: %ld minor, %ld major",
rusage.ru_minflt - last_rusage->ru_minflt,
rusage.ru_majflt - last_rusage->ru_majflt);
}
if (rusage.ru_inblock > last_rusage->ru_inblock
|| rusage.ru_oublock > last_rusage->ru_oublock) {
VLOG_WARN("disk: %ld reads, %ld writes",
rusage.ru_inblock - last_rusage->ru_inblock,
rusage.ru_oublock - last_rusage->ru_oublock);
}
if (rusage.ru_nvcsw > last_rusage->ru_nvcsw
|| rusage.ru_nivcsw > last_rusage->ru_nivcsw) {
VLOG_WARN("context switches: %ld voluntary, %ld involuntary",
rusage.ru_nvcsw - last_rusage->ru_nvcsw,
rusage.ru_nivcsw - last_rusage->ru_nivcsw);
if (!getrusage_thread(&rusage)) {
VLOG_WARN("Unreasonably long %lldms poll interval"
" (%lldms user, %lldms system)",
interval,
timeval_diff_msec(&rusage.ru_utime,
&last_rusage->ru_utime),
timeval_diff_msec(&rusage.ru_stime,
&last_rusage->ru_stime));

if (rusage.ru_minflt > last_rusage->ru_minflt
|| rusage.ru_majflt > last_rusage->ru_majflt) {
VLOG_WARN("faults: %ld minor, %ld major",
rusage.ru_minflt - last_rusage->ru_minflt,
rusage.ru_majflt - last_rusage->ru_majflt);
}
if (rusage.ru_inblock > last_rusage->ru_inblock
|| rusage.ru_oublock > last_rusage->ru_oublock) {
VLOG_WARN("disk: %ld reads, %ld writes",
rusage.ru_inblock - last_rusage->ru_inblock,
rusage.ru_oublock - last_rusage->ru_oublock);
}
if (rusage.ru_nvcsw > last_rusage->ru_nvcsw
|| rusage.ru_nivcsw > last_rusage->ru_nivcsw) {
VLOG_WARN("context switches: %ld voluntary, %ld involuntary",
rusage.ru_nvcsw - last_rusage->ru_nvcsw,
rusage.ru_nivcsw - last_rusage->ru_nivcsw);
}
} else {
VLOG_WARN("Unreasonably long %lldms poll interval", interval);
}
coverage_log();
}
Expand Down

0 comments on commit 4f948a1

Please sign in to comment.