Commit 181dfb4c authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] kset: make ksets have a spinlock, and use that to lock their lists

Do this instead of using the rwsem of a subsys.
Smaller, faster, and I'm trying to get rid of the rwsem in the subsys.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 199c50aa
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <linux/spinlock.h>
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <linux/kref.h> #include <linux/kref.h>
#include <linux/kobject_uevent.h> #include <linux/kobject_uevent.h>
...@@ -102,6 +103,7 @@ struct kset { ...@@ -102,6 +103,7 @@ struct kset {
struct subsystem * subsys; struct subsystem * subsys;
struct kobj_type * ktype; struct kobj_type * ktype;
struct list_head list; struct list_head list;
spinlock_t list_lock;
struct kobject kobj; struct kobject kobj;
struct kset_hotplug_ops * hotplug_ops; struct kset_hotplug_ops * hotplug_ops;
}; };
......
...@@ -140,9 +140,9 @@ void kobject_init(struct kobject * kobj) ...@@ -140,9 +140,9 @@ void kobject_init(struct kobject * kobj)
static void unlink(struct kobject * kobj) static void unlink(struct kobject * kobj)
{ {
if (kobj->kset) { if (kobj->kset) {
down_write(&kobj->kset->subsys->rwsem); spin_lock(&kobj->kset->list_lock);
list_del_init(&kobj->entry); list_del_init(&kobj->entry);
up_write(&kobj->kset->subsys->rwsem); spin_unlock(&kobj->kset->list_lock);
} }
kobject_put(kobj); kobject_put(kobj);
} }
...@@ -168,13 +168,13 @@ int kobject_add(struct kobject * kobj) ...@@ -168,13 +168,13 @@ int kobject_add(struct kobject * kobj)
kobj->kset ? kobj->kset->kobj.name : "<NULL>" ); kobj->kset ? kobj->kset->kobj.name : "<NULL>" );
if (kobj->kset) { if (kobj->kset) {
down_write(&kobj->kset->subsys->rwsem); spin_lock(&kobj->kset->list_lock);
if (!parent) if (!parent)
parent = kobject_get(&kobj->kset->kobj); parent = kobject_get(&kobj->kset->kobj);
list_add_tail(&kobj->entry,&kobj->kset->list); list_add_tail(&kobj->entry,&kobj->kset->list);
up_write(&kobj->kset->subsys->rwsem); spin_unlock(&kobj->kset->list_lock);
} }
kobj->parent = parent; kobj->parent = parent;
...@@ -380,6 +380,7 @@ void kset_init(struct kset * k) ...@@ -380,6 +380,7 @@ void kset_init(struct kset * k)
{ {
kobject_init(&k->kobj); kobject_init(&k->kobj);
INIT_LIST_HEAD(&k->list); INIT_LIST_HEAD(&k->list);
spin_lock_init(&k->list_lock);
} }
...@@ -444,7 +445,7 @@ struct kobject * kset_find_obj(struct kset * kset, const char * name) ...@@ -444,7 +445,7 @@ struct kobject * kset_find_obj(struct kset * kset, const char * name)
struct list_head * entry; struct list_head * entry;
struct kobject * ret = NULL; struct kobject * ret = NULL;
down_read(&kset->subsys->rwsem); spin_lock(&kset->list_lock);
list_for_each(entry,&kset->list) { list_for_each(entry,&kset->list) {
struct kobject * k = to_kobj(entry); struct kobject * k = to_kobj(entry);
if (kobject_name(k) && !strcmp(kobject_name(k),name)) { if (kobject_name(k) && !strcmp(kobject_name(k),name)) {
...@@ -452,7 +453,7 @@ struct kobject * kset_find_obj(struct kset * kset, const char * name) ...@@ -452,7 +453,7 @@ struct kobject * kset_find_obj(struct kset * kset, const char * name)
break; break;
} }
} }
up_read(&kset->subsys->rwsem); spin_unlock(&kset->list_lock);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment