From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6B8D6A034F; Mon, 22 Mar 2021 17:13:24 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E055540040; Mon, 22 Mar 2021 17:13:23 +0100 (CET) Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) by mails.dpdk.org (Postfix) with ESMTP id D34C64003D for ; Mon, 22 Mar 2021 17:13:22 +0100 (CET) Received: by mail-io1-f49.google.com with SMTP id x17so3236614iog.2 for ; Mon, 22 Mar 2021 09:13:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SF9erSRvQG/EzqKWTy7FDQ7MEplnMs2cc1pnVIyMV4A=; b=BsTgPQuds1j9h4p/gVTUaCyg1ll/oRBL55mG5GHHZdklgxYQYLoYXMuZO3be3mkZPl s0yi26WeRWjWRP1gRrhVu5YgIdpWnflEmsmtsNLlkm+9upylaZmJBaMQNyg7euA0V3tx /YI5u8J0oTTCrRCPhaHpVynWSgJPpXykaCd6xo6aS6mKc2exNzZGWET9QqxMEvhjea/E nIYgmxUxW611JBEOs4CQ8WF8Z7HN+GsNe99KkhUb+xdBbluZRcvbSeCjM5ypqgaUOCtm dposnxyk8bWojPcEhMAkUhWsvblx7raqV5wOm77Nlyt1G2Q2sbbbhqg401KJEx5tytn6 NkCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SF9erSRvQG/EzqKWTy7FDQ7MEplnMs2cc1pnVIyMV4A=; b=POFjVunZhlcHVC/5YH1F+ICuExw1ISxp2dYAZQELy731X6T3OUiA2OaoSTumxJFyld 2/i/8DWgv6gRg+8tT2fIb6H3mYtXB3HhiFqN3xoZtVRFepBNlpP+U0H2auUEOXwuK7pe t/e3jZwX9aK1LbrWBgC81PCjYGjsPqJlWp4TG+4JjnH+2ebhDqFnp4Vlql00BoQ4nLEY 7Y0Waz3uHXy56SRPjxCn0akAHpRzX+G799Xi0lSH3l9QmVX2G+B5ZjVYorvr+YinZBI2 aJK8YMKYE1qXHSn4Z/IuY4o7364l9ywtKq8nAhA5Pi57jS5hMBp3j3VfYzClVpy8i7lB iAIg== X-Gm-Message-State: AOAM530pjhrxQIiOc1reGyObbPOf1M2D9+AQLDm8RUedCgWw+yoa59+h LXE1rAUwRZfpK1ccI0rq7e7vMerzgf/6FHFmxiM= X-Google-Smtp-Source: ABdhPJzZIewnOaHgO+HBKjpmE57v4S9VuP/7LqXf4WF5HROQwyw4yA3jV0AJ1JXIl/8lm4TJBgA0Qyrdq04uqannIBU= X-Received: by 2002:a6b:b7cd:: with SMTP id h196mr384528iof.59.1616429602175; Mon, 22 Mar 2021 09:13:22 -0700 (PDT) MIME-Version: 1.0 References: <20210225122315.6350-1-pbhagavatula@marvell.com> <20210321084915.2649-1-pbhagavatula@marvell.com> <20210321084915.2649-4-pbhagavatula@marvell.com> In-Reply-To: <20210321084915.2649-4-pbhagavatula@marvell.com> From: Jerin Jacob Date: Mon, 22 Mar 2021 21:43:06 +0530 Message-ID: To: Pavan Nikhilesh Cc: Jerin Jacob , dpdk-dev Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v2 4/4] event/octeontx2: timer always use virtual counter 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" On Sun, Mar 21, 2021 at 2:20 PM wrote: > > From: Pavan Nikhilesh > > Use virtual counter for estimating current bucket as PMU cannot be > reliably used to estimate time. > > Signed-off-by: Pavan Nikhilesh There is a genuine Travis build issue with this patch. Please check http://patches.dpdk.org/project/dpdk/patch/20210321084915.2649-4-pbhagavatula@marvell.com/ https://travis-ci.com/github/ovsrobot/dpdk/builds/220728709 > --- > drivers/event/octeontx2/otx2_tim_evdev.c | 19 +++-------------- > drivers/event/octeontx2/otx2_tim_evdev.h | 26 +++++++++++++++++++++++ > drivers/event/octeontx2/otx2_tim_worker.c | 4 ++-- > drivers/event/octeontx2/otx2_tim_worker.h | 2 +- > 4 files changed, 32 insertions(+), 19 deletions(-) > > diff --git a/drivers/event/octeontx2/otx2_tim_evdev.c b/drivers/event/octeontx2/otx2_tim_evdev.c > index 4fb002ddb..926c2dce6 100644 > --- a/drivers/event/octeontx2/otx2_tim_evdev.c > +++ b/drivers/event/octeontx2/otx2_tim_evdev.c > @@ -354,7 +354,7 @@ otx2_tim_calibrate_start_tsc(struct otx2_tim_ring *tim_ring) > > for (icount = 0; icount < OTX2_TIM_CALIB_ITER; icount++) { > real_bkt = otx2_read64(tim_ring->base + TIM_LF_RING_REL) >> 44; > - bkt_cyc = rte_rdtsc(); > + bkt_cyc = tim_cntvct(); > bucket = (bkt_cyc - tim_ring->ring_start_cyc) / > tim_ring->tck_int; > bucket = bucket % (tim_ring->nb_bkts); > @@ -389,20 +389,8 @@ otx2_tim_ring_start(const struct rte_event_timer_adapter *adptr) > tim_err_desc(rc); > goto fail; > } > -#ifdef RTE_ARM_EAL_RDTSC_USE_PMU > - uint64_t tenns_stmp, tenns_diff; > - uint64_t pmu_stmp; > - > - pmu_stmp = rte_rdtsc(); > - asm volatile("mrs %0, cntvct_el0" : "=r" (tenns_stmp)); > - > - tenns_diff = tenns_stmp - rsp->timestarted; > - pmu_stmp = pmu_stmp - (NSEC2TICK(tenns_diff * 10, rte_get_timer_hz())); > - tim_ring->ring_start_cyc = pmu_stmp; > -#else > tim_ring->ring_start_cyc = rsp->timestarted; > -#endif > - tim_ring->tck_int = NSEC2TICK(tim_ring->tck_nsec, rte_get_timer_hz()); > + tim_ring->tck_int = NSEC2TICK(tim_ring->tck_nsec, tim_cntfrq()); > tim_ring->tot_int = tim_ring->tck_int * tim_ring->nb_bkts; > tim_ring->fast_div = rte_reciprocal_value_u64(tim_ring->tck_int); > tim_ring->fast_bkt = rte_reciprocal_value_u64(tim_ring->nb_bkts); > @@ -470,8 +458,7 @@ otx2_tim_stats_get(const struct rte_event_timer_adapter *adapter, > struct rte_event_timer_adapter_stats *stats) > { > struct otx2_tim_ring *tim_ring = adapter->data->adapter_priv; > - uint64_t bkt_cyc = rte_rdtsc() - tim_ring->ring_start_cyc; > - > + uint64_t bkt_cyc = tim_cntvct() - tim_ring->ring_start_cyc; > > stats->evtim_exp_count = __atomic_load_n(&tim_ring->arm_cnt, > __ATOMIC_RELAXED); > diff --git a/drivers/event/octeontx2/otx2_tim_evdev.h b/drivers/event/octeontx2/otx2_tim_evdev.h > index 0667d4576..410880e14 100644 > --- a/drivers/event/octeontx2/otx2_tim_evdev.h > +++ b/drivers/event/octeontx2/otx2_tim_evdev.h > @@ -176,6 +176,32 @@ tim_priv_get(void) > return mz->addr; > } > > +#ifdef RTE_ARCH_ARM64 > +static inline uint64_t > +tim_cntvct(void) > +{ > + return __rte_arm64_cntvct(); > +} > + > +static inline uint64_t > +tim_cntfrq(void) > +{ > + return __rte_arm64_cntfrq(); > +} > +#else > +static inline uint64_t > +tim_cntvct(void) > +{ > + return 0; > +} > + > +static inline uint64_t > +tim_cntfrq(void) > +{ > + return 0; > +} > +#endif > + > #define TIM_ARM_FASTPATH_MODES \ > FP(sp, 0, 0, 0, OTX2_TIM_ENA_DFB | OTX2_TIM_SP) \ > FP(mp, 0, 0, 1, OTX2_TIM_ENA_DFB | OTX2_TIM_MP) \ > diff --git a/drivers/event/octeontx2/otx2_tim_worker.c b/drivers/event/octeontx2/otx2_tim_worker.c > index 6a3511ec0..9ee07958f 100644 > --- a/drivers/event/octeontx2/otx2_tim_worker.c > +++ b/drivers/event/octeontx2/otx2_tim_worker.c > @@ -41,12 +41,12 @@ tim_format_event(const struct rte_event_timer * const tim, > static inline void > tim_sync_start_cyc(struct otx2_tim_ring *tim_ring) > { > - uint64_t cur_cyc = rte_rdtsc(); > + uint64_t cur_cyc = tim_cntvct(); > uint32_t real_bkt; > > if (cur_cyc - tim_ring->last_updt_cyc > tim_ring->tot_int) { > real_bkt = otx2_read64(tim_ring->base + TIM_LF_RING_REL) >> 44; > - cur_cyc = rte_rdtsc(); > + cur_cyc = tim_cntvct(); > > tim_ring->ring_start_cyc = cur_cyc - > (real_bkt * tim_ring->tck_int); > diff --git a/drivers/event/octeontx2/otx2_tim_worker.h b/drivers/event/octeontx2/otx2_tim_worker.h > index aa69da96c..582b9c1b9 100644 > --- a/drivers/event/octeontx2/otx2_tim_worker.h > +++ b/drivers/event/octeontx2/otx2_tim_worker.h > @@ -132,7 +132,7 @@ tim_get_target_bucket(struct otx2_tim_ring *const tim_ring, > const uint32_t rel_bkt, struct otx2_tim_bkt **bkt, > struct otx2_tim_bkt **mirr_bkt) > { > - const uint64_t bkt_cyc = rte_rdtsc() - tim_ring->ring_start_cyc; > + const uint64_t bkt_cyc = tim_cntvct() - tim_ring->ring_start_cyc; > uint64_t bucket = > rte_reciprocal_divide_u64(bkt_cyc, &tim_ring->fast_div) + > rel_bkt; > -- > 2.17.1 >