Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH v4] linux-gen: timer: avoid overrun debug prints if no timers started #1940

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions platform/linux-generic/odp_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ typedef struct timer_pool_s {
odp_timer_pool_param_t param;
char name[ODP_TIMER_POOL_NAME_LEN];
timer_t timerid;
int notify_overrun;
/*
* Timer pool overrun notification (debug print). Initialize to 0
* (don't notify). When value is 0 and a timer is started, set to 1
* (notify). When notification is done, set to 2 (don't notify).
*/
odp_atomic_u32_t notify_overrun;
int owner;
pthread_t thr_pthread; /* pthread_t of timer thread */
pid_t thr_pid; /* gettid() for timer thread */
Expand Down Expand Up @@ -828,14 +833,15 @@ static inline void timer_pool_scan_inline(int num, odp_time_t now)
continue;

if (odp_atomic_cas_u64(&tp->cur_tick, &old_tick, new_tick)) {
if (tp->notify_overrun && diff > 1) {
if (ODP_DEBUG_PRINT && odp_atomic_load_u32(&tp->notify_overrun) == 1 &&
diff > 1) {
if (old_tick == 0) {
_ODP_DBG("Timer pool (%s) missed %" PRIi64 " scans in start up\n",
tp->name, diff - 1);
} else {
_ODP_DBG("Timer pool (%s) resolution too high: %" PRIi64 " scans missed\n",
tp->name, diff - 1);
tp->notify_overrun = 0;
odp_atomic_store_u32(&tp->notify_overrun, 2);
}
}
timer_pool_scan(tp, nsec);
Expand Down Expand Up @@ -896,12 +902,12 @@ static inline void timer_run_posix(timer_pool_t *tp)
uint64_t nsec;
int overrun;

if (tp->notify_overrun) {
if (ODP_DEBUG_PRINT && odp_atomic_load_u32(&tp->notify_overrun) == 1) {
overrun = timer_getoverrun(tp->timerid);
if (overrun) {
_ODP_DBG("\n\t%d ticks overrun on timer pool \"%s\", timer resolution too high\n",
overrun, tp->name);
tp->notify_overrun = 0;
odp_atomic_store_u32(&tp->notify_overrun, 2);
}
}

Expand Down Expand Up @@ -1089,6 +1095,12 @@ static void posix_timer_start(timer_pool_t *tp)
* processed. Warm up helps avoiding overrun on the first timeout. */
while (odp_atomic_load_acq_u32(&tp->thr_ready) == 0)
sched_yield();

if (ODP_DEBUG_PRINT) {
uint32_t old_val = 0;

odp_atomic_cas_u32(&tp->notify_overrun, &old_val, 1);
}
}

static odp_timer_pool_t timer_pool_new(const char *name, const odp_timer_pool_param_t *param)
Expand Down Expand Up @@ -1234,8 +1246,8 @@ static odp_timer_pool_t timer_pool_new(const char *name, const odp_timer_pool_pa
}
tp->num_alloc = 0;
odp_atomic_init_u32(&tp->high_wm, 0);
odp_atomic_init_u32(&tp->notify_overrun, 0);
tp->first_free = 0;
tp->notify_overrun = 1;
tp->owner = -1;

if (param->priv)
Expand Down Expand Up @@ -1620,6 +1632,12 @@ int odp_timer_start(odp_timer_t timer, const odp_timer_start_t *start_param)
odp_event_free(tmo_ev);
}

if (ODP_DEBUG_PRINT) {
uint32_t old_val = 0;

odp_atomic_cas_u32(&tp->notify_overrun, &old_val, 1);
}

return ODP_TIMER_SUCCESS;
}

Expand Down