The kernel lock was added back when there was a single sofnet task queue:
sys/net/nd6.c revision 1.213
date: 2017/08/06 12:53:30; author: mpi; state: Exp; lines: +15 -21;
Reduce contention on the NET_LOCK() by moving the nd6 address expiration
task to the `softnettq`.
While here update comments and names to reflect reality after the
removal
of router and prefix lists.
ok florian@, bluhm@
I can't find the original thread, but "Reducing NET_LOCK() contention"[0]
and "Reduce NET_LOCK() contention part 2"[1] did similar stuff at that time.
0: https://marc.info/?l=openbsd-tech&m=150038615913233&w=2
1: https://marc.info/?l=openbsd-tech&m=150038690413538&w=2
Today there are min(4, hw.ncpu) MP-safe softnet task queues as compared to
the single one five years ago:
sys/net/if.c revision 1.652
date: 2022/05/03 11:47:03; author: bluhm; state: Exp; lines: +2 -2;
Activate parallel IP forwarding. Start 4 softnet tasks. Limit the
usage to the number of CPUs.
lots of testing Hrvoje Popovski; OK sashan@ sthen@
Nothing in nd6_expire() or nd6_expire_timer_update() requires protection by
the kernel lock.
Both interface list and per-interface address lists remain protected by
the net lock.
So I suggest putting pressure back onto the net lock.
This has been running fine for me in regular usage on desktop as well as
test machines in IPv6 networks.
Hrvoje was so kind to test this diff without any regressions in his
forward/performance setup, with and without creating extra ND6 traffic to
keep the cache expiry thread busy.
Feedback? Objection? OK?
Index: nd6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6.c,v
retrieving revision 1.248
diff -u -p -r1.248 nd6.c
--- nd6.c 9 Sep 2022 12:05:52 -0000 1.248
+++ nd6.c 20 Oct 2022 09:54:02 -0000
@@ -446,8 +446,6 @@ nd6_expire_timer_update(struct in6_ifadd
time_t expire_time = INT64_MAX;
int secs;
- KERNEL_ASSERT_LOCKED();
-
if (ia6->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME)
expire_time = ia6->ia6_lifetime.ia6t_expire;
@@ -486,7 +484,6 @@ nd6_expire(void *unused)
{
struct ifnet *ifp;
- KERNEL_LOCK();
NET_LOCK();
TAILQ_FOREACH(ifp, &ifnetlist, if_list) {
@@ -509,7 +506,6 @@ nd6_expire(void *unused)
}
NET_UNLOCK();
- KERNEL_UNLOCK();
}
void