latencystats: fix missing f suffix on literal float

Message ID 1713216746-25584-1-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series latencystats: fix missing f suffix on literal float |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Tyler Retzlaff April 15, 2024, 9:32 p.m. UTC
  Add missing f suffix to floating point literal to avoid warning about
truncation from double to float.

Fixes: 5cd3cac9ed22 ("latency: added new library for latency stats")
Cc: reshma.pattan@intel.com
Cc: stable@dpdk.org

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/latencystats/rte_latencystats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Stephen Hemminger April 15, 2024, 10:17 p.m. UTC | #1
On Mon, 15 Apr 2024 14:32:26 -0700
Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:

> Add missing f suffix to floating point literal to avoid warning about
> truncation from double to float.
> 
> Fixes: 5cd3cac9ed22 ("latency: added new library for latency stats")
> Cc: reshma.pattan@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  lib/latencystats/rte_latencystats.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c
> index 4ea9b0d..cae4b50 100644
> --- a/lib/latencystats/rte_latencystats.c
> +++ b/lib/latencystats/rte_latencystats.c
> @@ -166,7 +166,7 @@ struct latency_stats_nameoff {
>  	 * a constant smoothing factor between 0 and 1. The value
>  	 * is used below for measuring average latency.
>  	 */
> -	const float alpha = 0.2;
> +	const float alpha = 0.2f;
>  
>  	now = rte_rdtsc();
>  	for (i = 0; i < nb_pkts; i++) {

The use of floating point in fast path here is unnecessary.
Even without doing the full per-core values, this could just change
to an alpha of .25 and use fast fixed point math.
  
Tyler Retzlaff April 15, 2024, 11:14 p.m. UTC | #2
On Mon, Apr 15, 2024 at 03:17:38PM -0700, Stephen Hemminger wrote:
> On Mon, 15 Apr 2024 14:32:26 -0700
> Tyler Retzlaff <roretzla@linux.microsoft.com> wrote:
> 
> > Add missing f suffix to floating point literal to avoid warning about
> > truncation from double to float.
> > 
> > Fixes: 5cd3cac9ed22 ("latency: added new library for latency stats")
> > Cc: reshma.pattan@intel.com
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > ---
> >  lib/latencystats/rte_latencystats.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c
> > index 4ea9b0d..cae4b50 100644
> > --- a/lib/latencystats/rte_latencystats.c
> > +++ b/lib/latencystats/rte_latencystats.c
> > @@ -166,7 +166,7 @@ struct latency_stats_nameoff {
> >  	 * a constant smoothing factor between 0 and 1. The value
> >  	 * is used below for measuring average latency.
> >  	 */
> > -	const float alpha = 0.2;
> > +	const float alpha = 0.2f;
> >  
> >  	now = rte_rdtsc();
> >  	for (i = 0; i < nb_pkts; i++) {
> 
> The use of floating point in fast path here is unnecessary.
> Even without doing the full per-core values, this could just change
> to an alpha of .25 and use fast fixed point math.

agree, though my thoughts are make this code correct optimization is for
the maintainer. if they submit an alternate series i can withdraw this
patch. otherwise i think we should take it as-is.
  

Patch

diff --git a/lib/latencystats/rte_latencystats.c b/lib/latencystats/rte_latencystats.c
index 4ea9b0d..cae4b50 100644
--- a/lib/latencystats/rte_latencystats.c
+++ b/lib/latencystats/rte_latencystats.c
@@ -166,7 +166,7 @@  struct latency_stats_nameoff {
 	 * a constant smoothing factor between 0 and 1. The value
 	 * is used below for measuring average latency.
 	 */
-	const float alpha = 0.2;
+	const float alpha = 0.2f;
 
 	now = rte_rdtsc();
 	for (i = 0; i < nb_pkts; i++) {