mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 09:02:06 +00:00
sysfs: use singly-linked list for sysfs_dirent tree
Make sysfs_dirent use singly linked list for its tree structure. sysfs_link_sibling() and sysfs_unlink_sibling() functions are added to handle simpler cases. It adds some complexity and cpu cycle overhead but reduced memory footprint is worthwhile on big machines. This change reduces the sizeof sysfs_dirent from 104 to 88 on 64bit and from 60 to 52 on 32bit. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
8619f97989
commit
0c73f18b7d
4 changed files with 112 additions and 55 deletions
|
@ -284,8 +284,8 @@ void sysfs_drop_dentry(struct sysfs_dirent *sd)
|
|||
|
||||
int sysfs_hash_and_remove(struct dentry * dir, const char * name)
|
||||
{
|
||||
struct sysfs_dirent * sd;
|
||||
struct sysfs_dirent * parent_sd;
|
||||
struct sysfs_dirent **pos, *sd;
|
||||
struct sysfs_dirent *parent_sd = dir->d_fsdata;
|
||||
int found = 0;
|
||||
|
||||
if (!dir)
|
||||
|
@ -295,13 +295,15 @@ int sysfs_hash_and_remove(struct dentry * dir, const char * name)
|
|||
/* no inode means this hasn't been made visible yet */
|
||||
return -ENOENT;
|
||||
|
||||
parent_sd = dir->d_fsdata;
|
||||
mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_PARENT);
|
||||
list_for_each_entry(sd, &parent_sd->s_children, s_sibling) {
|
||||
for (pos = &parent_sd->s_children; *pos; pos = &(*pos)->s_sibling) {
|
||||
sd = *pos;
|
||||
|
||||
if (!sd->s_type)
|
||||
continue;
|
||||
if (!strcmp(sd->s_name, name)) {
|
||||
list_del_init(&sd->s_sibling);
|
||||
*pos = sd->s_sibling;
|
||||
sd->s_sibling = NULL;
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue