Since some threads do not call time_poll() regularly in their main loop (e.g. non-leader revalidator threads), their intermittent invocation of time_poll() in other modules can cause warnings like below:
"Unreasonably long 16518ms poll interval". To suppress such warning, this commit allows thread to disable poll interval check in time_poll() by calling disable_check_poll_interval(). Signed-off-by: Alex Wang <al...@nicira.com> --- lib/timeval.c | 22 ++++++++++++++++++++-- lib/timeval.h | 1 + ofproto/ofproto-dpif-upcall.c | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/timeval.c b/lib/timeval.c index ca663a0..6b8d8e7 100644 --- a/lib/timeval.c +++ b/lib/timeval.c @@ -90,6 +90,9 @@ static long long int deadline = LLONG_MAX; * up. */ DEFINE_STATIC_PER_THREAD_DATA(long long int, last_wakeup, 0); +/* boolean indicating if the poll interval should be checked in time_poll(). */ +DEFINE_STATIC_PER_THREAD_DATA(bool, check_poll_interval, true); + static void log_poll_interval(long long int last_wakeup); static struct rusage *get_recent_rusage(void); static void refresh_rusage(void); @@ -245,6 +248,16 @@ time_alarm(unsigned int secs) deadline = now < LLONG_MAX - msecs ? now + msecs : LLONG_MAX; } +/* Disables the check of poll interval in time_poll() for the calling + * thread. */ +void +disable_check_poll_interval(void) +{ + bool *check_poll_interval = check_poll_interval_get(); + + *check_poll_interval = false; +} + /* Like poll(), except: * * - The timeout is specified as an absolute time, as defined by @@ -261,6 +274,7 @@ int time_poll(struct pollfd *pollfds, int n_pollfds, HANDLE *handles OVS_UNUSED, long long int timeout_when, int *elapsed) { + bool *check_poll_interval = check_poll_interval_get(); long long int *last_wakeup = last_wakeup_get(); long long int start; bool quiescent; @@ -269,7 +283,8 @@ time_poll(struct pollfd *pollfds, int n_pollfds, HANDLE *handles OVS_UNUSED, time_init(); coverage_clear(); coverage_run(); - if (*last_wakeup) { + + if (*check_poll_interval && *last_wakeup) { log_poll_interval(*last_wakeup); } start = time_msec(); @@ -338,7 +353,10 @@ time_poll(struct pollfd *pollfds, int n_pollfds, HANDLE *handles OVS_UNUSED, break; } } - *last_wakeup = time_msec(); + + if (*check_poll_interval) { + *last_wakeup = time_msec(); + } refresh_rusage(); *elapsed = *last_wakeup - start; return retval; diff --git a/lib/timeval.h b/lib/timeval.h index 0bd74cc..f65a30e 100644 --- a/lib/timeval.h +++ b/lib/timeval.h @@ -57,6 +57,7 @@ long long int time_wall_msec(void); void time_timespec(struct timespec *); void time_wall_timespec(struct timespec *); void time_alarm(unsigned int secs); +void disable_check_poll_interval(void); int time_poll(struct pollfd *, int n_pollfds, HANDLE *handles, long long int timeout_when, int *elapsed); diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index db0f17e..c0fb083 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -537,6 +537,9 @@ udpif_revalidator(void *arg) unsigned int flow_limit = 0; size_t n_flows = 0; + if (!leader) { + disable_check_poll_interval(); + } revalidator->id = ovsthread_id_self(); for (;;) { if (leader) { -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev