From: bluhm Date: Sun, 21 Aug 2022 23:04:45 +0000 (+0000) Subject: Only grab netlock in igmp and mdl6 fast timer when necessary. There X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=148170073102c03b8ea62ff7e69f02107698b431;p=openbsd Only grab netlock in igmp and mdl6 fast timer when necessary. There are status variables that can be used to avoid locking if timers are not running. This should reduce contention on exclusive netlock. OK kn@ mvs@ --- diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index 973074266c5..251ad71894e 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: igmp.c,v 1.78 2022/03/28 16:31:26 bluhm Exp $ */ +/* $OpenBSD: igmp.c,v 1.79 2022/08/21 23:04:45 bluhm Exp $ */ /* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */ /* @@ -526,24 +526,24 @@ igmp_fasttimo(void) { struct ifnet *ifp; - NET_LOCK(); - /* * Quick check to see if any work needs to be done, in order * to minimize the overhead of fasttimo processing. + * Variable igmp_timers_are_running is read atomically. In case we + * miss a fast timer due to MP races, just run it next time. */ if (!igmp_timers_are_running) - goto out; + return; + + NET_LOCK(); igmp_timers_are_running = 0; TAILQ_FOREACH(ifp, &ifnet, if_list) igmp_checktimer(ifp); -out: NET_UNLOCK(); } - void igmp_checktimer(struct ifnet *ifp) { diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c index 2e386293d39..31c0256b7aa 100644 --- a/sys/netinet6/mld6.c +++ b/sys/netinet6/mld6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mld6.c,v 1.56 2018/11/30 09:28:34 claudio Exp $ */ +/* $OpenBSD: mld6.c,v 1.57 2022/08/21 23:04:45 bluhm Exp $ */ /* $KAME: mld6.c,v 1.26 2001/02/16 14:50:35 itojun Exp $ */ /* @@ -327,20 +327,21 @@ mld6_fasttimeo(void) { struct ifnet *ifp; - NET_LOCK(); - /* * Quick check to see if any work needs to be done, in order * to minimize the overhead of fasttimo processing. + * Variable mld_timers_are_running is read atomically. In case we + * miss a fast timer due to MP races, just run it next time. */ if (!mld_timers_are_running) - goto out; + return; + + NET_LOCK(); mld_timers_are_running = 0; TAILQ_FOREACH(ifp, &ifnet, if_list) mld6_checktimer(ifp); -out: NET_UNLOCK(); }