lib/poll-loop.c
/* Logs, if appropriate, that the poll loop was awakened by an event
 * registered at 'where' (typically a source file and line number).  The other
 * arguments have two possible interpretations:
 *
 *   - If 'pollfd' is nonnull then it should be the "struct pollfd" that caused
 *     the wakeup.  'timeout' is ignored.
 *
 *   - If 'pollfd' is NULL then 'timeout' is the number of milliseconds after
 *     which the poll loop woke up.
 */
Logs, if appropriate, that the poll loop was awakened by an event
registered at 'where' (typically a source file and line number).  The other
arguments have two possible interpretations.

- If 'pollfd' is nonnull then it should be the "struct pollfd" that caused
the wakeup.  'timeout' is ignored.

- If 'pollfd' is NULL then 'timeout' is the number of milliseconds after
which the poll loop woke up.
Logs if appropriate that the poll loop was awakened by an event registered at ' where ' ( typically a source file and line number ) . The other arguments have two possible interpretations . - If ' pollfd ' is nonnull then it should be the " struct pollfd " that caused the wakeup . ' timeout ' is ignored . - If ' pollfd ' is NULL then ' timeout ' is the number of milliseconds after which the poll loop woke up .
static void
log_wakeup(const char *where, const struct pollfd *pollfd, int timeout)
{
    static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 10);
    enum vlog_level level;
    int cpu_usage;
    struct ds s;
    cpu_usage = get_cpu_usage();
    if (VLOG_IS_DBG_ENABLED()) {
        level = VLL_DBG;
    } else if (cpu_usage > 50
               && !thread_is_pmd()
               && !VLOG_DROP_INFO(&rl)) {
        level = VLL_INFO;
    } else {
        return;
    }
    ds_init(&s);
    ds_put_cstr(&s, "wakeup due to ");
    if (pollfd) {
        char *description = describe_fd(pollfd->fd);
        if (pollfd->revents & POLLIN) {
            ds_put_cstr(&s, "[POLLIN]");
        }
        if (pollfd->revents & POLLOUT) {
            ds_put_cstr(&s, "[POLLOUT]");
        }
        if (pollfd->revents & POLLERR) {
            ds_put_cstr(&s, "[POLLERR]");
        }
        if (pollfd->revents & POLLHUP) {
            ds_put_cstr(&s, "[POLLHUP]");
        }
        if (pollfd->revents & POLLNVAL) {
            ds_put_cstr(&s, "[POLLNVAL]");
        }
        ds_put_format(&s, " on fd %d (%s)", pollfd->fd, description);
        free(description);
    } else {
        ds_put_format(&s, "%d-ms timeout", timeout);
    }
    if (where) {
        ds_put_format(&s, " at %s", where);
    }
    if (cpu_usage >= 0) {
        ds_put_format(&s, " (%d%% CPU usage)", cpu_usage);
    }
    VLOG(level, "%s", ds_cstr(&s));
    ds_destroy(&s);
}
static void log_wakeup ( const char * where , const struct pollfd * pollfd , int timeout ) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT ( 10 , 10 ) ; enum vlog_level level ; int cpu_usage ; struct ds s ; cpu_usage = get_cpu_usage ( ) ; if ( VLOG_IS_DBG_ENABLED ( ) ) { level = VLL_DBG ; } else if ( cpu_usage > 50 && ! thread_is_pmd ( ) && ! VLOG_DROP_INFO ( & rl ) ) { level = VLL_INFO ; } else { return ; } ds_init ( & s ) ; ds_put_cstr ( & s , " " ) ; if ( pollfd ) { char * description = describe_fd ( pollfd -> fd ) ; if ( pollfd -> revents & POLLIN ) { ds_put_cstr ( & s , " " ) ; } if ( pollfd -> revents & POLLOUT ) { ds_put_cstr ( & s , " " ) ; } if ( pollfd -> revents & POLLERR ) { ds_put_cstr ( & s , " " ) ; } if ( pollfd -> revents & POLLHUP ) { ds_put_cstr ( & s , " " ) ; } if ( pollfd -> revents & POLLNVAL ) { ds_put_cstr ( & s , " " ) ; } ds_put_format ( & s , " " , pollfd -> fd , description ) ; free ( description ) ; } else { ds_put_format ( & s , " " , timeout ) ; } if ( where ) { ds_put_format ( & s , " " , where ) ; } if ( cpu_usage >= 0 ) { ds_put_format ( & s , " " , cpu_usage ) ; } VLOG ( level , " " , ds_cstr ( & s ) ) ; ds_destroy ( & s ) ; }
Logs, if appropriate, that the poll loop was awakened by an event
 registered at 'where' (typically a source file and line number).
Logs if appropriate that the poll loop was awakened by an event registered at ' where ' ( typically a source file and line number ) .