rte_reciprocal: make arg to rte_reciprocal_divide_u64 const

Message ID 20190321195910.11140-1-stephen@networkplumber.org
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • rte_reciprocal: make arg to rte_reciprocal_divide_u64 const
Related show

Checks

Context Check Description
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger March 21, 2019, 7:59 p.m.
The divisor is not modified here. Doesn't really matter for optimizaton
since the function is inline already; but helps with expressing
intent.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/common/include/rte_reciprocal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Maxime Coquelin March 22, 2019, 6:09 p.m. | #1
On 3/21/19 8:59 PM, Stephen Hemminger wrote:
> The divisor is not modified here. Doesn't really matter for optimizaton
> since the function is inline already; but helps with expressing
> intent.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>   lib/librte_eal/common/include/rte_reciprocal.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/common/include/rte_reciprocal.h b/lib/librte_eal/common/include/rte_reciprocal.h
> index 3492c73bafea..63e16fde0aa8 100644
> --- a/lib/librte_eal/common/include/rte_reciprocal.h
> +++ b/lib/librte_eal/common/include/rte_reciprocal.h
> @@ -77,7 +77,7 @@ mullhi_u64(uint64_t x, uint64_t y)
>   }
>   
>   static __rte_always_inline uint64_t
> -rte_reciprocal_divide_u64(uint64_t a, struct rte_reciprocal_u64 *R)
> +rte_reciprocal_divide_u64(uint64_t a, const struct rte_reciprocal_u64 *R)
>   {
>   	uint64_t t = mullhi_u64(a, R->m);
>   
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thomas Monjalon March 27, 2019, 11:14 a.m. | #2
21/03/2019 20:59, Stephen Hemminger:
> The divisor is not modified here. Doesn't really matter for optimizaton
> since the function is inline already; but helps with expressing
> intent.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  static __rte_always_inline uint64_t
> -rte_reciprocal_divide_u64(uint64_t a, struct rte_reciprocal_u64 *R)
> +rte_reciprocal_divide_u64(uint64_t a, const struct rte_reciprocal_u64 *R)

Why not doing the same change for rte_reciprocal_divide()?

Should we advertise such API change?
Stephen Hemminger April 2, 2019, 3:26 p.m. | #3
On Wed, 27 Mar 2019 12:14:44 +0100
Thomas Monjalon <thomas@monjalon.net> wrote:

> 21/03/2019 20:59, Stephen Hemminger:
> > The divisor is not modified here. Doesn't really matter for optimizaton
> > since the function is inline already; but helps with expressing
> > intent.
> > 
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  static __rte_always_inline uint64_t
> > -rte_reciprocal_divide_u64(uint64_t a, struct rte_reciprocal_u64 *R)
> > +rte_reciprocal_divide_u64(uint64_t a, const struct rte_reciprocal_u64 *R)  
> 
> Why not doing the same change for rte_reciprocal_divide()?
It doesn't make sense for rte_reciprocal_divide since rte_reciprocal_divide
is call by value (ie doesn't take a pointer).


> Should we advertise such API change?

No. Since constant is always less intrusive than previous version
all cases will work the same.
Thomas Monjalon April 2, 2019, 4:05 p.m. | #4
02/04/2019 17:26, Stephen Hemminger:
> On Wed, 27 Mar 2019 12:14:44 +0100
> Thomas Monjalon <thomas@monjalon.net> wrote:
> 
> > 21/03/2019 20:59, Stephen Hemminger:
> > > The divisor is not modified here. Doesn't really matter for optimizaton
> > > since the function is inline already; but helps with expressing
> > > intent.
> > > 
> > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > > ---
> > >  static __rte_always_inline uint64_t
> > > -rte_reciprocal_divide_u64(uint64_t a, struct rte_reciprocal_u64 *R)
> > > +rte_reciprocal_divide_u64(uint64_t a, const struct rte_reciprocal_u64 *R)  
> > 
> > Why not doing the same change for rte_reciprocal_divide()?
> It doesn't make sense for rte_reciprocal_divide since rte_reciprocal_divide
> is call by value (ie doesn't take a pointer).

Oh, you're right.

> > Should we advertise such API change?
> 
> No. Since constant is always less intrusive than previous version
> all cases will work the same.

Yes OK
Thomas Monjalon April 3, 2019, 4:17 p.m. | #5
22/03/2019 19:09, Maxime Coquelin:
> On 3/21/19 8:59 PM, Stephen Hemminger wrote:
> > The divisor is not modified here. Doesn't really matter for optimizaton
> > since the function is inline already; but helps with expressing
> > intent.
> > 
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> 
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Applied, thanks

Patch

diff --git a/lib/librte_eal/common/include/rte_reciprocal.h b/lib/librte_eal/common/include/rte_reciprocal.h
index 3492c73bafea..63e16fde0aa8 100644
--- a/lib/librte_eal/common/include/rte_reciprocal.h
+++ b/lib/librte_eal/common/include/rte_reciprocal.h
@@ -77,7 +77,7 @@  mullhi_u64(uint64_t x, uint64_t y)
 }
 
 static __rte_always_inline uint64_t
-rte_reciprocal_divide_u64(uint64_t a, struct rte_reciprocal_u64 *R)
+rte_reciprocal_divide_u64(uint64_t a, const struct rte_reciprocal_u64 *R)
 {
 	uint64_t t = mullhi_u64(a, R->m);