Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1389179pxf; Fri, 12 Mar 2021 08:25:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyfD+yluGJKIBWqABhcDMEpWE8gtnv4+FFLHCgrKddo8pcgv57GV2RHdBAN4SLYP5inS8iM X-Received: by 2002:a17:906:bc81:: with SMTP id lv1mr9431208ejb.135.1615566344517; Fri, 12 Mar 2021 08:25:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615566344; cv=none; d=google.com; s=arc-20160816; b=J1STcl0xMS6P8NCbDvqNrvV9PJPzzInkQFQEDkDkDGdZGwQ1UGPRme61Pii1kygl9t AdHpYFRcvPLEjhUTnt1mTBs9CWj0Go9BC5R2Ld60Nr4BvOiVQKV5+lDwDaVLvxz/F8k+ HGLxyPzMxzMKkGpXjfOWjWDgYDXNvxtRp/s+JsRiPQbTFULa9ezEf/BsgvX9m5UmB9hS fJ6JqWyiglU7NLLwSryVoAK3yevV7Eg/DuqpKhyK+wsLtOuKD4a7HmEsfEhoof/mdfA4 ijwApTqt8iY01jnk85wCrxpyqT1vWg8euvziXiHZrjFt2Me2L5wiZqYxF8j8g2UlUR2o 9d8A== 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=YmdVo4a5muajAW7ky6oQdDWmCsEr3lutZLcm8CzAK8g=; b=mBHa7zbLhFvAhkwpoU4LPXeeVgxWVN07ox1qOJRQFhxWYQS+J9nwNYMRxke/FJdeYh TjjS8Hr6DCDbhNQgX5LPBuuNQBjsatvHgegLxbMDbE9viVVI8waVQob+VgRZ32RRiy5d 1/mPnNfQIsi380sMzO0kjbDUHs50oRx8SAhVGBU4TM7UVmP5HSBigi+6DGifHFWXM4IN W2nRDvV69Pu/xrWhGH/D9AMQAPd37S7InTsBkm8iVCR3u2wBrEjz0/rxeizCDL1gxU4h TiRGDmSkMnbPG0z/tqSUJaxhWnRhXdMUhHJ2dAf+uE6oiZJpC99C5SRgJalUdFyB8uUI 3NIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=Gxn0eCPz; 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 k13si4314102ejc.452.2021.03.12.08.25.22; Fri, 12 Mar 2021 08:25:44 -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=Gxn0eCPz; 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 S232549AbhCLQWY (ORCPT + 99 others); Fri, 12 Mar 2021 11:22:24 -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 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 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