From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id D38C043E98;
	Thu, 18 Apr 2024 02:03:33 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 796A6402CC;
	Thu, 18 Apr 2024 02:03:33 +0200 (CEST)
Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182])
 by mails.dpdk.org (Postfix) with ESMTP id 1FE1040272
 for <dev@dpdk.org>; Thu, 18 Apr 2024 02:03:31 +0200 (CEST)
Received: by linux.microsoft.com (Postfix, from userid 1086)
 id 700DA20FD4C4; Wed, 17 Apr 2024 17:03:30 -0700 (PDT)
DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 700DA20FD4C4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com;
 s=default; t=1713398610;
 bh=d8tmyyIjHTTMxIJpiSYQTkjXQUa9JOd1J9A6iiLbG4A=;
 h=Date:From:To:Cc:Subject:References:In-Reply-To:From;
 b=oMzp/gUmztXKemA1EjGIZuCs7486nVDvWnNoCjuY31nROkEIli37BqB8glL+CRQa7
 iObEldNVQshyn+ZpBwY/59L58ogU/az2SnIAzt97oAAputpY8uR7v8CNI4y79KCI//
 /igkrQKMlRzwENSMiOafWKlh/6NM0CM8WQ7gPjm4=
Date: Wed, 17 Apr 2024 17:03:30 -0700
From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dev@dpdk.org, Reshma Pattan <reshma.pattan@intel.com>
Subject: Re: [PATCH v3 2/5] latencystats: handle fractional cycles per ns
Message-ID: <20240418000330.GB26881@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>
References: <0240408195036.182545-1-stephen@networkplumber.org>
 <20240417170908.76701-1-stephen@networkplumber.org>
 <20240417170908.76701-3-stephen@networkplumber.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20240417170908.76701-3-stephen@networkplumber.org>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

On Wed, Apr 17, 2024 at 10:07:24AM -0700, Stephen Hemminger wrote:
> The timer_hz is not always an integral number of nanoseconds.
> For examples, cycles per nanoseconds on my test system is 2.8.
> Fix by using floating point where needed.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/latencystats/rte_latencystats.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c
> index 9b345bfb33..fe8c3c563a 100644
> --- a/lib/latencystats/rte_latencystats.c
> +++ b/lib/latencystats/rte_latencystats.c
> @@ -19,10 +19,10 @@
>  #define NS_PER_SEC 1E9
>  
>  /** Clock cycles per nano second */
> -static uint64_t
> +static float
>  latencystat_cycles_per_ns(void)
>  {
> -	return rte_get_timer_hz() / NS_PER_SEC;
> +	return (double)rte_get_timer_hz() / NS_PER_SEC;
>  }

my feeling is this will generate a warning on msvc later double ->
float.