From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavan Nikhilesh Subject: Re: [PATCH] eal: roundup tsc frequency when estimating it Date: Fri, 30 Nov 2018 07:17:00 +0000 Message-ID: <20181130071641.GA11625@ltp-pvn> References: <20181129083138.23029-1-pbhagavatula@caviumnetworks.com> <20181129132152.754ce410@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "bruce.richardson@intel.com" , "dev@dpdk.org" To: Stephen Hemminger , "Jacob, Jerin" Return-path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-eopbgr740047.outbound.protection.outlook.com [40.107.74.47]) by dpdk.org (Postfix) with ESMTP id 91F4758FA for ; Fri, 30 Nov 2018 08:17:02 +0100 (CET) In-Reply-To: <20181129132152.754ce410@xeon-e3> Content-Language: en-US Content-ID: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Stephen, On Thu, Nov 29, 2018 at 01:21:52PM -0800, Stephen Hemminger wrote: > On Thu, 29 Nov 2018 08:32:03 +0000 > Pavan Nikhilesh wrote: > > > When estimating tsc frequency using sleep/gettime round it up to the > > nearest multiple of 10Mhz for more accuracy. > > > > Signed-off-by: Pavan Nikhilesh > > Rounding reduces accuracy. > > Why is this code being used? Shouldn't get_tsc_freq_arch return a > correct value? This patch doesn't modify get_tsc_freq_arch(), it basically gives a more accurate freq reading when we rely on sleep(1) i.e. only when get_tsc_freq_arch() returns 0. example: static uint64_t estimate_tsc_freq(void) { RTE_LOG(WARNING, EAL, "WARNING: TSC frequency estimated roughly" " - clock timings may be less accurate.\n"); /* assume that the sleep(1) will sleep for 1 second */ uint64_t start =3D rte_rdtsc(); sleep(1); return rte_rdtsc() - start; } This will not give the accurate cyc/sec in most cases, rounding it to 10Mhz= wil do the job. In case of ARM64 if we enable RTE_ARM_EAL_RDTSC_USE_PMU, get_tsc_freq_arch(= ) will return 0 as there is no instruction to determine the clk of PMU. > > How well does the rdmsr() logic work in VM? > It looks like Hyper-V has special MSR's for TSC frequency determination. Maybe bruce can give a more accurate answer to this as it is x86 specific. Thanks, Pavan.