Commit 85496c9b authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-remove-some-rcu_bh-cruft'

Eric Dumazet says:

====================
net: remove some rcu_bh cruft

There is no point using rcu_bh variant hoping to free objects faster,
especially hen using call_rcu() or kfree_rcu().

Disabling/enabling BH has a non-zero cost, and adds distracting
hot spots in kernel profiles eg. in ip6_xmit().
====================

Link: https://lore.kernel.org/r/20230321040115.787497-1-edumazet@google.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents f6f4e739 fe602c87
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -61,16 +61,6 @@ static inline bool lockdep_rtnl_is_held(void)
#define rcu_dereference_rtnl(p)					\
	rcu_dereference_check(p, lockdep_rtnl_is_held())

/**
 * rcu_dereference_bh_rtnl - rcu_dereference_bh with debug checking
 * @p: The pointer to read, prior to dereference
 *
 * Do an rcu_dereference_bh(p), but check caller either holds rcu_read_lock_bh()
 * or RTNL. Note : Please prefer rtnl_dereference() or rcu_dereference_bh()
 */
#define rcu_dereference_bh_rtnl(p)				\
	rcu_dereference_bh_check(p, lockdep_rtnl_is_held())

/**
 * rtnl_dereference - fetch RCU pointer when updates are prevented by RTNL
 * @p: The pointer to read, prior to dereferencing
+4 −4
Original line number Diff line number Diff line
@@ -38,11 +38,11 @@ static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32
{
	struct neighbour *n;

	rcu_read_lock_bh();
	rcu_read_lock();
	n = __ipv4_neigh_lookup_noref(dev, key);
	if (n && !refcount_inc_not_zero(&n->refcnt))
		n = NULL;
	rcu_read_unlock_bh();
	rcu_read_unlock();

	return n;
}
@@ -51,10 +51,10 @@ static inline void __ipv4_confirm_neigh(struct net_device *dev, u32 key)
{
	struct neighbour *n;

	rcu_read_lock_bh();
	rcu_read_lock();
	n = __ipv4_neigh_lookup_noref(dev, key);
	neigh_confirm(n);
	rcu_read_unlock_bh();
	rcu_read_unlock();
}

void arp_init(void);
+6 −6
Original line number Diff line number Diff line
@@ -395,11 +395,11 @@ static inline struct neighbour *__ipv6_neigh_lookup(struct net_device *dev, cons
{
	struct neighbour *n;

	rcu_read_lock_bh();
	rcu_read_lock();
	n = __ipv6_neigh_lookup_noref(dev, pkey);
	if (n && !refcount_inc_not_zero(&n->refcnt))
		n = NULL;
	rcu_read_unlock_bh();
	rcu_read_unlock();

	return n;
}
@@ -409,10 +409,10 @@ static inline void __ipv6_confirm_neigh(struct net_device *dev,
{
	struct neighbour *n;

	rcu_read_lock_bh();
	rcu_read_lock();
	n = __ipv6_neigh_lookup_noref(dev, pkey);
	neigh_confirm(n);
	rcu_read_unlock_bh();
	rcu_read_unlock();
}

static inline void __ipv6_confirm_neigh_stub(struct net_device *dev,
@@ -420,10 +420,10 @@ static inline void __ipv6_confirm_neigh_stub(struct net_device *dev,
{
	struct neighbour *n;

	rcu_read_lock_bh();
	rcu_read_lock();
	n = __ipv6_neigh_lookup_noref_stub(dev, pkey);
	neigh_confirm(n);
	rcu_read_unlock_bh();
	rcu_read_unlock();
}

/* uses ipv6_stub and is meant for use outside of IPv6 core */
+3 −3
Original line number Diff line number Diff line
@@ -299,14 +299,14 @@ static inline struct neighbour *___neigh_lookup_noref(
	const void *pkey,
	struct net_device *dev)
{
	struct neigh_hash_table *nht = rcu_dereference_bh(tbl->nht);
	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);
	for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]);
	for (n = rcu_dereference(nht->hash_buckets[hash_val]);
	     n != NULL;
	     n = rcu_dereference_bh(n->next)) {
	     n = rcu_dereference(n->next)) {
		if (n->dev == dev && key_eq(n, pkey))
			return n;
	}
+3 −3
Original line number Diff line number Diff line
@@ -498,7 +498,7 @@ static inline struct fib6_nh *nexthop_fib6_nh(struct nexthop *nh)
}

/* Variant of nexthop_fib6_nh().
 * Caller should either hold rcu_read_lock_bh(), or RTNL.
 * Caller should either hold rcu_read_lock(), or RTNL.
 */
static inline struct fib6_nh *nexthop_fib6_nh_bh(struct nexthop *nh)
{
@@ -507,13 +507,13 @@ static inline struct fib6_nh *nexthop_fib6_nh_bh(struct nexthop *nh)
	if (nh->is_group) {
		struct nh_group *nh_grp;

		nh_grp = rcu_dereference_bh_rtnl(nh->nh_grp);
		nh_grp = rcu_dereference_rtnl(nh->nh_grp);
		nh = nexthop_mpath_select(nh_grp, 0);
		if (!nh)
			return NULL;
	}

	nhi = rcu_dereference_bh_rtnl(nh->nh_info);
	nhi = rcu_dereference_rtnl(nh->nh_info);
	if (nhi->family == AF_INET6)
		return &nhi->fib6_nh;

Loading