From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 5EA9E1B1C0 for ; Thu, 12 Oct 2017 12:12:50 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D529F20D61; Thu, 12 Oct 2017 06:12:49 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Thu, 12 Oct 2017 06:12:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=F51OuhN/DcNt8tfNr7KT2Gh1Sq G4VtN6JHr1V77+uiY=; b=g90sq6Vhr5IRi8CpCcZ4QfPojZv6pbFhg3CKwCBf1L kCPMCOkm8vQ6senip8cqT+Iyh8LjHSqcn/yqSJ8ukVONyDMTTePiFjeTjkNfo/p0 k0zuW2SZYKt+VJ7necEGm4W8VpLs5RDx6TuOyV6Kvg2HX6iZxCYc54U91eDKwa9o U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=F51Ouh N/DcNt8tfNr7KT2Gh1SqG4VtN6JHr1V77+uiY=; b=HtKe75USvlwp9tQpOv7Lnf zzj70/j8rLFlLH8bwEvAsRLJHHgdMzRgG3yqjvgNQ5idJ8r1aBm7OfEsdU//6M/z sVfZI5/nE78ug30k1hAiS8okMIj0tvFTbl5Ay6Rxcsyi8/n7x8orVcG60zKeAbYh Y6SRoHsVuZbIqP90OCL5PipO6lgAeGNTS9QazP9t7cXyXmQcTXm7ZHHAcrhZhRU6 dbw9HqyxvRJJgpyqr6puZcLBQ9K/MtX/QDD8ggCOu2MCg1ymtEABLibY5UOocPxh kNAQONZMFQQSshQdls7AIuC1d9PqZMuLkUdp0ia3Zxs6N1Neelieq/W4XZK/bbPw == X-ME-Sender: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 7B5C2247DD; Thu, 12 Oct 2017 06:12:49 -0400 (EDT) From: Thomas Monjalon To: Bruce Richardson Cc: Jerin Jacob , Gowrishankar , dev@dpdk.org, Chao Zhu , Konstantin Ananyev , viktorin@rehivetech.com, jianbo.liu@linaro.org Date: Thu, 12 Oct 2017 12:12:48 +0200 Message-ID: <2940582.YtahPHvW5m@xps> In-Reply-To: <20171012084847.GA46424@bricha3-MOBL3.ger.corp.intel.com> References: <1897496.fbWrZq1zZe@xps> <20171012084847.GA46424@bricha3-MOBL3.ger.corp.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v2 5/5] eal/timer: honor architecture specific rdtsc hz function 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: , X-List-Received-Date: Thu, 12 Oct 2017 10:12:50 -0000 12/10/2017 10:48, Bruce Richardson: > On Wed, Oct 11, 2017 at 09:25:58PM +0200, Thomas Monjalon wrote: > > 11/10/2017 20:57, Jerin Jacob: > > > From: Thomas Monjalon > > > > 22/09/2017 10:25, Gowrishankar: > > > > > From: 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 > > > > > > > > I agree on the idea. > > > > > > OK > > > > > > > The namespace of cycles related function in DPDK is a real mess. > > > > > > Absolutely!! > > > > > > > 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. > > > > > > I thought of avoid exporting it. But then if the function is in > > > lib/librte_eal/common/include/arch/../rte_cycles.h it is anyway exposed to > > > application. i.e whatever files in lib/librte_eal/common/include/arch/../ > > > anyway exposed to application. > > > > Ah yes, you are right! > > > > > See last comment. > > > > > > > > > > > > + 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 > > > > 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. > > > > > > I guess, we may need to see to how abstract vmware TSC support also in > > > proper way > > > > Yes > > > > > > 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. > > > > > > If I understand it correctly, You would like to create a header file > > > in lib/librte_eal/common/include/arch/../ which should not be exported and change > > > the name to tsc_arch_hz. > > > > I had not think about the way to do this. > > What about having internal headers in lib/librte_eal/common/arch/ ? > > > > Yes, this area needs cleanup, but I also think that this patchset (and > follow-on patch for x86-specific implementation) does not make things > significantly worse than they are now, while also giving significant > benefits for users both in terms of improved clock accuracy and reduced > startup time (due to not needing sleep). Therefore I'd like to see this > merged into 17.11 as a definite improvement, even if it does not "fix" the > bigger issues of poor naming etc. I think this is important enough an > improvement that we need to see it in the LTS release. I agree Bruce. My initial point was to avoid exporting a new function with a wrong name. It would be better to find a way to avoid this export. If it cannot be done in 17.11 timeframe, we can at least add the experimental tag.