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 EA8771AFE8 for ; Wed, 11 Oct 2017 19:36:12 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 7DBB720D21; Wed, 11 Oct 2017 13:36:12 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 11 Oct 2017 13:36:12 -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=mN4VndwbiIdyeSVCvn89fSH3s7 U4yUnSH43UPbGoIuc=; b=sJRA4HSfm/3BqRLAIRKOTBn5/cfeDgIIh5SOHGC6Hz 0/RdKUjc8s1eC1SRaO+VkbZfnjgw3e5mR7hjxqVssyCQsGBJjEOd34BWFUlxs92U 1DIkwywCKMnXz0k8y7lUzCWe6Ubt8BYBb2/H/yII8hun/wAdE4qcLvdHVedKHGaV 0= 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=mN4Vnd wbiIdyeSVCvn89fSH3s7U4yUnSH43UPbGoIuc=; b=nxUpVv9GyftaDd8Q5tJXou 0XXacqirCD4JRRKtxXJ24GYAOjjPsOfTNYuYMzAbwNUtVVgMiEtgjUS6NHUl4Plx YdUACFMwKZ+nOpV0OHzggcg9NYYTqsFj77yZL6b+SLljiufhROKZcdKmyle9fM9R 48nWlH8F1dfyF3z01usSIt58ES8CGM/LcDtzxyYAXa2eQB3nyvceFOBmR4/2ncDS sJR5n4V5bZkEYNcW3GR7vepBz2kZ93rAW7FzzT82D/idkhOLavQtRDrpedG47Bnx OiqK7btCBqb38xu0HOY9DU0kzcMPPDS6YidFab0heKFwyXVpIIU5xzwvWZceCPhA == 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 1F2882479F; Wed, 11 Oct 2017 13:36:12 -0400 (EDT) From: Thomas Monjalon To: Gowrishankar , Jerin Jacob Cc: dev@dpdk.org, Chao Zhu , Bruce Richardson , Konstantin Ananyev , viktorin@rehivetech.com, jianbo.liu@linaro.org Date: Wed, 11 Oct 2017 19:36:11 +0200 Message-ID: <3939224.L4DEiYxvN2@xps> In-Reply-To: <05e205ba2a617012e7dbea4b384a2a2280b36b63.1506058385.git.gowrishankar.m@linux.vnet.ibm.com> References: <05e205ba2a617012e7dbea4b384a2a2280b36b63.1506058385.git.gowrishankar.m@linux.vnet.ibm.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: Wed, 11 Oct 2017 17:36:13 -0000 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. The namespace of cycles related function in DPDK is a real mess. 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. > + 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 generic code despite HPET is Intel specific. 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. 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.