From: Kuniyuki Iwashima <kuniyu@google.com>
To: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>
Cc: Simon Horman <horms@kernel.org>,
Kuniyuki Iwashima <kuniyu@google.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>,
netdev@vger.kernel.org
Subject: [PATCH v1 net-next 3/4] neighbour: Schedule neigh_managed_work only when needed.
Date: Mon, 12 Oct 2026 19:44:58 +0000 [thread overview]
Message-ID: <20261012194530.3751034-4-kuniyu@google.com> (raw)
In-Reply-To: <20261012194530.3751034-1-kuniyu@google.com>
neigh_table is now per-netns.
tbl->managed_work is scheduled when netns is created and runs
periodically even though the netns does not have any NTF_MANAGED
entries.
Let's delay scheduling the work for the first NTF_MANAGED entry
and stop rescheduling if tbl->managed_list is empty.
Suggested-by: Ido Schimmel <idosch@nvidia.com>
Link: https://lore.kernel.org/netdev/20260902143023.GA3966681@shredder/
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
net/core/neighbour.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 90335895b415..6b0569aa5d64 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -184,6 +184,15 @@ static void neigh_update_gc_list(struct neighbour *n)
}
}
+static void neigh_add_managed_list(struct neighbour *n)
+{
+ list_add_tail(&n->managed_list, &n->tbl->managed_list);
+
+ if (list_is_singular(&n->tbl->managed_list))
+ queue_delayed_work(system_power_efficient_wq,
+ &n->tbl->managed_work, 0);
+}
+
static void neigh_update_managed_list(struct neighbour *n)
{
bool on_managed_list, add_to_managed;
@@ -194,7 +203,7 @@ static void neigh_update_managed_list(struct neighbour *n)
if (!add_to_managed && on_managed_list)
list_del_init(&n->managed_list);
else if (add_to_managed && !on_managed_list)
- list_add_tail(&n->managed_list, &n->tbl->managed_list);
+ neigh_add_managed_list(n);
}
static void neigh_update_flags(struct neighbour *neigh, u32 flags, int *notify,
@@ -708,7 +717,7 @@ ___neigh_create(struct neigh_table *tbl, const void *pkey,
if (!exempt_from_gc)
list_add_tail(&n->gc_list, &n->tbl->gc_list);
if (n->flags & NTF_MANAGED)
- list_add_tail(&n->managed_list, &n->tbl->managed_list);
+ neigh_add_managed_list(n);
if (want_ref)
neigh_hold(n);
hlist_add_head_rcu(&n->hash, &nht->hash_heads[hash_val]);
@@ -1670,10 +1679,14 @@ static void neigh_managed_work(struct work_struct *work)
struct neighbour *neigh;
spin_lock_bh(&tbl->lock);
+
list_for_each_entry(neigh, &tbl->managed_list, managed_list)
neigh_event_send_probe(neigh, NULL, false);
- queue_delayed_work(system_power_efficient_wq, &tbl->managed_work,
- NEIGH_VAR(&tbl->parms, INTERVAL_PROBE_TIME_MS));
+
+ if (!list_empty(&tbl->managed_list))
+ queue_delayed_work(system_power_efficient_wq, &tbl->managed_work,
+ NEIGH_VAR(&tbl->parms, INTERVAL_PROBE_TIME_MS));
+
spin_unlock_bh(&tbl->lock);
}
@@ -1873,7 +1886,6 @@ static int neigh_table_init(struct net *net, struct neigh_table *tbl)
INIT_LIST_HEAD(&tbl->managed_list);
INIT_DEFERRABLE_WORK(&tbl->managed_work, neigh_managed_work);
- queue_delayed_work(system_power_efficient_wq, &tbl->managed_work, 0);
return 0;
--
2.56.0.385.gd3acb90ef8-goog
next prev parent reply other threads:[~2026-10-12 19:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 19:44 [PATCH v1 net-next 0/4] neighbour: Misc follow-ups on per-netns neigh_table series Kuniyuki Iwashima
2026-10-12 19:44 ` [PATCH v1 net-next 1/4] Documentation: networking: switchdev: Replace arp_tbl with arp_table(net) Kuniyuki Iwashima
2026-10-12 19:44 ` [PATCH v1 net-next 2/4] selftests: netfilter: Set gc_thresh[123] for gw netns in nft_nat_zones.sh Kuniyuki Iwashima
2026-10-12 19:44 ` Kuniyuki Iwashima [this message]
2026-10-12 19:44 ` [PATCH v1 net-next 4/4] neighbour: Floor INTERVAL_PROBE_TIME_MS at 1000 Kuniyuki Iwashima
2026-10-13 7:16 ` Ido Schimmel
2026-10-13 7:27 ` Kuniyuki Iwashima
2026-10-13 7:00 ` [PATCH v1 net-next 0/4] neighbour: Misc follow-ups on per-netns neigh_table series Ido Schimmel
2026-10-13 7:23 ` 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=20261012194530.3751034-4-kuniyu@google.com \
--to=kuniyu@google.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--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.