From patchwork Thu Sep 21 11:41:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar X-Patchwork-Id: 29057 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8E35F1B194; Thu, 21 Sep 2017 13:41:39 +0200 (CEST) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by dpdk.org (Postfix) with ESMTP id 124FF2C36 for ; Thu, 21 Sep 2017 13:41:37 +0200 (CEST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8LBcdCb147729 for ; Thu, 21 Sep 2017 07:41:37 -0400 Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) by mx0b-001b2d01.pphosted.com with ESMTP id 2d4bjyvbb5-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 21 Sep 2017 07:41:37 -0400 Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 21 Sep 2017 21:41:33 +1000 Received: from d23relay08.au.ibm.com (202.81.31.227) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 21 Sep 2017 21:41:31 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v8LBfUSv39649354 for ; Thu, 21 Sep 2017 21:41:30 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v8LBfVn4002614 for ; Thu, 21 Sep 2017 21:41:31 +1000 Received: from chozha.in.ibm.com ([9.77.206.38]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v8LBfRkC002555; Thu, 21 Sep 2017 21:41:28 +1000 From: Gowrishankar To: dev@dpdk.org Cc: Chao Zhu , Bruce Richardson , Konstantin Ananyev , Jerin Jacob , Gowrishankar Muthukrishnan Date: Thu, 21 Sep 2017 17:11:26 +0530 X-Mailer: git-send-email 1.9.1 X-TM-AS-MML: disable x-cbid: 17092111-1617-0000-0000-0000020044F9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17092111-1618-0000-0000-0000484FB0D2 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-21_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709210158 Subject: [dpdk-dev] [PATCH] eal: fix TSC resolution in hz for ppc_64 architecture 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" From: Gowrishankar Muthukrishnan 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 --- 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; }