Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1483360pxf; Fri, 12 Mar 2021 10:30:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxiQU80zjFu1lJ7c4vpUGGG9iN2x5YwioHiqvvy1iguoB0SCXMHpAhMEiri6nSN8uJuxPLg X-Received: by 2002:a17:906:c405:: with SMTP id u5mr10075718ejz.341.1615573805587; Fri, 12 Mar 2021 10:30:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615573805; cv=none; d=google.com; s=arc-20160816; b=0a4oWabOnIwz4rUUoDGn+QW4bzz0qYch2cvZ/hMxxTUYnSRJe09UZ0EIX2vIMPR1Ut 1nRg5EZohwLeSYUyejTf0cv6XC0u3dghHLM72qHqp78/m25AUUTQxW3Fsph3it7sFRTO 5TxcPbd3q0iRBRlJ+vpokws6RiokOkmroz7zqdDOvTx/VEeIg3HUlTAdBZD98t3A7qWD BVRlUS/n6Y/xlAZezV1dOlFSZeIO9bunvHZe2aMYPq+WbcFa6mZbqcmhunSIBhAF+oZ1 Fpz+HJ61k4jJdqTaICuflHcytH7AgElLeC9QibUAtve1a/Py94Wlc9jaF/crdnLjTbjo r2Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=L0uazoUIkN0zjdIavDun3gMD7KLrxkBn0hh1tsNwdYA=; b=nc7lvpXrLamJPWzEXtPBPslkpN1KKJNO9U2fRu8ZV6UvMGXbWO2cp2lje/Pia8GEkW sBLvT3iJXz+mVwKyHYfEQCEVyDr3jxGI/aAgQHYuH6e5iieF7YaO7ZavoR2WtwCV1uhg spFKm78gsbvW7txcPdxc1LVbDNJcBPIEwqixZ3tQbceJK6MzgWBgM63hWPhJn16LXtKd fw1gG49nd6PKs/3GO/YAa2PWEKGU10Fjy7xP+exoUcmtp6yWUmzxz/30BxrYo32gg60E 20gez8sJiYcW6v8KpZxvLPDhQ5Ui7wNbqdeH5tI1tRpwPazSc3VmgaFD86CFMe+a4/vM oQ9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=nJrLBQ7Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c10si4494325edv.12.2021.03.12.10.29.43; Fri, 12 Mar 2021 10:30:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=nJrLBQ7Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233446AbhCLS2l (ORCPT + 99 others); Fri, 12 Mar 2021 13:28:41 -0500 Received: from mail-40134.protonmail.ch ([185.70.40.134]:20732 "EHLO mail-40134.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233205AbhCLS2W (ORCPT ); Fri, 12 Mar 2021 13:28:22 -0500 Date: Fri, 12 Mar 2021 18:28:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1615573700; bh=L0uazoUIkN0zjdIavDun3gMD7KLrxkBn0hh1tsNwdYA=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=nJrLBQ7QGtRHzE4HZ5TSZc7Iemy7dzVq8QJGuIEOco91HRWWipj82pCJeYaF1PTps kyr0+E0pBF+rH7GwUwVn6o9k/MKF/7g4YXni56+7Kw3uohsUD3tA0I1bPr47KT9q5v w/qMenB5m40w+KcGbqDiCaknD5JHTpTpLiNkPJsFpvoMEhrznz15eNVJxXktIyTaew hepGGaYI4w6w3lFIwzbl5DrhhqsrY2Sbs6D//JuMGNkhax93/0QYVOJg6OrO0I8bGA NyLhmbHZnnLiISbJtKI1M0Asn5rAV5a7b86qfjYngFIZSCuUtbC7J2GsJ9M3FZEtzz FYYwPjXgqOp2w== To: Eric Dumazet From: Alexander Lobakin Cc: Alexander Lobakin , "David S. Miller" , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Wei Wang , Cong Wang , Taehee Yoo , netdev , LKML Reply-To: Alexander Lobakin Subject: Re: [PATCH net-next 4/4] gro: improve flow distribution across GRO buckets in dev_gro_receive() Message-ID: <20210312182754.241807-1-alobakin@pm.me> In-Reply-To: References: <20210312162127.239795-1-alobakin@pm.me> <20210312162127.239795-5-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet Date: Fri, 12 Mar 2021 17:33:53 +0100 > 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, struc= t sk_buff *skb) > > { > > - u32 bucket =3D skb_get_hash_raw(skb) & (GRO_HASH_BUCKETS - 1); > > + u32 bucket =3D 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. We-e-ell, seems like it. > Now, had you use hash_32(skb_get_hash_raw(skb), 3), you could have > claimed to use "more bits" Nice suggestion, I'll try. If there won't be any visible improvements, I'll just drop this one. > Toeplitz already shuffles stuff. As well as CRC and others, but I feel like we shouldn't rely only on the hardware. > Adding a multiply here seems not needed. > > Please provide experimental results, because this looks unnecessary to me= . Thanks, Al