DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal: fix TSC resolution in hz for ppc_64 architecture
@ 2017-09-21 11:41 Gowrishankar
  2017-09-21 12:20 ` Jerin Jacob
  0 siblings, 1 reply; 2+ messages in thread
From: Gowrishankar @ 2017-09-21 11:41 UTC (permalink / raw)
  To: dev
  Cc: Chao Zhu, Bruce Richardson, Konstantin Ananyev, Jerin Jacob,
	Gowrishankar Muthukrishnan

From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>

In ppc_64, rte_rdtsc() returns timebase register value which increments
at independent timebase frequency and hence not related to lcore cpu
frequency to derive into. In this patch, we fix get_tsc_freq() to not
depend upon rte_rdtsc(), but obtain cpu current frequency from sysfs.

Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
---
 Note:
 * This patch would need minor port as per below patch (yet to upstream):
   http://dpdk.org/dev/patchwork/patch/27527/

 lib/librte_eal/linuxapp/eal/eal_timer.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lib/librte_eal/linuxapp/eal/eal_timer.c b/lib/librte_eal/linuxapp/eal/eal_timer.c
index afa32f5..b8775cc 100644
--- a/lib/librte_eal/linuxapp/eal/eal_timer.c
+++ b/lib/librte_eal/linuxapp/eal/eal_timer.c
@@ -55,8 +55,10 @@
 
 #include "eal_private.h"
 #include "eal_internal_cfg.h"
+#include "eal_filesystem.h"
 
 enum timer_source eal_timer_source = EAL_TIMER_HPET;
+static const char sys_cpu_dir[] = "/sys/devices/system/cpu";
 
 #ifdef RTE_LIBEAL_USE_HPET
 
@@ -269,6 +271,17 @@ struct eal_hpet_regs {
 uint64_t
 get_tsc_freq(void)
 {
+#ifdef RTE_ARCH_PPC_64
+	unsigned long cpu_hz;
+	char path[PATH_MAX];
+
+	snprintf(path, sizeof(path), "%s/cpu%d/cpufreq/cpuinfo_cur_freq",
+			sys_cpu_dir, rte_get_master_lcore());
+	if (eal_parse_sysfs_value(path, &cpu_hz) < 0)
+		RTE_LOG(WARNING, EAL, "Unable to parse %s\n",
+				path);
+	return cpu_hz*1000;
+#else
 #ifdef CLOCK_MONOTONIC_RAW
 #define NS_PER_SEC 1E9
 
@@ -290,6 +303,7 @@ struct eal_hpet_regs {
 		return tsc_hz;
 	}
 #endif
+#endif
 	return 0;
 }
 
-- 
1.9.1

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

* Re: [dpdk-dev] [PATCH] eal: fix TSC resolution in hz for ppc_64 architecture
  2017-09-21 11:41 [dpdk-dev] [PATCH] eal: fix TSC resolution in hz for ppc_64 architecture Gowrishankar
@ 2017-09-21 12:20 ` Jerin Jacob
  0 siblings, 0 replies; 2+ messages in thread
From: Jerin Jacob @ 2017-09-21 12:20 UTC (permalink / raw)
  To: Gowrishankar; +Cc: dev, Chao Zhu, Bruce Richardson, Konstantin Ananyev

-----Original Message-----
> Date: Thu, 21 Sep 2017 17:11:26 +0530
> From: Gowrishankar <gowrishankar.m@linux.vnet.ibm.com>
> To: dev@dpdk.org
> CC: Chao Zhu <chaozhu@linux.vnet.ibm.com>, Bruce Richardson
>  <bruce.richardson@intel.com>, Konstantin Ananyev
>  <konstantin.ananyev@intel.com>, Jerin Jacob
>  <jerin.jacob@caviumnetworks.com>, Gowrishankar Muthukrishnan
>  <gowrishankar.m@linux.vnet.ibm.com>
> Subject: [PATCH] eal: fix TSC resolution in hz for ppc_64 architecture
> X-Mailer: git-send-email 1.9.1
> 
> From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
> 
> In ppc_64, rte_rdtsc() returns timebase register value which increments
> at independent timebase frequency and hence not related to lcore cpu
> frequency to derive into. In this patch, we fix get_tsc_freq() to not
> depend upon rte_rdtsc(), but obtain cpu current frequency from sysfs.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>

Hi Gowrishankar,

> ---
>  Note:
>  * This patch would need minor port as per below patch (yet to upstream):
>    http://dpdk.org/dev/patchwork/patch/27527/
> 
>  lib/librte_eal/linuxapp/eal/eal_timer.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_timer.c b/lib/librte_eal/linuxapp/eal/eal_timer.c
> index afa32f5..b8775cc 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_timer.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_timer.c
> @@ -55,8 +55,10 @@
>  
>  #include "eal_private.h"
>  #include "eal_internal_cfg.h"
> +#include "eal_filesystem.h"
>  
>  enum timer_source eal_timer_source = EAL_TIMER_HPET;
> +static const char sys_cpu_dir[] = "/sys/devices/system/cpu";
>  
>  #ifdef RTE_LIBEAL_USE_HPET
>  
> @@ -269,6 +271,17 @@ struct eal_hpet_regs {
>  uint64_t
>  get_tsc_freq(void)
>  {
> +#ifdef RTE_ARCH_PPC_64

I guess you can use the below series to avoid ifdef clutter in common code.
Right?

http://dpdk.org/ml/archives/dev/2017-August/072805.html.

If yes, then you could resend the series with ppc_64 change.i.e
removing following patch and add yours.
http://dpdk.org/dev/patchwork/patch/27527/


> +	unsigned long cpu_hz;
> +	char path[PATH_MAX];
> +
> +	snprintf(path, sizeof(path), "%s/cpu%d/cpufreq/cpuinfo_cur_freq",
> +			sys_cpu_dir, rte_get_master_lcore());
> +	if (eal_parse_sysfs_value(path, &cpu_hz) < 0)
> +		RTE_LOG(WARNING, EAL, "Unable to parse %s\n",
> +				path);
> +	return cpu_hz*1000;
> +#else
>  #ifdef CLOCK_MONOTONIC_RAW
>  #define NS_PER_SEC 1E9
>  
> @@ -290,6 +303,7 @@ struct eal_hpet_regs {
>  		return tsc_hz;
>  	}
>  #endif
> +#endif
>  	return 0;
>  }
>  
> -- 
> 1.9.1
> 

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

end of thread, other threads:[~2017-09-21 12:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-21 11:41 [dpdk-dev] [PATCH] eal: fix TSC resolution in hz for ppc_64 architecture Gowrishankar
2017-09-21 12:20 ` Jerin Jacob

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).