From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30AC9C43332 for ; Fri, 12 Mar 2021 16:22:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F044D6501C for ; Fri, 12 Mar 2021 16:22:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232554AbhCLQWZ (ORCPT ); Fri, 12 Mar 2021 11:22:25 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:44311 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232130AbhCLQWS (ORCPT ); Fri, 12 Mar 2021 11:22:18 -0500 Date: Fri, 12 Mar 2021 16:22:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1615566136; bh=YmdVo4a5muajAW7ky6oQdDWmCsEr3lutZLcm8CzAK8g=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=Gxn0eCPzV4PGe17edQnPQpPylHh4XzMaGCPbxHxHjyfMIXAd3m7xStNFdThQ00ElP GjM50m5sXUXL4og8AOZ1rRcmmL1DRYJtgsSJndp4PwsXELfkguazt35Wh1mI1o98Ss BUpVrINRoxlZMa5aiSgZ3AX4vg25oQOxhMvcmnmK6DT2dGiXE9Y6yuiZWZ3lmKBXRj gKtpSjs9wCLhaOCwxKpT/MEpT+3m8iIhO/TBjMHxZ09YHItZJHDrqXNPuiZJ8/SCCr M/lTU/X0acg0yNutXVhGSMcXHse204uy6r3K+9wrASXIFtdb2GsvczGT2I59rfOnik 1ScsMIEqnRjVA== To: "David S. Miller" , Jakub Kicinski From: Alexander Lobakin Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Alexander Lobakin , Eric Dumazet , Wei Wang , Cong Wang , Taehee Yoo , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH net-next 4/4] gro: improve flow distribution across GRO buckets in dev_gro_receive() Message-ID: <20210312162127.239795-5-alobakin@pm.me> In-Reply-To: <20210312162127.239795-1-alobakin@pm.me> References: <20210312162127.239795-1-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Most of the functions that "convert" hash value into an index (when RPS is configured / XPS is not configured / etc.) set reciprocal_scale() on it. Its logics is simple, but fair enough and accounts the entire input value. On the opposite side, 'hash & (GRO_HASH_BUCKETS - 1)' expression uses only 3 least significant bits of the value, which is far from optimal (especially for XOR RSS hashers, where the hashes of two different flows may differ only by 1 bit somewhere in the middle). Use reciprocal_scale() here too to take the entire hash value into account and improve flow dispersion between GRO hash buckets. Signed-off-by: Alexander Lobakin --- net/core/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/dev.c b/net/core/dev.c index 65d9e7d9d1e8..bd7c9ba54623 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5952,7 +5952,7 @@ static void gro_flush_oldest(struct napi_struct *napi= , struct list_head *head) static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk= _buff *skb) { -=09u32 bucket =3D skb_get_hash_raw(skb) & (GRO_HASH_BUCKETS - 1); +=09u32 bucket =3D reciprocal_scale(skb_get_hash_raw(skb), GRO_HASH_BUCKETS= ); =09struct gro_list *gro_list =3D &napi->gro_hash[bucket]; =09struct list_head *gro_head =3D &gro_list->list; =09struct list_head *head =3D &offload_base; -- 2.30.2