All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] improve tsc frequency calibration
@ 2017-08-13  7:03 Jerin Jacob
  2017-08-13  7:03 ` [PATCH 1/5] eal/x86: define architecture specific rdtsc hz Jerin Jacob
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Jerin Jacob @ 2017-08-13  7:03 UTC (permalink / raw)
  To: dev
  Cc: thomas, bruce.richardson, konstantin.ananyev, viktorin,
	jianbo.liu, chaozhu, Jerin Jacob

Some architecture like armv8 provides an architecture specific function
to get the rdtsc frequency. The existing rdtsc calibration scheme uses
OS serivce like sleep(1) to calibrate the frequency which may not
produce the accurate result. Introducing an architecture specific hook
to get the rdtsc frequency if architecture provides it. If not, use the
exiting the calibrate scheme to get the rdtsc frequency.

Jerin Jacob (5):
  eal/x86: define architecture specific rdtsc hz
  eal/ppc64: define architecture specific rdtsc hz
  eal/armv7: define architecture specific rdtsc hz
  eal/armv8: define architecture specific rdtsc hz
  eal/timer: honor architecture specific rdtsc hz function

 lib/librte_eal/common/eal_common_timer.c           |  5 +++-
 .../common/include/arch/arm/rte_cycles_32.h        | 13 ++++++++++
 .../common/include/arch/arm/rte_cycles_64.h        | 30 ++++++++++++++++++++++
 .../common/include/arch/ppc_64/rte_cycles.h        | 13 ++++++++++
 .../common/include/arch/x86/rte_cycles.h           | 13 ++++++++++
 5 files changed, 73 insertions(+), 1 deletion(-)

-- 
2.14.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/5] eal/x86: define architecture specific rdtsc hz
  2017-08-13  7:03 [PATCH 0/5] improve tsc frequency calibration Jerin Jacob
@ 2017-08-13  7:03 ` Jerin Jacob
  2017-09-18 12:54   ` Burakov, Anatoly
  2017-08-13  7:03 ` [PATCH 2/5] eal/ppc64: " Jerin Jacob
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Jerin Jacob @ 2017-08-13  7:03 UTC (permalink / raw)
  To: dev
  Cc: thomas, bruce.richardson, konstantin.ananyev, viktorin,
	jianbo.liu, chaozhu, Jerin Jacob

CC: Bruce Richardson <bruce.richardson@intel.com>
CC: Konstantin Ananyev <konstantin.ananyev@intel.com>

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 lib/librte_eal/common/include/arch/x86/rte_cycles.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/librte_eal/common/include/arch/x86/rte_cycles.h b/lib/librte_eal/common/include/arch/x86/rte_cycles.h
index 1bb3e1dbe..e2661e278 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_cycles.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_cycles.h
@@ -77,6 +77,19 @@ rte_rdtsc(void)
 	return tsc.tsc_64;
 }
 
+/**
+ * Get the number of rdtsc cycles in one second if the architecture supports.
+ *
+ * @return
+ *   The number of rdtsc cycles in one second. Return zero if the architecture
+ *   support is not available.
+ */
+static inline uint64_t
+rte_rdtsc_arch_hz(void)
+{
+	return 0;
+}
+
 static inline uint64_t
 rte_rdtsc_precise(void)
 {
-- 
2.14.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/5] eal/ppc64: define architecture specific rdtsc hz
  2017-08-13  7:03 [PATCH 0/5] improve tsc frequency calibration Jerin Jacob
  2017-08-13  7:03 ` [PATCH 1/5] eal/x86: define architecture specific rdtsc hz Jerin Jacob
@ 2017-08-13  7:03 ` Jerin Jacob
  2017-09-28  1:53   ` Chao Zhu
  2017-08-13  7:03 ` [PATCH 3/5] eal/armv7: " Jerin Jacob
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Jerin Jacob @ 2017-08-13  7:03 UTC (permalink / raw)
  To: dev
  Cc: thomas, bruce.richardson, konstantin.ananyev, viktorin,
	jianbo.liu, chaozhu, Jerin Jacob

CC: Chao Zhu <chaozhu@linux.vnet.ibm.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
index 8fa6fc60b..20243fb29 100644
--- a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
+++ b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
@@ -79,6 +79,19 @@ rte_rdtsc(void)
 	return tsc.tsc_64;
 }
 
