diff options
| author | Greg Kroah-Hartman <gregkh@suse.de> | 2005-03-08 17:53:28 -0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-03-08 17:53:28 -0800 |
| commit | 181dfb4cef2cf62ea71bdc17a52073f6f02d5bfe (patch) | |
| tree | ff12b69d4e826a9ccf9d9382f1506ac60bbf4ccc /lib/kobject.c | |
| parent | 199c50aa72e7e04aa63b797996b8ea8e320a6de2 (diff) | |
[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: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib/kobject.c')
| -rw-r--r-- | lib/kobject.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index e1282b3576b6..ff9491986b38 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -140,9 +140,9 @@ void kobject_init(struct kobject * kobj) static void unlink(struct kobject * kobj) { if (kobj->kset) { - down_write(&kobj->kset->subsys->rwsem); + spin_lock(&kobj->kset->list_lock); list_del_init(&kobj->entry); - up_write(&kobj->kset->subsys->rwsem); + spin_unlock(&kobj->kset->list_lock); } kobject_put(kobj); } @@ -168,13 +168,13 @@ int kobject_add(struct kobject * kobj) kobj->kset ? kobj->kset->kobj.name : "<NULL>" ); if (kobj->kset) { - down_write(&kobj->kset->subsys->rwsem); + spin_lock(&kobj->kset->list_lock); if (!parent) parent = kobject_get(&kobj->kset->kobj); list_add_tail(&kobj->entry,&kobj->kset->list); - up_write(&kobj->kset->subsys->rwsem); + spin_unlock(&kobj->kset->list_lock); } kobj->parent = parent; @@ -380,6 +380,7 @@ void kset_init(struct kset * k) { kobject_init(&k->kobj); 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) struct list_head * entry; struct kobject * ret = NULL; - down_read(&kset->subsys->rwsem); + spin_lock(&kset->list_lock); list_for_each(entry,&kset->list) { struct kobject * k = to_kobj(entry); if (kobject_name(k) && !strcmp(kobject_name(k),name)) { @@ -452,7 +453,7 @@ struct kobject * kset_find_obj(struct kset * kset, const char * name) break; } } - up_read(&kset->subsys->rwsem); + spin_unlock(&kset->list_lock); return ret; } |
