summaryrefslogtreecommitdiffstats
path: root/sys/net/pfil.h
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.h
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.h')
-rw-r--r--sys/net/pfil.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/net/pfil.h b/sys/net/pfil.h
index d2308fd..22d3d16 100644
--- a/sys/net/pfil.h
+++ b/sys/net/pfil.h
@@ -37,7 +37,7 @@
#include <sys/_lock.h>
#include <sys/_mutex.h>
#include <sys/lock.h>
-#include <sys/rwlock.h>
+#include <sys/rmlock.h>
struct mbuf;
struct ifnet;
@@ -69,7 +69,7 @@ struct pfil_head {
pfil_list_t ph_out;
int ph_type;
int ph_nhooks;
- struct rwlock ph_mtx;
+ struct rmlock ph_lock;
union {
u_long phu_val;
void *phu_ptr;
@@ -93,10 +93,13 @@ int pfil_head_unregister(struct pfil_head *);
struct pfil_head *pfil_head_get(int, u_long);
#define PFIL_HOOKED(p) ((p)->ph_nhooks > 0)
-#define PFIL_RLOCK(p) rw_rlock(&(p)->ph_mtx)
-#define PFIL_WLOCK(p) rw_wlock(&(p)->ph_mtx)
-#define PFIL_RUNLOCK(p) rw_runlock(&(p)->ph_mtx)
-#define PFIL_WUNLOCK(p) rw_wunlock(&(p)->ph_mtx)
+#define PFIL_LOCK_INIT(p) \
+ rm_init(&(p)->ph_lock, "PFil hook read/write mutex", LO_RECURSABLE)
+#define PFIL_LOCK_DESTROY(p) rm_destroy(&(p)->ph_lock)
+#define PFIL_RLOCK(p, t) rm_rlock(&(p)->ph_lock, (t))
+#define PFIL_WLOCK(p) rm_wlock(&(p)->ph_lock)
+#define PFIL_RUNLOCK(p, t) rm_runlock(&(p)->ph_lock, (t))
+#define PFIL_WUNLOCK(p) rm_wunlock(&(p)->ph_lock)
#define PFIL_LIST_LOCK() mtx_lock(&pfil_global_lock)
#define PFIL_LIST_UNLOCK() mtx_unlock(&pfil_global_lock)
OpenPOWER on IntegriCloud