+/**
+ * Get the number of rdtsc cycles in one second if the architecture supports.
+ *
+ * @return
+ *   The number of rdtsc cycles in one second. Return zero if the architecture
+ *   support is not available.
+ */
+static inline uint64_t
+rte_rdtsc_arch_hz(void)
+{
+	return 0;
+}
+
 static inline uint64_t
 rte_rdtsc_precise(void)
 {
-- 
2.14.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/5] eal/armv7: define architecture specific rdtsc hz
  2017-08-13  7:03 [PATCH 0/5] improve tsc frequency calibration Jerin Jacob
  2017-08-13  7:03 ` [PATCH 1/5] eal/x86: define architecture specific rdtsc hz Jerin Jacob
  2017-08-13  7:03 ` [PATCH 2/5] eal/ppc64: " Jerin Jacob
@ 2017-08-13  7:03 ` Jerin Jacob
  2017-08-13  7:03 ` [PATCH 4/5] eal/armv8: " Jerin Jacob
  2017-08-13  7:03 ` [PATCH 5/5] eal/timer: honor architecture specific rdtsc hz function Jerin Jacob
  4 siblings, 0 replies; 9+ messages in thread
From: Jerin Jacob @ 2017-08-13  7:03 UTC (permalink / raw)
  To: dev
  Cc: thomas, bruce.richardson, konstantin.ananyev, viktorin,
	jianbo.liu, chaozhu, Jerin Jacob

CC: Jan Viktorin <viktorin@rehivetech.com>
CC: Jianbo Liu <jianbo.liu@linaro.org>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 lib/librte_eal/common/include/arch/arm/rte_cycles_32.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/librte_eal/common/include/arch/arm/rte_cycles_32.h b/lib/librte_eal/common/include/arch/arm/rte_cycles_32.h
index 9c1be71ea..68d7462c4 100644
--- a/lib/librte_eal/common/include/arch/arm/rte_cycles_32.h
+++ b/lib/librte_eal/common/include/arch/arm/rte_cycles_32.h
@@ -104,6 +104,19 @@ __rte_rdtsc_pmccntr(void)
 
 #endif /* RTE_ARM_EAL_RDTSC_USE_PMU */
 
+/**
+ * Get the number of rdtsc cycles in one second if the architecture supports.
+ *
+ * @return
+ *   The number of rdtsc cycles in one second. Return zero if the architecture
+ *   support is not available.
+ */
+static inline uint64_t
+rte_rdtsc_arch_hz(void)
+{
+	return 0;
+}
+
 static inline uint64_t
 rte_rdtsc_precise(void)
 {
-- 
2.14.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/5] eal/armv8: define architecture specific rdtsc hz
  2017-08-13  7:03 [PATCH 0/5] improve tsc frequency calibration Jerin Jacob
                   ` (2 preceding siblings ...)
  2017-08-13  7:03 ` [PATCH 3/5] eal/armv7: " Jerin Jacob
@ 2017-08-13  7:03 ` Jerin Jacob
  2017-08-15  3:35   ` Jianbo Liu
  2017-08-13  7:03 ` [PATCH 5/5] eal/timer: honor architecture specific rdtsc hz function Jerin Jacob
  4 siblings, 1 reply; 9+ messages in thread
From: Jerin Jacob @ 2017-08-13  7:03 UTC (permalink / raw)
  To: dev
  Cc: thomas, bruce.richardson, konstantin.ananyev, viktorin,
	jianbo.liu, chaozhu, Jerin Jacob

Use cntvct_el0 system register to get the system counter frequency.

If the system is configured with RTE_ARM_EAL_RDTSC_USE_PMU then
return 0(let the common code calibrate the tsc frequency).

CC: Jianbo Liu <jianbo.liu@linaro.org>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 .../common/include/arch/arm/rte_cycles_64.h        | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

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 154576910..5b95cb67d 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
@@ -58,6 +58,23 @@ rte_rdtsc(void)
 	asm volatile("mrs %0, cntvct_el0" : "=r" (tsc));
 	return tsc;
 }
