Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp504990rdb; Tue, 5 Dec 2023 11:10:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IElzkiU2fRaPbDTcpWF/c+zexGFAk1J+qolnjRivAkzUL+vHnmdCxXTMpZF4zkVfIpBRSXK X-Received: by 2002:a05:6a20:7f9c:b0:18f:5f6f:fc69 with SMTP id d28-20020a056a207f9c00b0018f5f6ffc69mr3069439pzj.97.1701803418998; Tue, 05 Dec 2023 11:10:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701803418; cv=none; d=google.com; s=arc-20160816; b=mEsvQvKSdYCWZ6IaGTBZEkcXeNhcCny5s0H6DdJUQInbgRwHIQColcgKVu3HBwje25 f5s/lJEvzSEQyI8fC7DVdPv3xi57zrCjbXixSTTUOMvK1k7u4WOAfvjASJ0Xnt/aeIJs 0szOX4XoZoQcnmFaMUkK2ilSUjygfHD+XBW7xBRCR2MaoyAgtqHzVCHbgvzyiC1CEDcE UXI/eySFVn0nXIPDDcbYq8vSvW9tb/xfQZpBSWMbp823lsuXEs+ltzG4DhHjQrv75Of5 O2FqCD12GEy3ETNQCsRpWown96N1zP2MQIl7CqdW2mPhxgmEdwVv5sTSRZnBgF8rUB1t upqg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=LPvsreD7SHt4olmNelnu/glf+fhgjLiYFThCak4nyVI=; fh=/AeaX1VbQ96MWp/bESs4TN+NFBPc05De6zbZtSMgJQo=; b=I20KnQzox4rhSbCX+W64SBOPwsTU5Rvvos09FQ1IA8DS83rswPo71vHMtnNUc38E3T 52DqqrAWxRJ4KF7oabuhAS29P2jPmnWurRKfoBtOncXzzKbl4Py8I8CflzqELxNoEvUe Je74Sce3tZ9r3+uUv2cMP/861L4+30/jZEnECzci73yZh0xEz1TuxD9EXMVuTqYWfq/o OTO1+WG1drO/ufNhHQnDWGSdNkU3UU1jGlCAVubnDid4nErCsMfzXQywU8k/INqYgzo+ YO1ypDuThbnh+SE84WQvnUrMT7QXfGnyQfiY/62thZI1wP6PNK//h/zK+lzltuBIBB1D pYFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Hhn7edko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id n30-20020a056a000d5e00b006ce44b51172si4509856pfv.351.2023.12.05.11.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 11:10:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Hhn7edko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D9B9380215B6; Tue, 5 Dec 2023 11:10:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231839AbjLETKB (ORCPT + 99 others); Tue, 5 Dec 2023 14:10:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbjLETJ7 (ORCPT ); Tue, 5 Dec 2023 14:09:59 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 881B3194; Tue, 5 Dec 2023 11:10:01 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6ce4d4c5ea2so2095548b3a.0; Tue, 05 Dec 2023 11:10:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701803401; x=1702408201; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LPvsreD7SHt4olmNelnu/glf+fhgjLiYFThCak4nyVI=; b=Hhn7edkoFmTEiS3+su/j/RRiFeVA9otf8tmzu6jhc75nIjt/f4/yDJtvIr1uDpjQmD QDxDynTskK5OLmTTQqxKSj6HwUlZx8AK8mMvMgPXEBUKpcoGwTXKE9UfZDw7BWlNyR9H qITgRwSJQKZlUpRaP567Wtq7pBrVO2ERNT+Lu3JUQb03+tU8+4qA10d4J6PdMUAEaAGJ E+pRrJNTJKsapNyH+skD5fRK7l0nwdiF+bV9hh/rC6rY82eEWbCZF4I7uqz/HB2kUk9r 296unvcjwWGAhvpG5W2JnDWo0U46iPXcxOe8aZ7wB8SG7IulbGNAB49T52CVLnsx/uF6 zW9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701803401; x=1702408201; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LPvsreD7SHt4olmNelnu/glf+fhgjLiYFThCak4nyVI=; b=xPA6i2dTsrVGOYPrUqZoin5K26HS2RzzqxgF4zspfzY2+q+sVdjmKP9b7iYbcD7Zsq SNOUlclGkcUXhEJUMgs9zNDRP308euLwDHvSNnbZiwdfO7OpnmkXbSsHGKOWiLoGyJNZ zXpmHOU6Z91bRfUxuIftV4osshC4OvDm2A0SKFsng0RRWqQBrv/BBy5Y21k2CIq3u7y3 83oBPYjEF+yHyETgkXgvgGnSu/U+PvBwd/tkHKhdkon4/1r35LvLrgRq6RJ14/IHmJT6 I7Hp0UifN6H3f8XRlW9AYQsCSEFdcSFAwqIlA6Y9sI7YpG4JVrQ9I6YzhnWoeqLCi5Rn oRKQ== X-Gm-Message-State: AOJu0YzpTwxbqRcdZ5E4Fd8rxpKDTH0NUHwJj1NGMCqUvTDVSVn1p0nT HbfeVL1QNZLwjaHUeM/Ena4= X-Received: by 2002:a05:6a21:19d:b0:18c:570d:c5b4 with SMTP id le29-20020a056a21019d00b0018c570dc5b4mr26991876pzb.35.1701803400827; Tue, 05 Dec 2023 11:10:00 -0800 (PST) Received: from localhost.localdomain ([114.249.31.17]) by smtp.gmail.com with ESMTPSA id v18-20020a63f212000000b005ab281d0777sm9624568pgh.20.2023.12.05.11.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 11:10:00 -0800 (PST) From: YangXin To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: remove ___neigh_lookup_noref(). Date: Wed, 6 Dec 2023 03:09:51 +0800 Message-Id: <20231205190951.67-1-yx.0xffff@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 05 Dec 2023 11:10:16 -0800 (PST) key_eq() and hash() are functions of struct neigh_table, so we just need to call tbl->key_eq() and tbl->hash(), instead of passing them in as parameters. And if those two parameters were removed, ___neigh_lookup_noref() would be pointless, so I replaced ___neigh_lookup_noref() with __neigh_lookup_noref(). Signed-off-by: YangXin --- Last time I comitted this patch, Mr Dumazet said "this might defeat inlining.". So I compiled kernel on my computer with defconfig, made sure that this patch would not lead __neigh_lookup_noref() fail to inline. My enviroment: Debian12 gcc version: gcc (Debian 12.2.0-14) 12.2.0 include/net/arp.h | 2 +- include/net/ndisc.h | 5 ++--- include/net/neighbour.h | 22 +++++----------------- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/include/net/arp.h b/include/net/arp.h index e8747e0713c7..e274c7fc5020 100644 --- a/include/net/arp.h +++ b/include/net/arp.h @@ -24,7 +24,7 @@ static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev if (dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) key = INADDR_ANY; - return ___neigh_lookup_noref(&arp_tbl, neigh_key_eq32, arp_hashfn, &key, dev); + return __neigh_lookup_noref(&arp_tbl, &key, dev); } #else static inline diff --git a/include/net/ndisc.h b/include/net/ndisc.h index 9bbdf6eaa942..8e0ba9a87e4d 100644 --- a/include/net/ndisc.h +++ b/include/net/ndisc.h @@ -380,15 +380,14 @@ static inline u32 ndisc_hashfn(const void *pkey, const struct net_device *dev, _ static inline struct neighbour *__ipv6_neigh_lookup_noref(struct net_device *dev, const void *pkey) { - return ___neigh_lookup_noref(&nd_tbl, neigh_key_eq128, ndisc_hashfn, pkey, dev); + return __neigh_lookup_noref(&nd_tbl, pkey, dev); } static inline struct neighbour *__ipv6_neigh_lookup_noref_stub(struct net_device *dev, const void *pkey) { - return ___neigh_lookup_noref(ipv6_stub->nd_tbl, neigh_key_eq128, - ndisc_hashfn, pkey, dev); + return __neigh_lookup_noref(ipv6_stub->nd_tbl, pkey, dev); } static inline struct neighbour *__ipv6_neigh_lookup(struct net_device *dev, const void *pkey) diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 0d28172193fa..434c9e7c7ea7 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -290,37 +290,25 @@ static inline bool neigh_key_eq128(const struct neighbour *n, const void *pkey) (n32[2] ^ p32[2]) | (n32[3] ^ p32[3])) == 0; } -static inline struct neighbour *___neigh_lookup_noref( - struct neigh_table *tbl, - bool (*key_eq)(const struct neighbour *n, const void *pkey), - __u32 (*hash)(const void *pkey, - const struct net_device *dev, - __u32 *hash_rnd), - const void *pkey, - struct net_device *dev) +static inline struct neighbour *__neigh_lookup_noref(struct neigh_table *tbl, + const void *pkey, + struct net_device *dev) { struct neigh_hash_table *nht = rcu_dereference(tbl->nht); struct neighbour *n; u32 hash_val; - hash_val = hash(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift); + hash_val = tbl->hash(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift); for (n = rcu_dereference(nht->hash_buckets[hash_val]); n != NULL; n = rcu_dereference(n->next)) { - if (n->dev == dev && key_eq(n, pkey)) + if (n->dev == dev && tbl->key_eq(n, pkey)) return n; } return NULL; } -static inline struct neighbour *__neigh_lookup_noref(struct neigh_table *tbl, - const void *pkey, - struct net_device *dev) -{ - return ___neigh_lookup_noref(tbl, tbl->key_eq, tbl->hash, pkey, dev); -} - static inline void neigh_confirm(struct neighbour *n) { if (n) { -- 2.33.0