From patchwork Fri Mar 12 16:22:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 12135225 X-Patchwork-Delegate: kuba@kernel.org 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=ham 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 A9CD8C433E9 for ; Fri, 12 Mar 2021 16:22:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C10E65027 for ; Fri, 12 Mar 2021 16:22:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232529AbhCLQWX (ORCPT ); Fri, 12 Mar 2021 11:22:23 -0500 Received: from mail1.protonmail.ch ([185.70.40.18]:44310 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232301AbhCLQWS (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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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(-) -- 2.30.2 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) { - u32 bucket = skb_get_hash_raw(skb) & (GRO_HASH_BUCKETS - 1); + u32 bucket = reciprocal_scale(skb_get_hash_raw(skb), GRO_HASH_BUCKETS); struct gro_list *gro_list = &napi->gro_hash[bucket]; struct list_head *gro_head = &gro_list->list; struct list_head *head = &offload_base;