+
+/**
+ * Get the number of rdtsc cycles in one second if the architecture supports.
+ *
+ * @return
+ *   The number of rdtsc cycles in one second. Return zero if the architecture
+ *   support is not available.
+ */
+static inline uint64_t
+rte_rdtsc_arch_hz(void)
+{
+	uint64_t freq;
+
+	asm volatile("mrs %0, cntfrq_el0" : "=r" (freq));
+	return freq;
+}
+
 #else
 /**
  * This is an alternative method to enable rte_rdtsc() with high resolution
@@ -85,6 +102,19 @@ rte_rdtsc(void)
 	asm volatile("mrs %0, pmccntr_el0" : "=r"(tsc));
 	return tsc;
 }
+
+/**
+ * Get the number of rdtsc cycles in one second if the architecture supports.
+ *
+ * @return
+ *   The number of rdtsc cycles in one second. Return zero if the architecture
+ *   support is not available.
+ */
+static inline uint64_t
+rte_rdtsc_arch_hz(void)
+{
+	return 0;
+}
 #endif
 
 static inline uint64_t
-- 
2.14.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 5/5] eal/timer: honor architecture specific rdtsc hz function
  2017-08-13  7:03 [PATCH 0/5] improve tsc frequency calibration Jerin Jacob
                   ` (3 preceding siblings ...)
  2017-08-13  7:03 ` [PATCH 4/5] eal/armv8: " Jerin Jacob
@ 2017-08-13  7:03 ` Jerin Jacob
  4 siblings, 0 replies; 9+ messages in thread
From: Jerin Jacob @ 2017-08-13  7:03 UTC (permalink / raw)
  To: dev
  Cc: thomas, bruce.richardson, konstantin.ananyev, viktorin,
	jianbo.liu, chaozhu, Jerin Jacob

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>
---
 lib/librte_eal/common/eal_common_timer.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_timer.c b/lib/librte_eal/common/eal_common_timer.c
index ed0b16d05..978edaed7 100644
--- a/lib/librte_eal/common/eal_common_timer.c
+++ b/lib/librte_eal/common/eal_common_timer.c
@@ -80,8 +80,11 @@ estimate_tsc_freq(void)
 void
 set_tsc_freq(void)
 {
-	uint64_t freq = get_tsc_freq();
+	uint64_t freq;
 
+	freq = rte_rdtsc_arch_hz();
+	if (!freq)
+		freq = get_tsc_freq();
 	if (!freq)
 		freq = estimate_tsc_freq();
 
-- 
2.14.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/5] eal/armv8: define architecture specific rdtsc hz
  2017-08-13  7:03 ` [PATCH 4/5] eal/armv8: " Jerin Jacob
@ 2017-08-15  3:35   ` Jianbo Liu
  0 siblings, 0 replies; 9+ messages in thread
From: Jianbo Liu @ 2017-08-15  3:35 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: dev, Thomas Monjalon, Bruce Richardson, Ananyev, Konstantin,
	Jan Viktorin, Chao Zhu

On 13 August 2017 at 15:03, Jerin Jacob <jerin.jacob@caviumnetworks.com> wrote:
> Use cntvct_el0 system register to get the system counter frequency.
>
> If the system is configured with RTE_ARM_EAL_RDTSC_USE_PMU then
> return 0(let the common code calibrate the tsc frequency).
>
> CC: Jianbo Liu <jianbo.liu@linaro.org>
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>  .../common/include/arch/arm/rte_cycles_64.h        | 30 ++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
>
> 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 154576910..5b95cb67d 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
> @@ -58,6 +58,23 @@ rte_rdtsc(void)
>         asm volatile("mrs %0, cntvct_el0" : "=r" (tsc));
>         return tsc;
>  }
> +
> +/**
> + * Get the number of rdtsc cycles in one second if the architecture supports.
> + *
> + * @return
> + *   The number of rdtsc cycles in one second. Return zero if the architecture
> + *   support is not available.
> + */
> +static inline uint64_t
> +rte_rdtsc_arch_hz(void)
> +{
> +       uint64_t freq;
> +
> +       asm volatile("mrs %0, cntfrq_el0" : "=r" (freq));
> +       return freq;
> +}
> +
>  #else
>  /**
>   * This is an alternative method to enable rte_rdtsc() with high resolution
> @@ -85,6 +102,19 @@ rte_rdtsc(void)
>         asm volatile("mrs %0, pmccntr_el0" : "=r"(tsc));
>         return tsc;
>  }
> +
> +/**
> + * Get the number of rdtsc cycles in one second if the architecture supports.
> + *
> + * @return
> + *   The number of rdtsc cycles in one second. Return zero if the architecture
> + *   support is not available.
> + */
> +static inline uint64_t
> +rte_rdtsc_arch_hz(void)
> +{
> +       return 0;
> +}
>  #endif
>
>  static inline uint64_t
> --
> 2.14.0
>

Acked-by: Jianbo Liu <jianbo.liu@linaro.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/5] eal/x86: define architecture specific rdtsc hz
  2017-08-13  7:03 ` [PATCH 1/5] eal/x86: define architecture specific rdtsc hz Jerin Jacob
