From patchwork Thu Feb 25 12:01:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pavan Nikhilesh Bhagavatula X-Patchwork-Id: 88219 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BB025A034F; Thu, 25 Feb 2021 13:02:02 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A43EC16082B; Thu, 25 Feb 2021 13:02:02 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 77658406B4; Thu, 25 Feb 2021 13:02:00 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11PBuIQa006424; Thu, 25 Feb 2021 04:01:59 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=wLB1QvILlKcUC9R4/2pHpU3LndS7roZSinR7YkSwzKI=; b=EjWxEK/Uv7LARNbvyVYGk0R63/MUoKIQN91bc0gyhwl6fvY/96Ik55VBDXAlcuKlqMO5 h3AnVpj0iK3NKPNuyd5QyxpYgr/UtdNlsOwX4gvLQ/mcIPZajRrX+K0EJUHXXbiGCKxg 6Zvz9UatohMONlSjVIheqF28ZohA5NEyI7XtR7+LTwnznqI+zeLUTFlgh8vcjIBll3Lc khOPC2s2nxeSvvxahW38L/vjs4WUmVnV2Em0TzozL03RSSRvG+msWusiJ0GWAhSrBf9t mMcmN7zI9jiCbH0H69X39YLqr7WLrdB5vOzZB9ezHIblAP9TCahpwUEryqKYCQPfFohY zA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 36wxbwsydq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 25 Feb 2021 04:01:59 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 25 Feb 2021 04:01:57 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 25 Feb 2021 04:01:57 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 25 Feb 2021 04:01:57 -0800 Received: from BG-LT7430.marvell.com (BG-LT7430.marvell.com [10.28.177.176]) by maili.marvell.com (Postfix) with ESMTP id 9EB1F3F7041; Thu, 25 Feb 2021 04:01:55 -0800 (PST) From: To: CC: , Pavan Nikhilesh , Date: Thu, 25 Feb 2021 17:31:43 +0530 Message-ID: <20210225120144.2591-1-pbhagavatula@marvell.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-02-25_06:2021-02-24, 2021-02-25 signatures=0 Subject: [dpdk-dev] [PATCH] app/eventdev: fix timeout accuracy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Pavan Nikhilesh Round timeout ticks when converting from nanoseconds, this prevents loss of accuracy and deviation from requested timeout value. Fixes: d008f20bce23 ("app/eventdev: add event timer adapter as a producer") Cc: stable@dpdk.org Signed-off-by: Pavan Nikhilesh Reviewed-by: Erik Gabriel Carrillo --- app/test-eventdev/test_perf_common.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/app/test-eventdev/test_perf_common.c b/app/test-eventdev/test_perf_common.c index 34cded373..cc100650c 100644 --- a/app/test-eventdev/test_perf_common.c +++ b/app/test-eventdev/test_perf_common.c @@ -2,6 +2,8 @@ * Copyright(c) 2017 Cavium, Inc */ +#include + #include "test_perf_common.h" int @@ -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; @@ -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;