summaryrefslogtreecommitdiff
path: root/lib/timer.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-05-13 13:06:49 -0700
committerBen Pfaff <blp@nicira.com>2011-05-13 14:38:15 -0700
commitf89ffb0e2f6fa8adc100192ea4b5f948170d8d57 (patch)
treea95358d92f1ef01bf231e2f22fad99cd6c93afc5 /lib/timer.c
parent0e6644c3880be9684f37f48da84907bb67112514 (diff)
downloadopenvswitch-f89ffb0e2f6fa8adc100192ea4b5f948170d8d57.tar.gz
poll-loop: Make wakeup logging more portable and easier to understand.
Until now, when the poll_loop module's log level was turned up to "debug", it would log a backtrace of the call stack for the event that caused poll() to wake up in poll_block(). This was pretty useful from time to time to find out why ovs-vswitchd was using more CPU than expected, because we could find out what was causing it to wake up. But there were some issues. One is simply that the backtrace was printed as a series of hexadecimal numbers, so GDB or another debugger was needed to translate it into human-readable format. Compiler optimizations meant that even the human-readable backtrace wasn't, in my experience, as helpful as it could have been. And, of course, one needed to have the binary to interpret the backtrace. When the backtrace couldn't be interpreted or wasn't meaningful, there was essentially nothing to fall back on. This commit changes the way that "debug" logging for poll_block() wakeups works. Instead of logging a backtrace, it logs the source code file name and line number of the call to a poll_loop function, using __FILE__ and __LINE__. This is by itself much more meaningful than a sequence of hexadecimal numbers, since no additional interpretation is necessary. It can be useful even if the Open vSwitch version is only approximately known. In addition to the file and line, this commit adds, for wakeups caused by file descriptors, information about the file descriptor itself: what kind of file it is (regular file, directory, socket, etc.), the name of the file (on Linux only), and the local and remote endpoints for socket file descriptors. Here are a few examples of the new output format: 932-ms timeout at ../ofproto/in-band.c:507 [POLLIN] on fd 20 (192.168.0.20:35388<->192.168.0.3:6633) at ../lib/stream-fd.c:149 [POLLIN] on fd 7 (FIFO pipe:[48049]) at ../lib/fatal-signal.c:168
Diffstat (limited to 'lib/timer.c')
-rw-r--r--lib/timer.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/timer.c b/lib/timer.c
index b640a7be8..84d20a401 100644
--- a/lib/timer.c
+++ b/lib/timer.c
@@ -34,9 +34,9 @@ timer_msecs_until_expired(const struct timer *timer)
/* Causes poll_block() to wake when 'timer' expires. */
void
-timer_wait(const struct timer *timer)
+(timer_wait)(const struct timer *timer, const char *where)
{
if (timer->t < LLONG_MAX) {
- poll_timer_wait_until(timer->t);
+ (poll_timer_wait_until)(timer->t, where);
}
}