@ 2017-09-18 12:54   ` Burakov, Anatoly
  0 siblings, 0 replies; 9+ messages in thread
From: Burakov, Anatoly @ 2017-09-18 12:54 UTC (permalink / raw)
  To: jerin.jacob; +Cc: dev, bruce.richardson, konstantin.ananyev

On 13-Aug-17 8:03 AM, jerin.jacob at caviumnetworks.com (Jerin Jacob) wrote:
> CC: Bruce Richardson <bruce.richardson at intel.com>
> CC: Konstantin Ananyev <konstantin.ananyev at intel.com>
> 
> Signed-off-by: Jerin Jacob <jerin.jacob at caviumnetworks.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/5] eal/ppc64: define architecture specific rdtsc hz
  2017-08-13  7:03 ` [PATCH 2/5] eal/ppc64: " Jerin Jacob
@ 2017-09-28  1:53   ` Chao Zhu
  0 siblings, 0 replies; 9+ messages in thread
From: Chao Zhu @ 2017-09-28  1:53 UTC (permalink / raw)
  To: 'Jerin Jacob', dev
  Cc: thomas, bruce.richardson, konstantin.ananyev, viktorin, jianbo.liu

> -----Original Message-----
> From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com]
> Sent: 2017年8月13日 15:04
> To: dev@dpdk.org
> Cc: thomas@monjalon.net; bruce.richardson@intel.com;
> konstantin.ananyev@intel.com; viktorin@rehivetech.com;
> jianbo.liu@linaro.org; chaozhu@linux.vnet.ibm.com; Jerin Jacob
> <jerin.jacob@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH 2/5] eal/ppc64: define architecture specific
rdtsc hz
> 
> CC: Chao Zhu <chaozhu@linux.vnet.ibm.com>
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>  lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
> b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
> index 8fa6fc60b..20243fb29 100644
> --- a/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
> +++ b/lib/librte_eal/common/include/arch/ppc_64/rte_cycles.h
> @@ -79,6 +79,19 @@ rte_rdtsc(void)
>  	return tsc.tsc_64;
>  }
> 
> +/**
> + * Get the number of rdtsc cycles in one second if the architecture
supports.
> + *
> + * @return
> + *   The number of rdtsc cycles in one second. Return zero if the
architecture
> + *   support is not available.
> + */
> +static inline uint64_t
> +rte_rdtsc_arch_hz(void)
> +{
> +	return 0;
> +}
> +
>  static inline uint64_t
>  rte_rdtsc_precise(void)
>  {
> --
> 2.14.0
Acked-by: Chao Zhu <chaozhu@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-09-28  1:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-13  7:03 [PATCH 0/5] improve tsc frequency calibration Jerin Jacob
2017-08-13  7:03 ` [PATCH 1/5] eal/x86: define architecture specific rdtsc hz Jerin Jacob
2017-09-18 12:54   ` Burakov, Anatoly
2017-08-13  7:03 ` [PATCH 2/5] eal/ppc64: " Jerin Jacob
2017-09-28  1:53   ` Chao Zhu
2017-08-13  7:03 ` [PATCH 3/5] eal/armv7: " Jerin Jacob
2017-08-13  7:03 ` [PATCH 4/5] eal/armv8: " Jerin Jacob
2017-08-15  3:35   ` Jianbo Liu
2017-08-13  7:03 ` [PATCH 5/5] eal/timer: honor architecture specific rdtsc hz function Jerin Jacob

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.