linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: ipv4: route.c: add likely() statements
@ 2021-03-24  3:09 Yejune Deng
  2021-03-24 10:34 ` Leon Romanovsky
  0 siblings, 1 reply; 4+ messages in thread
From: Yejune Deng @ 2021-03-24  3:09 UTC (permalink / raw)
  To: davem, yoshfuji, dsahern, kuba; +Cc: netdev, linux-kernel, yejune, Yejune Deng

Add likely() statements in ipv4_confirm_neigh() for 'rt->rt_gw_family
== AF_INET'.

Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
---
 net/ipv4/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index fa68c2612252..5762d9bc671c 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -440,7 +440,7 @@ static void ipv4_confirm_neigh(const struct dst_entry *dst, const void *daddr)
 	struct net_device *dev = dst->dev;
 	const __be32 *pkey = daddr;
 
-	if (rt->rt_gw_family == AF_INET) {
+	if (likely(rt->rt_gw_family == AF_INET)) {
 		pkey = (const __be32 *)&rt->rt_gw4;
 	} else if (rt->rt_gw_family == AF_INET6) {
 		return __ipv6_confirm_neigh_stub(dev, &rt->rt_gw6);
-- 
2.29.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net: ipv4: route.c: add likely() statements
  2021-03-24  3:09 [PATCH 1/2] net: ipv4: route.c: add likely() statements Yejune Deng
@ 2021-03-24 10:34 ` Leon Romanovsky
  2021-03-24 11:01   ` Yejune Deng
  0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2021-03-24 10:34 UTC (permalink / raw)
  To: Yejune Deng; +Cc: davem, yoshfuji, dsahern, kuba, netdev, linux-kernel, yejune

On Wed, Mar 24, 2021 at 11:09:22AM +0800, Yejune Deng wrote:
> Add likely() statements in ipv4_confirm_neigh() for 'rt->rt_gw_family
> == AF_INET'.

Why? Such macros are beneficial in only specific cases, most of the time,
likely/unlikely is cargo cult.

> 
> Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
> ---
>  net/ipv4/route.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index fa68c2612252..5762d9bc671c 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -440,7 +440,7 @@ static void ipv4_confirm_neigh(const struct dst_entry *dst, const void *daddr)
>  	struct net_device *dev = dst->dev;
>  	const __be32 *pkey = daddr;
>  
> -	if (rt->rt_gw_family == AF_INET) {
> +	if (likely(rt->rt_gw_family == AF_INET)) {
>  		pkey = (const __be32 *)&rt->rt_gw4;
>  	} else if (rt->rt_gw_family == AF_INET6) {
>  		return __ipv6_confirm_neigh_stub(dev, &rt->rt_gw6);
> -- 
> 2.29.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net: ipv4: route.c: add likely() statements
  2021-03-24 10:34 ` Leon Romanovsky
@ 2021-03-24 11:01   ` Yejune Deng
  2021-03-24 12:19     ` Leon Romanovsky
  0 siblings, 1 reply; 4+ messages in thread
From: Yejune Deng @ 2021-03-24 11:01 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: David Miller, yoshfuji, dsahern, Jakub Kicinski, netdev,
	Linux Kernel Mailing List, yejune

My reasons are as following: ipv4_confirm_neigh() belongs to
ipv4_dst_ops that family is AF_INET, and ipv4_neigh_lookup() is also
added likely() when rt->rt_gw_family is equal to AF_INET.

On Wed, Mar 24, 2021 at 6:34 PM Leon Romanovsky <leon@kernel.org> wrote:
>
> On Wed, Mar 24, 2021 at 11:09:22AM +0800, Yejune Deng wrote:
> > Add likely() statements in ipv4_confirm_neigh() for 'rt->rt_gw_family
> > == AF_INET'.
>
> Why? Such macros are beneficial in only specific cases, most of the time,
> likely/unlikely is cargo cult.
>
> >
> > Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
> > ---
> >  net/ipv4/route.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> > index fa68c2612252..5762d9bc671c 100644
> > --- a/net/ipv4/route.c
> > +++ b/net/ipv4/route.c
> > @@ -440,7 +440,7 @@ static void ipv4_confirm_neigh(const struct dst_entry *dst, const void *daddr)
> >       struct net_device *dev = dst->dev;
> >       const __be32 *pkey = daddr;
> >
> > -     if (rt->rt_gw_family == AF_INET) {
> > +     if (likely(rt->rt_gw_family == AF_INET)) {
> >               pkey = (const __be32 *)&rt->rt_gw4;
> >       } else if (rt->rt_gw_family == AF_INET6) {
> >               return __ipv6_confirm_neigh_stub(dev, &rt->rt_gw6);
> > --
> > 2.29.0
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net: ipv4: route.c: add likely() statements
  2021-03-24 11:01   ` Yejune Deng
@ 2021-03-24 12:19     ` Leon Romanovsky
  0 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2021-03-24 12:19 UTC (permalink / raw)
  To: Yejune Deng
  Cc: David Miller, yoshfuji, dsahern, Jakub Kicinski, netdev,
	Linux Kernel Mailing List, yejune

On Wed, Mar 24, 2021 at 07:01:19PM +0800, Yejune Deng wrote:
> My reasons are as following: ipv4_confirm_neigh() belongs to
> ipv4_dst_ops that family is AF_INET, and ipv4_neigh_lookup() is also
> added likely() when rt->rt_gw_family is equal to AF_INET.

It is part of that cargo cult. Please support your claim with
performance numbers when this likely/unlikely will give any difference.

Thanks

> 
> On Wed, Mar 24, 2021 at 6:34 PM Leon Romanovsky <leon@kernel.org> wrote:
> >
> > On Wed, Mar 24, 2021 at 11:09:22AM +0800, Yejune Deng wrote:
> > > Add likely() statements in ipv4_confirm_neigh() for 'rt->rt_gw_family
> > > == AF_INET'.
> >
> > Why? Such macros are beneficial in only specific cases, most of the time,
> > likely/unlikely is cargo cult.
> >
> > >
> > > Signed-off-by: Yejune Deng <yejune.deng@gmail.com>
> > > ---
> > >  net/ipv4/route.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> > > index fa68c2612252..5762d9bc671c 100644
> > > --- a/net/ipv4/route.c
> > > +++ b/net/ipv4/route.c
> > > @@ -440,7 +440,7 @@ static void ipv4_confirm_neigh(const struct dst_entry *dst, const void *daddr)
> > >       struct net_device *dev = dst->dev;
> > >       const __be32 *pkey = daddr;
> > >
> > > -     if (rt->rt_gw_family == AF_INET) {
> > > +     if (likely(rt->rt_gw_family == AF_INET)) {
> > >               pkey = (const __be32 *)&rt->rt_gw4;
> > >       } else if (rt->rt_gw_family == AF_INET6) {
> > >               return __ipv6_confirm_neigh_stub(dev, &rt->rt_gw6);
> > > --
> > > 2.29.0
> > >

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-24 12:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24  3:09 [PATCH 1/2] net: ipv4: route.c: add likely() statements Yejune Deng
2021-03-24 10:34 ` Leon Romanovsky
2021-03-24 11:01   ` Yejune Deng
2021-03-24 12:19     ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).