diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-03-01 22:37:01 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-03-01 22:37:01 +0000 |
commit | 8da3c338df69c01d7b944522ec9ce80aa7f6b6f7 (patch) | |
tree | bc9b2866a079fd9f8cd42348680176d3f9e0fa0b | |
parent | 2413c6f29f84c5ff7492862c41ff2b211cdcfd80 (diff) | |
download | FreeBSD-src-8da3c338df69c01d7b944522ec9ce80aa7f6b6f7.zip FreeBSD-src-8da3c338df69c01d7b944522ec9ce80aa7f6b6f7.tar.gz |
Rename NET_PICKUP_GIANT() to NET_LOCK_GIANT(), and NET_DROP_GIANT()
to NET_UNLOCK_GIANT(). While they are used in similar ways, the
semantics are quite different -- NET_LOCK_GIANT() and NET_UNLOCK_GIANT()
directly wrap mutex lock and unlock operations, whereas drop/pickup
special case the handling of Giant recursion. Add a comment saying
as much.
Add NET_ASSERT_GIANT(), which conditionally asserts Giant based
on the value of debug_mpsafenet.
-rw-r--r-- | sys/netinet/ip_input.c | 4 | ||||
-rw-r--r-- | sys/sys/mutex.h | 12 |
2 files changed, 11 insertions, 5 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 8100a62..b798092 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -936,9 +936,9 @@ DPRINTF(("ip_input: no SP, packet discarded\n"));/*XXX*/ *(struct sockaddr_in **)(mtag+1) = args.next_hop; m_tag_prepend(m, mtag); } - NET_PICKUP_GIANT(); + NET_LOCK_GIANT(); (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen); - NET_DROP_GIANT(); + NET_UNLOCK_GIANT(); return; bad: m_freem(m); diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index 05575b5..f86679d 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -345,20 +345,26 @@ do { \ * input path and protocols that require Giant must collect it * on entry. When 0 Giant is grabbed in the network interface * ISR's and in the netisr path and there is no need to grab - * the Giant lock. + * the Giant lock. Note that, unlike GIANT_PICKUP() and + * GIANT_DROP(), these macros directly wrap mutex operations + * without special recursion handling. * * This mechanism is intended as temporary until everything of * importance is properly locked. */ extern int debug_mpsafenet; /* defined in net/netisr.c */ -#define NET_PICKUP_GIANT() do { \ +#define NET_LOCK_GIANT() do { \ if (debug_mpsafenet) \ mtx_lock(&Giant); \ } while (0) -#define NET_DROP_GIANT() do { \ +#define NET_UNLOCK_GIANT() do { \ if (debug_mpsafenet) \ mtx_unlock(&Giant); \ } while (0) +#define NET_ASSERT_GIANT() do { \ + if (debug_mpsafenet) \ + mtx_assert(&Giant, MA_OWNED); \ +} while (0) #define UGAR(rval) do { \ int _val = (rval); \ |