[dahdi-commits] sruffell: linux/trunk r9589 - /linux/trunk/drivers/dahdi/dahdi-base.c
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Mon Jan 3 18:26:51 UTC 2011
Author: sruffell
Date: Mon Jan 3 12:26:47 2011
New Revision: 9589
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9589
Log:
dahdi: Convert ecfactory_list_lock from rwlock to spinlock.
rwlocks are slowly being deprecated because they typically do not
provide the performance increase expected. Most of the
ecfactory_list_lock acquiring is during setup and not in the hot path
anyway, so we can just use the simpler spinlock semantics without the
overhead of a semaphore or mutex.
Signed-off-by: Shaun Ruffell <sruffell at digium.com>
Acked-by: Kinsey Moore <kmoore at digium.com>
Modified:
linux/trunk/drivers/dahdi/dahdi-base.c
Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=9589&r1=9588&r2=9589
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Mon Jan 3 12:26:47 2011
@@ -483,11 +483,7 @@
#define NUM_SIGS 10
-#ifdef DEFINE_RWLOCK
-static DEFINE_RWLOCK(ecfactory_list_lock);
-#else
-static rwlock_t ecfactory_list_lock = __RW_LOCK_UNLOCKED();
-#endif
+static DEFINE_SPINLOCK(ecfactory_list_lock);
static LIST_HEAD(ecfactory_list);
@@ -502,18 +498,18 @@
WARN_ON(!ec->owner);
- write_lock(&ecfactory_list_lock);
+ spin_lock(&ecfactory_list_lock);
/* make sure it isn't already registered */
list_for_each_entry(cur, &ecfactory_list, list) {
if (cur->ec == ec) {
- write_unlock(&ecfactory_list_lock);
+ spin_unlock(&ecfactory_list_lock);
return -EPERM;
}
}
if (!(cur = kzalloc(sizeof(*cur), GFP_KERNEL))) {
- write_unlock(&ecfactory_list_lock);
+ spin_unlock(&ecfactory_list_lock);
return -ENOMEM;
}
@@ -522,7 +518,7 @@
list_add_tail(&cur->list, &ecfactory_list);
- write_unlock(&ecfactory_list_lock);
+ spin_unlock(&ecfactory_list_lock);
return 0;
}
@@ -531,7 +527,7 @@
{
struct ecfactory *cur, *next;
- write_lock(&ecfactory_list_lock);
+ spin_lock(&ecfactory_list_lock);
list_for_each_entry_safe(cur, next, &ecfactory_list, list) {
if (cur->ec == ec) {
@@ -540,7 +536,7 @@
}
}
- write_unlock(&ecfactory_list_lock);
+ spin_unlock(&ecfactory_list_lock);
}
static inline void rotate_sums(void)
@@ -1213,23 +1209,23 @@
*c = '\0';
retry:
- read_lock(&ecfactory_list_lock);
+ spin_lock(&ecfactory_list_lock);
list_for_each_entry(cur, &ecfactory_list, list) {
if (!strcmp(name_upper, cur->ec->get_name(NULL))) {
if (try_module_get(cur->ec->owner)) {
- read_unlock(&ecfactory_list_lock);
+ spin_unlock(&ecfactory_list_lock);
kfree(name_upper);
return cur->ec;
} else {
- read_unlock(&ecfactory_list_lock);
+ spin_unlock(&ecfactory_list_lock);
kfree(name_upper);
return NULL;
}
}
}
- read_unlock(&ecfactory_list_lock);
+ spin_unlock(&ecfactory_list_lock);
if (tried_once) {
kfree(name_upper);
@@ -4641,7 +4637,7 @@
memset(&vi, 0, sizeof(vi));
strlcpy(vi.version, DAHDI_VERSION, sizeof(vi.version));
- read_lock(&ecfactory_list_lock);
+ spin_lock(&ecfactory_list_lock);
list_for_each_entry(cur, &ecfactory_list, list) {
strncat(vi.echo_canceller + strlen(vi.echo_canceller),
cur->ec->get_name(NULL), space);
@@ -4657,7 +4653,7 @@
}
}
}
- read_unlock(&ecfactory_list_lock);
+ spin_unlock(&ecfactory_list_lock);
if (copy_to_user((void __user *)data, &vi, sizeof(vi)))
return -EFAULT;
break;
More information about the dahdi-commits
mailing list