Skip to content

Commit

Permalink
app/eventdev: fix timeout accuracy
Browse files Browse the repository at this point in the history
[ upstream commit 626b12a ]

Round timeout ticks when converting from nanoseconds, this prevents
loss of accuracy and deviation from requested timeout value.

Fixes: d008f20 ("app/eventdev: add event timer adapter as a producer")

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Erik Gabriel Carrillo <erik.g.carrillo@intel.com>
  • Loading branch information
PavanNikhilesh authored and steevenlee committed May 8, 2021
1 parent 5b91f48 commit dc7e8df
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions app/test-eventdev/test_perf_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Copyright(c) 2017 Cavium, Inc
*/

#include <math.h>

#include "test_perf_common.h"

int
Expand Down Expand Up @@ -95,11 +97,13 @@ perf_event_timer_producer(void *arg)
uint64_t timeout_ticks = opt->expiry_nsec / opt->timer_tick_nsec;

memset(&tim, 0, sizeof(struct rte_event_timer));
timeout_ticks = opt->optm_timer_tick_nsec ?
(timeout_ticks * opt->timer_tick_nsec)
/ opt->optm_timer_tick_nsec : timeout_ticks;
timeout_ticks =
opt->optm_timer_tick_nsec
? ceil((double)(timeout_ticks * opt->timer_tick_nsec) /
opt->optm_timer_tick_nsec)
: timeout_ticks;
timeout_ticks += timeout_ticks ? 0 : 1;
tim.ev.event_type = RTE_EVENT_TYPE_TIMER;
tim.ev.event_type = RTE_EVENT_TYPE_TIMER;
tim.ev.op = RTE_EVENT_OP_NEW;
tim.ev.sched_type = t->opt->sched_type_list[0];
tim.ev.queue_id = p->queue_id;
Expand Down Expand Up @@ -159,11 +163,13 @@ perf_event_timer_producer_burst(void *arg)
uint64_t timeout_ticks = opt->expiry_nsec / opt->timer_tick_nsec;

memset(&tim, 0, sizeof(struct rte_event_timer));
timeout_ticks = opt->optm_timer_tick_nsec ?
(timeout_ticks * opt->timer_tick_nsec)
/ opt->optm_timer_tick_nsec : timeout_ticks;
timeout_ticks =
opt->optm_timer_tick_nsec
? ceil((double)(timeout_ticks * opt->timer_tick_nsec) /
opt->optm_timer_tick_nsec)
: timeout_ticks;
timeout_ticks += timeout_ticks ? 0 : 1;
tim.ev.event_type = RTE_EVENT_TYPE_TIMER;
tim.ev.event_type = RTE_EVENT_TYPE_TIMER;
tim.ev.op = RTE_EVENT_OP_NEW;
tim.ev.sched_type = t->opt->sched_type_list[0];
tim.ev.queue_id = p->queue_id;
Expand Down

0 comments on commit dc7e8df

Please sign in to comment.