DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Gowrishankar <gowrishankar.m@linux.vnet.ibm.com>,
	Jerin Jacob <jerin.jacob@caviumnetworks.com>
Cc: dev@dpdk.org, Chao Zhu <chaozhu@linux.vnet.ibm.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Konstantin Ananyev <konstantin.ananyev@intel.com>,
	viktorin@rehivetech.com, jianbo.liu@linaro.org
Subject: Re: [dpdk-dev] [PATCH v2 5/5] eal/timer: honor architecture specific rdtsc hz function
Date: Wed, 11 Oct 2017 19:36:11 +0200	[thread overview]
Message-ID: <3939224.L4DEiYxvN2@xps> (raw)
In-Reply-To: <05e205ba2a617012e7dbea4b384a2a2280b36b63.1506058385.git.gowrishankar.m@linux.vnet.ibm.com>

22/09/2017 10:25, Gowrishankar:
> From: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> 
> When calibrating the tsc frequency, first, probe the architecture specific
> rdtsc hz function. if not available, use the existing calibrate scheme
> to calibrate the tsc frequency.
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

I agree on the idea.

The namespace of cycles related function in DPDK is a real mess.
I think we can choose better names in this series as a first step
to tidy this mess.
I will explain below.

At first, we should avoid TSC and RDTSC which are Intel-only wording.
The generic word could be "cycles" (the word used in arch headers),
or "ticks".
We should also name the timer sources or their function in a generic way.
Examples: CPU cycles? fast counter? precise counter?

Sometimes we use "hz", sometimes "freq".
It would better to keep one of them.

> --- a/lib/librte_eal/common/eal_common_timer.c
> +++ b/lib/librte_eal/common/eal_common_timer.c
> @@ -80,8 +80,11 @@
>  void
>  set_tsc_freq(void)
>  {
> -	uint64_t freq = get_tsc_freq();
> +	uint64_t freq;
>  
> +	freq = rte_rdtsc_arch_hz();

This new function is arch-specific and exported as a new API.

> +	if (!freq)
> +		freq = get_tsc_freq();

The function get_tsc_freq is guessing the freq with OS-specific method.

>  	if (!freq)
>  		freq = estimate_tsc_freq();

The function estimate_tsc_freq is doing an estimation based on sleep().

At the end, the most accurate frequency is saved in eal_tsc_resolution_hz
and can be retrieved with rte_get_tsc_hz().
I don't understand why rte_rdtsc_arch_hz() is also exported to the apps.

TSC and HPET timer sources are wrapped in rte_get_timer_hz() in the
generic code despite HPET is Intel specific.

Similarly we can get the current timer with rte_get_timer_cycles().
In the case of TSC, it calls rte_get_tsc_cycles() which is an alias
of rte_rdtsc().
Some code is still using directly rte_rdtsc().
There is also rte_rdtsc_precise which adds a memory barrier.

The real question is what is the right abstraction for the application?
Do we want the fastest timer? the CPU timer? a precise timer?

I would like to see a real discussion on this topic, in order of building
a new timer API which would alias the old one for some time.

If you don't want to bother with all these questions, I suggest to not
export the new function rte_rdtsc_arch_hz() and rename it to tsc_arch_hz.

  reply	other threads:[~2017-10-11 17:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-22  8:25 [dpdk-dev] [PATCH v2 0/5] improve tsc frequency calibration Gowrishankar
2017-09-22  8:25 ` [dpdk-dev] [PATCH v2 1/5] eal/x86: define architecture specific rdtsc hz Gowrishankar
2017-09-22  8:25 ` [dpdk-dev] [PATCH v2 2/5] eal/ppc64: " Gowrishankar
2017-10-12 22:20   ` Thomas Monjalon
2017-09-22  8:25 ` [dpdk-dev] [PATCH v2 3/5] eal/armv7: " Gowrishankar
2017-09-22  8:25 ` [dpdk-dev] [PATCH v2 4/5] eal/armv8: " Gowrishankar
2017-09-22  8:25 ` [dpdk-dev] [PATCH v2 5/5] eal/timer: honor architecture specific rdtsc hz function Gowrishankar
2017-10-11 17:36   ` Thomas Monjalon [this message]
2017-10-11 18:57     ` Jerin Jacob
2017-10-11 19:25       ` Thomas Monjalon
2017-10-12  8:48         ` Bruce Richardson
2017-10-12 10:12           ` Thomas Monjalon
2017-10-12 10:25             ` Bruce Richardson
2017-10-12 10:16         ` Jerin Jacob
2017-10-13  0:02 ` [dpdk-dev] [PATCH 0/4] improve tsc frequency calibration Thomas Monjalon
2017-10-13  0:02   ` [dpdk-dev] [PATCH 1/4] timer: honor arch-specific TSC frequency query Thomas Monjalon
2017-10-13  0:02   ` [dpdk-dev] [PATCH 2/4] eal/armv8: implement arch-specific TSC freq query Thomas Monjalon
2017-10-13  0:02   ` [dpdk-dev] [PATCH 3/4] eal/ppc64: " Thomas Monjalon
2017-10-13  0:02   ` [dpdk-dev] [PATCH 4/4] eal/x86: " Thomas Monjalon
2017-10-13  3:47     ` Stephen Hemminger
2017-10-13  7:30       ` Thomas Monjalon
2017-10-13 15:13         ` Stephen Hemminger
2017-10-13 15:17           ` Bruce Richardson
2017-10-13  3:21   ` [dpdk-dev] [PATCH 0/4] improve tsc frequency calibration Jerin Jacob
2017-10-13 11:08     ` Thomas Monjalon

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=3939224.L4DEiYxvN2@xps \
    --to=thomas@monjalon.net \
    --cc=bruce.richardson@intel.com \
    --cc=chaozhu@linux.vnet.ibm.com \
    --cc=dev@dpdk.org \
    --cc=gowrishankar.m@linux.vnet.ibm.com \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=jianbo.liu@linaro.org \
    --cc=konstantin.ananyev@intel.com \
    --cc=viktorin@rehivetech.com \
    /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).