From: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
To: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>,
"dev@dpdk.org" <dev@dpdk.org>,
Jerin Jacob Kollanukkaran <jerinj@marvell.com>,
"hemant.agrawal@nxp.com" <hemant.agrawal@nxp.com>,
"akhil.goyal@nxp.com" <akhil.goyal@nxp.com>,
"ogerlitz@mellanox.com" <ogerlitz@mellanox.com>,
"ajit.khaparde@broadcom.com" <ajit.khaparde@broadcom.com>
Cc: "ruigeng.wang@arm.com" <ruigeng.wang@arm.com>,
"dharmik.thakkar@arm.com" <dharmik.thakkar@arm.com>,
"phil.yang@arm.com" <phil.yang@arm.com>,
"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] eal: generic counter based loop for CPU freq calculation
Date: Wed, 24 Jun 2020 15:09:24 +0000 [thread overview]
Message-ID: <BN6PR18MB11401E50F1D39BA36262A246DE950@BN6PR18MB1140.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20200608213417.9764-1-honnappa.nagarahalli@arm.com>
>Subject: [dpdk-dev] [PATCH] eal: generic counter based loop for CPU
>freq calculation
>
>get_tsc_freq uses 'nanosleep' system call to calculate the CPU
>frequency. However, 'nanosleep' results in the process getting
>un-scheduled. The kernel saves and restores the PMU state. This
>ensures that the PMU cycles are not counted towards a sleeping
>process. When RTE_ARM_EAL_RDTSC_USE_PMU is defined, this results
>in incorrect CPU frequency calculation. This logic is replaced
>with generic counter based loop.
>
>Bugzilla ID: 450
>Fixes: af75078fece3 ("first public release")
>Cc: stable@dpdk.org
>
>Signed-off-by: Honnappa Nagarahalli
><honnappa.nagarahalli@arm.com>
>Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
>Reviewed-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
>Reviewed-by: Phil Yang <phil.yang@arm.com>
>
>---
> lib/librte_eal/arm/include/rte_cycles_64.h | 45
>+++++++++++++++++++---
> lib/librte_eal/arm/rte_cycles.c | 24 ++++++++++--
> 2 files changed, 61 insertions(+), 8 deletions(-)
>
<Snip>
>
> uint64_t
> get_tsc_freq_arch(void)
> {
> #if defined RTE_ARCH_ARM64 && !defined
>RTE_ARM_EAL_RDTSC_USE_PMU
>- uint64_t freq;
>- asm volatile("mrs %0, cntfrq_el0" : "=r" (freq));
>- return freq;
>+ return __rte_rd_generic_cntr_freq();
>+#elif defined RTE_ARCH_ARM64 && defined
>RTE_ARM_EAL_RDTSC_USE_PMU
>+ /* Use the generic counter ticks to calculate the PMU
>+ * cycle frequency.
>+ */
>+ uint64_t gcnt_ticks;
>+ uint64_t start_ticks, cur_ticks;
>+ uint64_t start_pmu_cycles, end_pmu_cycles;
>+
>+ /* Number of ticks for 1/10 second */
>+ gcnt_ticks = __rte_rd_generic_cntr_freq() / 10;
>+
>+ start_ticks = __rte_rd_generic_cntr_precise();
>+ start_pmu_cycles = rte_rdtsc_precise();
>+ do {
>+ cur_ticks = __rte_rd_generic_cntr();
>+ } while ((cur_ticks - start_ticks) < gcnt_ticks);
>+ end_pmu_cycles = rte_rdtsc_precise();
>+
>+ return ((end_pmu_cycles - start_pmu_cycles) * 10);
I think we need to round this of to the next multiple of 10.
Sometimes it is off by one
EAL: TSC frequency is ~2399999 KHz
Similar to http://git.dpdk.org/dpdk/tree/lib/librte_eal/common/eal_common_timer.c#n54
Pavan.
> #else
> return 0;
> #endif
>--
>2.17.1
next prev parent reply other threads:[~2020-06-24 15:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-08 21:34 [dpdk-stable] " Honnappa Nagarahalli
2020-06-24 12:50 ` [dpdk-stable] [dpdk-dev] " Jerin Jacob
2020-06-26 20:46 ` Honnappa Nagarahalli
2020-06-24 15:09 ` Pavan Nikhilesh Bhagavatula [this message]
2020-06-26 20:35 ` [dpdk-stable] [PATCH v2 1/2] eal/arm: " Honnappa Nagarahalli
2020-07-07 11:16 ` [dpdk-stable] [dpdk-dev] " David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BN6PR18MB11401E50F1D39BA36262A246DE950@BN6PR18MB1140.namprd18.prod.outlook.com \
--to=pbhagavatula@marvell.com \
--cc=ajit.khaparde@broadcom.com \
--cc=akhil.goyal@nxp.com \
--cc=dev@dpdk.org \
--cc=dharmik.thakkar@arm.com \
--cc=hemant.agrawal@nxp.com \
--cc=honnappa.nagarahalli@arm.com \
--cc=jerinj@marvell.com \
--cc=ogerlitz@mellanox.com \
--cc=phil.yang@arm.com \
--cc=ruigeng.wang@arm.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).