lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 2 Nov 2022 11:25:54 -0700
From:   Eric Dumazet <edumazet@...gle.com>
To:     Richard Gobert <richardbgobert@...il.com>
Cc:     Jakub Kicinski <kuba@...nel.org>, davem@...emloft.net,
        pabeni@...hat.com, lixiaoyan@...gle.com, alexanderduyck@...com,
        steffen.klassert@...unet.com, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] gro: avoid checking for a failed search

On Wed, Nov 2, 2022 at 11:20 AM Eric Dumazet <edumazet@...gle.com> wrote:
>
> On Wed, Nov 2, 2022 at 9:46 AM Richard Gobert <richardbgobert@...il.com> wrote:
> >
> > > Why does it matter? You see a measurable perf win?
> >
> > In the common case, we will exit the loop with a break,
> > so this patch eliminates an unnecessary check.
> >
> > On some architectures this optimization might be done
> > automatically by the compiler, but I think it will be better
> > to make it explicit here. Although on x86 this optimization
> > happens automatically, I noticed that on my build target
> > (ARM/GCC) this does change the binary.
>
> What about taking this as an opportunity to reduce the indentation
> level by one tab ?
>
> Untested patch:
>
> diff --git a/net/core/gro.c b/net/core/gro.c
> index bc9451743307bc380cca96ae6995aa0a3b83d185..ddfe92c9a5e869d241931b72d6b3426a0e858468
> 100644
> --- a/net/core/gro.c
> +++ b/net/core/gro.c
> @@ -491,43 +491,44 @@ static enum gro_result dev_gro_receive(struct
> napi_struct *napi, struct sk_buff
>         list_for_each_entry_rcu(ptype, head, list) {
>                 if (ptype->type != type || !ptype->callbacks.gro_receive)
>                         continue;
> +               goto found_ptype;
> +       }
> +       rcu_read_unlock();
> +       goto normal;


Or even better:

        list_for_each_entry_rcu(ptype, head, list) {
               if (ptype->type == type && ptype->callbacks.gro_receive)
                       goto found_ptype;
       }
       rcu_read_unlock();
       goto normal;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