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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, 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,USER_IN_DEF_DKIM_WL 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 88744C433E0 for ; Fri, 12 Mar 2021 16:35:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61BBB64FE2 for ; Fri, 12 Mar 2021 16:35:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229959AbhCLQeg (ORCPT ); Fri, 12 Mar 2021 11:34:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230302AbhCLQeG (ORCPT ); Fri, 12 Mar 2021 11:34:06 -0500 Received: from mail-yb1-xb32.google.com (mail-yb1-xb32.google.com [IPv6:2607:f8b0:4864:20::b32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41885C061761 for ; Fri, 12 Mar 2021 08:34:06 -0800 (PST) Received: by mail-yb1-xb32.google.com with SMTP id l8so25949780ybe.12 for ; Fri, 12 Mar 2021 08:34:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xd1OpSyULBAJCoaVVVrUuAIYtmhkhP65BjNqmabUSts=; b=tbXRuUKTAJ5OAzLt4K/pJhrwxAyj+0prXM6A/hLCmCMfOhznh8CB2cMbHU4IgyVxW5 Im21oExo+0EMEbC1VIEOvaPHRbzZFruXZG8nlj4Tt0atYQ+i6rCMf8Sc1UetIG0kNtca sA6HIkx89UhP/NR7A8HDOO9I2rtiH5F5Ej+PRtgcL/gyhMeWSEYGjDsbV9Rf1ttIMRgt 2nYv+umR2yKe+MvCQOWDNXYAuQm1O4y61WtiTBvisiV+ldsE+sA1dzI9Ck7X7JKed6ei x/HX5w7QqT+ZhF3g13nEw7CMcayY8A1UDh2YtoTSl+3Sj+MEAiprFeCVGeD0XhqbPnxB +ISA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xd1OpSyULBAJCoaVVVrUuAIYtmhkhP65BjNqmabUSts=; b=qwQwojqZMAO5fCZ3Mwt2+5dRglV5ZOZAPMsL/MCkCoTJWUPkhvmY/EnxsmY3uxOYOb 2OtC3jSnUBT/5HM7nSBCpBxjVd2rgnsupg3K7cnZAoYJIj+Fmql+grTOWZRZuv4M8LNO 8aNoJDTfnzlshkQeCOKgGaY5oliGyne1lgTZjRq8qIFuXcudqJtvq7AKfbshA8p0ynNY Ss0q6CJchPtMJxvlbRdA1S70cqmnnkB0nRwEtXWtxl7n0dibdWa/G2akUtru2qAdLyvU nGEJA6gjr5DGacbmWI5oa+VjeQKOdowiO0JZEukx9+9FkAl7/HAb99zJhONw3ls6pF5d mpZw== X-Gm-Message-State: AOAM533B5BmOYV+grLTxOmA62dFOPlvPL1UEt4wSmRwH2idjrO/4ZDug Zlj4fY27q6Rd1SLdmYHLbVbmwGZB55fzTvM0VYcUFA== X-Google-Smtp-Source: ABdhPJxTNip7fRhXXacvymw5GDHidct5oiKxuvIuYl2k74buQ2MPzFqhAIv6SB81Zi9YTWU8TyTZ7l+/yTWNknU9dnM= X-Received: by 2002:a5b:78f:: with SMTP id b15mr20254754ybq.234.1615566845126; Fri, 12 Mar 2021 08:34:05 -0800 (PST) MIME-Version: 1.0 References: <20210312162127.239795-1-alobakin@pm.me> <20210312162127.239795-5-alobakin@pm.me> In-Reply-To: <20210312162127.239795-5-alobakin@pm.me> From: Eric Dumazet Date: Fri, 12 Mar 2021 17:33:53 +0100 Message-ID: Subject: Re: [PATCH net-next 4/4] gro: improve flow distribution across GRO buckets in dev_gro_receive() To: Alexander Lobakin Cc: "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Wei Wang , Cong Wang , Taehee Yoo , netdev , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 12, 2021 at 5:22 PM Alexander Lobakin wrote: > > 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) > { > - u32 bucket = skb_get_hash_raw(skb) & (GRO_HASH_BUCKETS - 1); > + u32 bucket = reciprocal_scale(skb_get_hash_raw(skb), GRO_HASH_BUCKETS); This is going to use 3 high order bits instead of 3 low-order bits. Now, had you use hash_32(skb_get_hash_raw(skb), 3), you could have claimed to use "more bits" Toeplitz already shuffles stuff. Adding a multiply here seems not needed. Please provide experimental results, because this looks unnecessary to me.