[PATCH v3 2/5] latencystats: handle fractional cycles per ns
Tyler Retzlaff
roretzla at linux.microsoft.com
Thu Apr 18 02:03:30 CEST 2024
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 at 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.
More information about the dev
mailing list