diff options
author | Tejun Heo <htejun@gmail.com> | 2007-06-13 14:45:18 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-11 19:09:07 -0400 |
commit | 8619f979898397582e366877fd5feeba7560d70c (patch) | |
tree | 7d0e92d4c17d92a00dfeba2b840bf89657b30607 /fs/sysfs/sysfs.h | |
parent | b6b4a4399c2a83d1af77c99dee0d0b5cc15ec268 (diff) |
sysfs: slim down sysfs_dirent->s_active
Make sysfs_dirent->s_active an atomic_t instead of rwsem. This
reduces the size of sysfs_dirent from 136 to 104 on 64bit and from 76
to 60 on 32bit with lock debugging turned off. With lock debugging
turned on the reduction is much larger.
s_active starts at zero and each active reference increments s_active.
Putting a reference decrements s_active. Deactivation subtracts
SD_DEACTIVATED_BIAS which is currently INT_MIN and assumed to be small
enough to make s_active negative. If s_active is negative,
sysfs_get() no longer grants new references. Deactivation succeeds
immediately if there is no active user; otherwise, it waits using a
completion for the last put.
Due to the removal of lockdep tricks, this change makes things less
trickier in release_sysfs_dirent(). As all the complexity is
contained in three s_active functions, I think it's more readable this
way.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/sysfs.h')
-rw-r--r-- | fs/sysfs/sysfs.h | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h index f8779eaa53ff..ae006b070bf0 100644 --- a/fs/sysfs/sysfs.h +++ b/fs/sysfs/sysfs.h | |||
@@ -21,7 +21,7 @@ struct sysfs_elem_bin_attr { | |||
21 | */ | 21 | */ |
22 | struct sysfs_dirent { | 22 | struct sysfs_dirent { |
23 | atomic_t s_count; | 23 | atomic_t s_count; |
24 | struct rw_semaphore s_active; | 24 | atomic_t s_active; |
25 | struct sysfs_dirent * s_parent; | 25 | struct sysfs_dirent * s_parent; |
26 | struct list_head s_sibling; | 26 | struct list_head s_sibling; |
27 | struct list_head s_children; | 27 | struct list_head s_children; |
@@ -42,16 +42,7 @@ struct sysfs_dirent { | |||
42 | atomic_t s_event; | 42 | atomic_t s_event; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /* | 45 | #define SD_DEACTIVATED_BIAS INT_MIN |
46 | * A sysfs file which deletes another file when written to need to | ||
47 | * write lock the s_active of the victim while its s_active is read | ||
48 | * locked for the write operation. Tell lockdep that this is okay. | ||
49 | */ | ||
50 | enum sysfs_s_active_class | ||
51 | { | ||
52 | SYSFS_S_ACTIVE_NORMAL, /* file r/w access, etc - default */ | ||
53 | SYSFS_S_ACTIVE_DEACTIVATE, /* file deactivation */ | ||
54 | }; | ||
55 | 46 | ||
56 | extern struct vfsmount * sysfs_mount; | 47 | extern struct vfsmount * sysfs_mount; |
57 | extern struct kmem_cache *sysfs_dir_cachep; | 48 | extern struct kmem_cache *sysfs_dir_cachep; |