Re: Kernel thoughts of a Linux user

Maneesh Soni
2004-11-22T20:24:11Z

On Mon, Nov 22, 2004 at 10:54:01PM +0800, Adam J. Richter wrote:
> I wrote:
> > Please correct me if I am wrong, but, as far as I can tell,
> >in 2.6.10-rc2-bk6, a struct dentry is held for each node in the sysfs
> >tree at all times. I infer this from noticing that sysfs_drop_dentry
> >and sysfs_hash_and_remove in fs/sysfs/inode.c only seem to be called
> >on operations to delete a node. If I've missed something and the dentry
> >structures are all or mostly released, I would love to be corrected about
> >it as that would be really good news to me.
>

The new code doesnot pin the leaf nodes but still pins (by having an extra
ref count will creation) the non-leaf nodes or directory dentry and inode.
The non-directory (leaf nodes) dentry and inodes are freed as per the normal
VFS/dcache cache eviction policies. Dentries not in use, will be pruned under
memory pressure and eventually evict inodes also.

> I should correct myself, although this correction suggests
> that sysfs currently uses slightly _more_ memory than I previously
> thought in the case of my computer (1100 directories and 2305
> non-directories in sysfs).
>
> In 2.6.10-rc2-bk6, it looks like sysfs releases the dname
> structures as well in the case of a file (attribute) or symlink,
> but keeps these structures *and* a struct inode for every directory
> (kobject). So, it looks like the non-swappable memory usage of my
> /sys is actually about 900kB.
>
> directories non-directories
> dentry 144 0
> inode 344 0
> sysfs_dirent 36 36
>
> Bytes per: 524 36
> #of nodes: 1100 2305
> Subtotal: 576,400 82,980
>
> Total: 659,380 bytes
>
>
> Perhaps the code that allows non-directories in sysfs to free
> their inode and dname structures will in the future be extended to allow
> directories do so also, which would reduce that total to 122kB.

Extending this to directories introduces lots of race conditions in
maintaining the coherancy between VFS dentry tree and sysfs_dirent
based tree. It could be doable but not without complications.

Thanks
Maneesh

--
Maneesh Soni
Linux Technology Center,
IBM Austin
email: maneesh@in.ibm.com
Phone: 1-512-838-1896 Fax:
T/L : 6781896