From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2087CA0565; Tue, 10 Mar 2020 11:47:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 340531BFF7; Tue, 10 Mar 2020 11:47:32 +0100 (CET) Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by dpdk.org (Postfix) with ESMTP id 5EB0F1BFF5 for ; Tue, 10 Mar 2020 11:47:31 +0100 (CET) Received: by mail-io1-f67.google.com with SMTP id v3so6196878iom.13 for ; Tue, 10 Mar 2020 03:47:31 -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=snnXGAdIRgUeZU/FYBw/sWb2Qm5AV1cqm+QYBNyNMQw=; b=qgojL2DP6a1RrLOC3CuFp+H28GWEXWOTyKD1aXtx3FKF6lMcqMMLkWNKVht+3x5nlh K0PUfW6vV1FV9Uu2L5hllH15G+EydxIXJqxjnWrc3t31K9LuLSEU7ycTK+xM9IS/8+lP AULoUPDe9fPgGpv+qF1HDeIx9TbfIlhqSOs0/Elss4bjktO/4O8Mjgw3N1Lx76SIW1Xb 65P171pSLOQYTal4hwI0ynRoXbWGRrxUW/fEqlz4sSpR2lv2TP7Mmq9k2OPqphEqVt3O fmqPP8t1uXAAFWd+jkM68G8n0QxzVcrYOHEw2Ba4YTqLkQYHJ/+rERxH5ojLCeQZ6Al4 mK6A== 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=snnXGAdIRgUeZU/FYBw/sWb2Qm5AV1cqm+QYBNyNMQw=; b=Gy9sd/3PCqhgU+YW4CL8mzaNGJomzYaJt6cylCpPD97PUizCYPPUjwzZLvYmvoIn+9 6EF2AAPqt3tvg0Gad2vPJYmTM5aeUnlA60gy7MX3KYEfWsK+Oxzj8bcXe8xpkbg9vC1i GJi+hHoewD9js27AJlRgCFvuIZ05cTNuUNNCiNOalzgYk44e4atkfXycrwRq32uwkeGf 9GYrycSnqpiTiy/1F9IPTt9WL+Y+axXwASXhPl4emQ+/S7f26X1J9cbyo/1TsyiB2atQ 3tqf7p6tl0CX3OA9BJMRroPBYby2hWUW6nz5ptzbiJv/XLeZbzMPU07KeDFyFQsXhQt+ 2adQ== X-Gm-Message-State: ANhLgQ2BDBVIt/vlELs60+hZTdoRrMAUpFd11/wqofa97gi958l3/TF8 ZXJAENjdAy2K9fBN2i18u07EC6JXEaobVPiC6wc= X-Google-Smtp-Source: ADFU+vszIB83ddXYq8knyuP/fZYvAz/BfmpxucdhNHp2PmRzC+JSbc5QaXexEaU3nlDOSuCt3fPfCpfaoaXY+XtXasw= X-Received: by 2002:a6b:5905:: with SMTP id n5mr6573454iob.59.1583837250496; Tue, 10 Mar 2020 03:47:30 -0700 (PDT) MIME-Version: 1.0 References: <4099DE2E54AFAD489356C6C9161D53339729F5D7@DGGEML502-MBX.china.huawei.com> In-Reply-To: <4099DE2E54AFAD489356C6C9161D53339729F5D7@DGGEML502-MBX.china.huawei.com> From: Jerin Jacob Date: Tue, 10 Mar 2020 16:17:14 +0530 Message-ID: To: Linhaifeng Cc: Gavin Hu , "dev@dpdk.org" , "thomas@monjalon.net" , chenchanghu , xudingke , "Lilijun (Jerry)" , Honnappa Nagarahalli , Steve Capper , nd Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v3] eal/arm64: fix rdtsc precise version X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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 Tue, Mar 10, 2020 at 3:09 PM Linhaifeng wrote: > > In order to get more accurate the cntvct_el0 reading, > SW must invoke isb and arch_counter_enforce_ordering. > > Reference of linux kernel: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/include/asm/arch_timer.h?h=v5.5#n220 > > Signed-off-by: Haifeng Lin Not addressed Fixes: comment http://mails.dpdk.org/archives/dev/2020-March/159547.html > --- > .../common/include/arch/arm/rte_atomic_64.h | 3 +++ > .../common/include/arch/arm/rte_cycles_64.h | 20 +++++++++++++++++-- > 2 files changed, 21 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_eal/common/include/arch/arm/rte_atomic_64.h b/lib/librte_eal/common/include/arch/arm/rte_atomic_64.h > index 859ae129d..2587f98a2 100644 > --- a/lib/librte_eal/common/include/arch/arm/rte_atomic_64.h > +++ b/lib/librte_eal/common/include/arch/arm/rte_atomic_64.h > @@ -21,6 +21,7 @@ extern "C" { > > #define dsb(opt) asm volatile("dsb " #opt : : : "memory") > #define dmb(opt) asm volatile("dmb " #opt : : : "memory") > +#define isb() (asm volatile("isb" : : : "memory")) > > #define rte_mb() dsb(sy) > > @@ -44,6 +45,8 @@ extern "C" { > > #define rte_cio_rmb() dmb(oshld) > > +#define rte_isb() isb() Not addressed comment http://mails.dpdk.org/archives/dev/2020-March/159547.html > + > /*------------------------ 128 bit atomic operations -------------------------*/ > > #if defined(__ARM_FEATURE_ATOMICS) || defined(RTE_ARM_FEATURE_ATOMICS) > diff --git a/lib/librte_eal/common/include/arch/arm/rte_cycles_64.h b/lib/librte_eal/common/include/arch/arm/rte_cycles_64.h > index 68e7c7338..bc4e3f8e6 100644 > --- a/lib/librte_eal/common/include/arch/arm/rte_cycles_64.h > +++ b/lib/librte_eal/common/include/arch/arm/rte_cycles_64.h > @@ -18,6 +18,7 @@ extern "C" { > * The time base for this lcore. > */ > #ifndef RTE_ARM_EAL_RDTSC_USE_PMU > + > /** > * This call is portable to any ARMv8 architecture, however, typically > * cntvct_el0 runs at <= 100MHz and it may be imprecise for some tasks. > @@ -59,11 +60,26 @@ rte_rdtsc(void) > } > #endif > > +#define arch_counter_enforce_ordering(val) do { \ > + uint64_t tmp, _val = (val); \ > + \ > + asm volatile( \ > + " eor %0, %1, %1\n" \ > + " add %0, sp, %0\n" \ > + " ldr xzr, [%0]" \ > + : "=r" (tmp) : "r" (_val)); \ > +} while (0) > + Not addressed the comments in http://mails.dpdk.org/archives/dev/2020-March/159547.html Gavin, Linhaifeng, I don't think, this ordering is valid in the DPDK context. See the patch from Will. https://lore.kernel.org/patchwork/patch/1076132/ Thoughts? > static inline uint64_t > rte_rdtsc_precise(void) > { > - rte_mb(); > - return rte_rdtsc(); > + uint64_t tsc; > + > + rte_isb(); > + tsc = rte_rdtsc(); Not addressed the comments in http://mails.dpdk.org/archives/dev/2020-March/159547.html > + arch_counter_enforce_ordering(tsc); > + return tsc; > } > > static inline uint64_t > -- > 2.24.1.windows.2 >