lkml.org 
[lkml]   [2022]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH net-next] gro: avoid checking for a failed search
On Wed, Nov 2, 2022 at 11:20 AM Eric Dumazet <edumazet@google.com> wrote:
>
> On Wed, Nov 2, 2022 at 9:46 AM Richard Gobert <richardbgobert@gmail.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;

\
 
 \ /
  Last update: 2022-11-02 19:26    [W:0.045 / U:0.792 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site