From 8619f979898397582e366877fd5feeba7560d70c Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 14 Jun 2007 03:45:18 +0900 Subject: 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 Signed-off-by: Greg Kroah-Hartman --- fs/sysfs/sysfs.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'fs/sysfs/sysfs.h') diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h index f8779eaa53f..ae006b070bf 100644 --- a/fs/sysfs/sysfs.h +++ b/fs/sysfs/sysfs.h @@ -21,7 +21,7 @@ struct sysfs_elem_bin_attr { */ struct sysfs_dirent { atomic_t s_count; - struct rw_semaphore s_active; + atomic_t s_active; struct sysfs_dirent * s_parent; struct list_head s_sibling; struct list_head s_children; @@ -42,16 +42,7 @@ struct sysfs_dirent { atomic_t s_event; }; -/* - * A sysfs file which deletes another file when written to need to - * write lock the s_active of the victim while its s_active is read - * locked for the write operation. Tell lockdep that this is okay. - */ -enum sysfs_s_active_class -{ - SYSFS_S_ACTIVE_NORMAL, /* file r/w access, etc - default */ - SYSFS_S_ACTIVE_DEACTIVATE, /* file deactivation */ -}; +#define SD_DEACTIVATED_BIAS INT_MIN extern struct vfsmount * sysfs_mount; extern struct kmem_cache *sysfs_dir_cachep; -- cgit v1.2.3-70-g09d2