Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1397339pxf; Fri, 12 Mar 2021 08:35:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzaEqsugc6BlzTXF1/ZmjQJUb9AZhfD2u7v+t4RD9bEoHuOcB2NIYYo4LuQM6aoLy/pr1io X-Received: by 2002:a05:6402:1649:: with SMTP id s9mr15143968edx.177.1615566956594; Fri, 12 Mar 2021 08:35:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615566956; cv=none; d=google.com; s=arc-20160816; b=GaI8syAVbRPuQ1JG2K+JjlC+4vh7otvLXCHID4WbH2FnaCuNKxLDsLPT+0MLglZj+E k0/dagCNtQDj3Osnvmd4QjjPCYJxNrXy+Hwl4ov17vbkt0URJJ44Mq1b3jPC+b1QPx1o tPjjH+JoO+/+2G7FRzcdPCZDdb3skJRhn62xRTa3e/jdmiEOPWuJ3zpGDPPi47vW2P6p CGFo43Sv/tbvYvP/lTGJsV5Qjt5bUA5Rqh7VSFJkHJvkksbbwfDT1YhLPwm2X1KAeHvA vL4fXzVTNnReoDf+0mxAuX9AVJafJmxaxfeciqsjdQS8L7mqoI59hVL+Yh5C7wSQpsn4 pq9w== 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=xd1OpSyULBAJCoaVVVrUuAIYtmhkhP65BjNqmabUSts=; b=HD0WTHgP+TKXdhUDJCzwoTuEoyLFTnLgyj4AA30UOH0mVXicPHzTP5+kGWiiM7prWz ctP6Ubft1abGmU5aXfcZ0OVDX5aH1fILAEaxmu3bRrpqe1BSCzcVLrVwLdpP+OHxRqr+ CvxMxONVJbiwHQ3eQnu10OI2l2wMgy/Qghg9BG72ZrQjHsAQ6/JVrg8uHVWUmwVMiERR c9XUey6phXkphRDaHVAYc1aXxyHwpHoJIGyRKcTW4dvgsSV+s5wxUxYcnxQT0AKUnmAG puIVGNEPjyA2cFnNiMo6iKiTZb1f/MiTFEosveIpe3jDzYYOXQUqMQJaeZbQT+AurwKZ apvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tbXRuUKT; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gz11si4526791ejc.745.2021.03.12.08.35.33; Fri, 12 Mar 2021 08:35:56 -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=@google.com header.s=20161025 header.b=tbXRuUKT; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232043AbhCLQeg (ORCPT + 99 others); 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-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.