Use a rw_lock instead of a mutex.
This however doesn't seem to improve performance here. Need to investigate lock contention I think.
This commit is contained in:
@@ -610,14 +610,14 @@ __unused static void ifa_free(struct ifaddr *ifa) {}
|
|||||||
__unused static void ifa_init(struct ifaddr *ifa) {}
|
__unused static void ifa_init(struct ifaddr *ifa) {}
|
||||||
__unused static void ifa_ref(struct ifaddr *ifa) {}
|
__unused static void ifa_ref(struct ifaddr *ifa) {}
|
||||||
|
|
||||||
extern struct mtx ifnet_lock;
|
extern struct rw_lock ifnet_rwlock;
|
||||||
#define IFNET_LOCK_INIT()
|
#define IFNET_LOCK_INIT() rw_lock_init(&ifnet_rwlock, "ifnet rwlock")
|
||||||
#define IFNET_WLOCK() mtx_lock(&ifnet_lock)
|
#define IFNET_WLOCK() rw_lock_write_lock(&ifnet_rwlock)
|
||||||
#define IFNET_WUNLOCK() mtx_unlock(&ifnet_lock)
|
#define IFNET_WUNLOCK() rw_lock_write_unlock(&ifnet_rwlock)
|
||||||
#define IFNET_RLOCK() IFNET_WLOCK()
|
#define IFNET_RLOCK() rw_lock_read_lock(&ifnet_rwlock)
|
||||||
#define IFNET_RLOCK_NOSLEEP() IFNET_WLOCK()
|
#define IFNET_RLOCK_NOSLEEP() rw_lock_read_lock(&ifnet_rwlock)
|
||||||
#define IFNET_RUNLOCK() IFNET_WUNLOCK()
|
#define IFNET_RUNLOCK() rw_lock_read_unlock(&ifnet_rwlock)
|
||||||
#define IFNET_RUNLOCK_NOSLEEP() IFNET_WUNLOCK()
|
#define IFNET_RUNLOCK_NOSLEEP() rw_lock_read_unlock(&ifnet_rwlock)
|
||||||
|
|
||||||
struct ifnet *ifnet_byindex(u_short idx);
|
struct ifnet *ifnet_byindex(u_short idx);
|
||||||
struct ifnet *ifnet_byindex_locked(u_short idx);
|
struct ifnet *ifnet_byindex_locked(u_short idx);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
// these methods are bit unfriendly, a bit too much panic() around
|
// these methods are bit unfriendly, a bit too much panic() around
|
||||||
|
|
||||||
struct mtx Giant;
|
struct mtx Giant;
|
||||||
struct mtx ifnet_lock;
|
struct rw_lock ifnet_rwlock;
|
||||||
struct mtx gIdStoreLock;
|
struct mtx gIdStoreLock;
|
||||||
|
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ status_t
|
|||||||
init_mutexes()
|
init_mutexes()
|
||||||
{
|
{
|
||||||
mtx_init(&Giant, "Banana Giant", NULL, MTX_DEF);
|
mtx_init(&Giant, "Banana Giant", NULL, MTX_DEF);
|
||||||
mtx_init(&ifnet_lock, "gDevices", NULL, MTX_DEF);
|
rw_lock_init(&ifnet_rwlock, "gDevices");
|
||||||
mtx_init(&gIdStoreLock, "Identity Store", NULL, MTX_DEF);
|
mtx_init(&gIdStoreLock, "Identity Store", NULL, MTX_DEF);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -59,6 +59,6 @@ void
|
|||||||
uninit_mutexes()
|
uninit_mutexes()
|
||||||
{
|
{
|
||||||
mtx_destroy(&Giant);
|
mtx_destroy(&Giant);
|
||||||
mtx_destroy(&ifnet_lock);
|
rw_lock_destroy(&ifnet_rwlock);
|
||||||
mtx_destroy(&gIdStoreLock);
|
mtx_destroy(&gIdStoreLock);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user