summaryrefslogtreecommitdiffstats
path: root/sys/net/pfil.c
diff options
context:
space:
mode:
authormlaier <mlaier@FreeBSD.org>2007-11-25 12:41:47 +0000
committermlaier <mlaier@FreeBSD.org>2007-11-25 12:41:47 +0000
commitb79ff6363a8f9013c8d2e976f34720f6ba6a7476 (patch)
treeeb25112607028bcedf3a83b39b1721175f867f3a /sys/net/pfil.c
parent9ba5385124b0c51a31a2a273e5a51fdd2a4d38d7 (diff)
downloadFreeBSD-src-b79ff6363a8f9013c8d2e976f34720f6ba6a7476.zip
FreeBSD-src-b79ff6363a8f9013c8d2e976f34720f6ba6a7476.tar.gz
pfil(9) locking take 3: Switch to rmlock(9)
This has the benefit that rmlocks have proper support for reader recursion (in contrast to rwlock(9) which could potential lead to writer stravation). It also means a significant performance gain, eventhough only visible in microbenchmarks at the moment. Discussed on: -arch, -net
Diffstat (limited to 'sys/net/pfil.c')
-rw-r--r--sys/net/pfil.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/net/pfil.c b/sys/net/pfil.c
index 78b87f3..bb82bb3 100644
--- a/sys/net/pfil.c
+++ b/sys/net/pfil.c
@@ -34,7 +34,7 @@
#include <sys/errno.h>
#include <sys/lock.h>
#include <sys/malloc.h>
-#include <sys/rwlock.h>
+#include <sys/rmlock.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/systm.h>
@@ -66,11 +66,12 @@ int
pfil_run_hooks(struct pfil_head *ph, struct mbuf **mp, struct ifnet *ifp,
int dir, struct inpcb *inp)
{
+ struct rm_priotracker rmpt;
struct packet_filter_hook *pfh;
struct mbuf *m = *mp;
int rv = 0;
- PFIL_RLOCK(ph);
+ PFIL_RLOCK(ph, &rmpt);
KASSERT(ph->ph_nhooks >= 0, ("Pfil hook count dropped < 0"));
for (pfh = pfil_hook_get(dir, ph); pfh != NULL;
pfh = TAILQ_NEXT(pfh, pfil_link)) {
@@ -80,7 +81,7 @@ pfil_run_hooks(struct pfil_head *ph, struct mbuf **mp, struct ifnet *ifp,
break;
}
}
- PFIL_RUNLOCK(ph);
+ PFIL_RUNLOCK(ph, &rmpt);
*mp = m;
return (rv);
@@ -104,7 +105,7 @@ pfil_head_register(struct pfil_head *ph)
}
PFIL_LIST_UNLOCK();
- rw_init(&ph->ph_mtx, "PFil hook read/write mutex");
+ PFIL_LOCK_INIT(ph);
PFIL_WLOCK(ph);
ph->ph_nhooks = 0;
@@ -143,7 +144,7 @@ pfil_head_unregister(struct pfil_head *ph)
free(pfh, M_IFADDR);
TAILQ_FOREACH_SAFE(pfh, &ph->ph_out, pfil_link, pfnext)
free(pfh, M_IFADDR);
- rw_destroy(&ph->ph_mtx);
+ PFIL_LOCK_DESTROY(ph);
return (0);
}
OpenPOWER on IntegriCloud