Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp252320rwi; Wed, 2 Nov 2022 11:29:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5H3wHCRoXLN8gQjFDVrfrp/sgEh2VoiH4KxtltCJRjTytZ14G54ajVui2vjCFyBBNeeabR X-Received: by 2002:a05:6402:33c4:b0:448:e63e:4f40 with SMTP id a4-20020a05640233c400b00448e63e4f40mr26120098edc.203.1667413772478; Wed, 02 Nov 2022 11:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667413772; cv=none; d=google.com; s=arc-20160816; b=pDPV6UQe+c+4sgdsVkuVOOcJ3+qIv05Hr1uWjh747dH5rGSf257F4zTrhCyaVbPrmr aVP6HJdu4d9bq5xOWD6lW+c+3Gd7WKrfJaTHgkYO5E/dbZrr2+StD+uNxnQTv/kG6IU2 CItgqT/oXk1YOM9RWCEhB4bbEMa3YYRbudM7kcxLpba0nxF0LwYDK6zBrXrt8ZlBn+zH /MQMP8G4W9aeEPnf1mFNtU2DV87YrkZSvd1VY1wqZBW2m2Zzt58/aYKcuj4wx2PKsfa7 EPIqvL6iO5NdjEGfpQ16UZE43vI0/i5kwImvObpoqZuMN97TuQeir7DUI8rBIHszyjnc z0Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ULxNV0Y7ObC/UK3IdOnSD/Vynj/215SLWO43fDO8Lz8=; b=RbgHjasTKVFfk36apLO/gl9IpMyXtCYObeGnNDZLecS4sRhmCwlPhKfK4sSizgvipi qI0d8HeCK3dJS2pOxTOsy1Js0sidHf/+uUyh+XA+q60YmIijPaepvIczMCw0Hnt4qce5 LCOlHnQfZgOuMDMKqUIM+o57xfbuoj/2b9a5/iaj/2BBGIyvOl/EgzZlD8pahpfgNK8n M83/stUHuNi/ODgVoi14yYqXb6yx/EuJBRQn6T5KJWeXPvF4XKRq01gnZz47dc19W/m7 MERVlna9IWgYkkXfkrl4Mna+XHID7o9u0Z2xNJKi8G+9im2zqGri43VY1MOUszTcgb7o d6fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TAWW3m8U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020a1709066d8e00b007aa35038c6bsi13079821ejt.463.2022.11.02.11.29.08; Wed, 02 Nov 2022 11:29:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TAWW3m8U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230261AbiKBS0P (ORCPT + 98 others); Wed, 2 Nov 2022 14:26:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231196AbiKBS0I (ORCPT ); Wed, 2 Nov 2022 14:26:08 -0400 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2F6921834 for ; Wed, 2 Nov 2022 11:26:06 -0700 (PDT) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-3701a0681daso139663217b3.4 for ; Wed, 02 Nov 2022 11:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ULxNV0Y7ObC/UK3IdOnSD/Vynj/215SLWO43fDO8Lz8=; b=TAWW3m8UL5LDFG8C5gf7E3dMuHygxgu6yswn9PmrqsByIQCZ0c30noNS+qq6tWhn1B Z0g3s4wyuwoWgQ/SfCSK9KWahrIm58SDkKbPOjM/KJzKSnxwk9yw2fyfT6hB264wI1TH /aneHQVowmTlQPO4/kfq+HbuB73l8yxkcEZEbKb9sa42tv7EkRZlwc+UjqwbvEhoAlXl a9+m0pkRgC5CHjT7iljQ8DGTMySEZmn1frCJLkAO+NsjrZZeAaWx2z/WAWW8rDDsWnF5 n0YBGD834JmcA2b2ZTNW9x84QF3HrHM2VcVbWy/mD5xjXK+iHjk5wSHgiBG9PE1SnC90 UDvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ULxNV0Y7ObC/UK3IdOnSD/Vynj/215SLWO43fDO8Lz8=; b=QYiDnIsIvCDgidNcEpjGD9Uvla+sUEUkn28YfoT0COaUEbmhdvrRbQG+cRjVy9tr2U mT8t9ITcDeN/zY87GTNpybZpHI38DWAUYfMFm1UGtIQXAi6DX+QpwT+Qp4C/Cy6WqVoN bSxstW/MBqx9GXm68uo99i9KBMfwPAypEYZfDnS7qXenYUBocE7k4jp3FqvZ9r1+v8U6 BRKJWmYVoSV3nRCT0LU8zrpRVIFA0DhKJA1/00cPnoTS0tHv5lRacmplMeZYqLppoPu7 XVQPrb4bAuF4T3hPoukw+4NneGNUTbHoIqq1LEfJorHuOMt1rWhSLGEIbnL72o563Srq 3eaQ== X-Gm-Message-State: ACrzQf1kw0xrDpWRUYIS63A+b+MJ8152UunwhLiw7Q4bW1c/mqhuZV7B s/L4/ltCS6gsayRelFXcXPGRzf9eocZJpZwj1rIbKWbb8JVg1A== X-Received: by 2002:a81:c11:0:b0:36a:bcf0:6340 with SMTP id 17-20020a810c11000000b0036abcf06340mr24170753ywm.467.1667413565888; Wed, 02 Nov 2022 11:26:05 -0700 (PDT) MIME-Version: 1.0 References: <20221024051744.GA48642@debian> <20221101085153.12ccae1c@kernel.org> In-Reply-To: From: Eric Dumazet Date: Wed, 2 Nov 2022 11:25:54 -0700 Message-ID: Subject: Re: [PATCH net-next] gro: avoid checking for a failed search To: Richard Gobert Cc: Jakub Kicinski , davem@davemloft.net, pabeni@redhat.com, lixiaoyan@google.com, alexanderduyck@fb.com, steffen.klassert@secunet.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 2, 2022 at 11:20 AM Eric Dumazet wrote: > > On Wed, Nov 2, 2022 at 9:46 AM Richard Gobert 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;