diff options
author | Ethan Jackson <ethan@nicira.com> | 2012-10-22 16:53:54 -0700 |
---|---|---|
committer | Ethan Jackson <ethan@nicira.com> | 2012-10-25 11:14:07 -0700 |
commit | f43e80e023378a2c1ef18d3caee9b76d6d2a6d23 (patch) | |
tree | 26bde690227c3e3ded1a5fe140a25ac605b61186 /lib/poll-loop.c | |
parent | 7d1563e9612e2f99df5da488981b5bc05fb88180 (diff) |
poll-loop: Log backtraces when CPU usage is high.
Often when debugging Open vSwitch, one will see in the logs that
CPU usage has been high for some period of time, but it's totally
unclear why. In an attempt to remedy the situation, this patch
logs backtraces taken at regular intervals as a poor man's
profiling alternative.
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'lib/poll-loop.c')
-rw-r--r-- | lib/poll-loop.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/poll-loop.c b/lib/poll-loop.c index 516cf13d..7e328bc2 100644 --- a/lib/poll-loop.c +++ b/lib/poll-loop.c @@ -157,6 +157,7 @@ poll_immediate_wake(const char *where) static void log_wakeup(const char *where, const struct pollfd *pollfd, int timeout) { + static struct vlog_rate_limit trace_rl = VLOG_RATE_LIMIT_INIT(1, 1); static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 10); enum vlog_level level; int cpu_usage; @@ -200,6 +201,11 @@ log_wakeup(const char *where, const struct pollfd *pollfd, int timeout) } if (cpu_usage >= 0) { ds_put_format(&s, " (%d%% CPU usage)", cpu_usage); + + if (!vlog_should_drop(THIS_MODULE, level, &trace_rl)) { + ds_put_char(&s, '\n'); + format_backtraces(&s, 2); + } } VLOG(level, "%s", ds_cstr(&s)); ds_destroy(&s); |