All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zqiang <qiang.zhang@linux.dev>
To: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, kuniyu@google.com
Cc: qiang.zhang@linux.dev, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] neighbour: Move the netdev_put() out of RCU callback
Date: Fri,  9 Oct 2026 17:19:41 +0800	[thread overview]
Message-ID: <20261009091941.5837-1-qiang.zhang@linux.dev> (raw)

For builts with CONFIG_NET_DEV_REFCNT_TRACKER=y kernels, netdev_put()
records the caller's stack trace via ref_tracker_free() for debugging
reference leaks. however, the netdev_put() is within pneigh_destroy()
RCU callback, this recorded stack is uninformative, it does not reveal
which code path initiated the deletion.

This commit therefore move netdev_put() from the RCU callback into the
caller's process context, and replace call_rcu() with kfree_rcu().

Fixes: d539d8fbd8fc ("neighbour: Free pneigh_entry after RCU grace period.")
Signed-off-by: Zqiang <qiang.zhang@linux.dev>
---
 net/core/neighbour.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 6ed8eb075146..4263689fc415 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -818,14 +818,6 @@ int pneigh_create(struct neigh_table *tbl,
 	return err;
 }
 
-static void pneigh_destroy(struct rcu_head *rcu)
-{
-	struct pneigh_entry *n = container_of(rcu, struct pneigh_entry, rcu);
-
-	netdev_put(n->dev, &n->dev_tracker);
-	kfree(n);
-}
-
 int pneigh_delete(struct neigh_table *tbl, const void *pkey,
 		  struct net_device *dev)
 {
@@ -849,7 +841,8 @@ int pneigh_delete(struct neigh_table *tbl, const void *pkey,
 			if (tbl->pdestructor)
 				tbl->pdestructor(n);
 
-			call_rcu(&n->rcu, pneigh_destroy);
+			netdev_put(n->dev, &n->dev_tracker);
+			kfree_rcu(n, rcu);
 			return 0;
 		}
 	}
@@ -891,7 +884,8 @@ static void pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev,
 		if (tbl->pdestructor)
 			tbl->pdestructor(n);
 
-		call_rcu(&n->rcu, pneigh_destroy);
+		netdev_put(n->dev, &n->dev_tracker);
+		kfree_rcu(n, rcu);
 	}
 }
 
-- 
2.17.1


             reply	other threads:[~2026-10-09  9:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09  9:19 Zqiang [this message]
2026-10-09 21:26 ` [PATCH] neighbour: Move the netdev_put() out of RCU callback Kuniyuki Iwashima

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261009091941.5837-1-qiang.zhang@linux.dev \
    --to=qiang.zhang@linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.