Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Remove IFNET_GLOBAL_LOCK where it's unnecessary beca...
details: https://anonhg.NetBSD.org/src/rev/17648801cb34
branches: trunk
changeset: 358160:17648801cb34
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Dec 15 04:04:58 2017 +0000
description:
Remove IFNET_GLOBAL_LOCK where it's unnecessary because IFNET_LOCK is held
diffstat:
sys/net/if.c | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
diffs (62 lines):
diff -r 01a0e659183c -r 17648801cb34 sys/net/if.c
--- a/sys/net/if.c Fri Dec 15 04:03:46 2017 +0000
+++ b/sys/net/if.c Fri Dec 15 04:04:58 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.415 2017/12/15 04:03:46 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.416 2017/12/15 04:04:58 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.415 2017/12/15 04:03:46 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.416 2017/12/15 04:04:58 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -1792,11 +1792,18 @@
ifa->ifa_ifp = ifp;
- IFNET_GLOBAL_LOCK();
+ /*
+ * Check !IFF_RUNNING for initialization routines that normally don't
+ * take IFNET_LOCK but it's safe because there is no competitor.
+ * XXX there are false positive cases because IFF_RUNNING can be off on
+ * if_stop.
+ */
+ KASSERT(!ISSET(ifp->if_flags, IFF_RUNNING) ||
+ IFNET_LOCKED(ifp));
+
TAILQ_INSERT_TAIL(&ifp->if_addrlist, ifa, ifa_list);
IFADDR_ENTRY_INIT(ifa);
IFADDR_WRITER_INSERT_TAIL(ifp, ifa);
- IFNET_GLOBAL_UNLOCK();
ifaref(ifa);
}
@@ -1806,14 +1813,19 @@
{
KASSERT(ifa->ifa_ifp == ifp);
-
- IFNET_GLOBAL_LOCK();
+ /*
+ * if_is_deactivated indicates ifa_remove is called form if_detach
+ * where is safe even if IFNET_LOCK isn't held.
+ */
+ KASSERT(if_is_deactivated(ifp) || IFNET_LOCKED(ifp));
+
TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list);
IFADDR_WRITER_REMOVE(ifa);
#ifdef NET_MPSAFE
+ IFNET_GLOBAL_LOCK();
pserialize_perform(ifnet_psz);
+ IFNET_GLOBAL_UNLOCK();
#endif
- IFNET_GLOBAL_UNLOCK();
#ifdef NET_MPSAFE
psref_target_destroy(&ifa->ifa_psref, ifa_psref_class);
Home |
Main Index |
Thread Index |
Old Index