Re: Kernel thoughts of a Linux user

Adam J. Richter
2004-11-22T15:00:00Z

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.

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.
However, even then, one might still consider how much of the 57kB of
kobject's and 36kB of attribute's and pointers to them in kset's
are due soley to sysfs, and therefore still consider it a RAM
overhead worth avoiding in some cases.

__ ______________
Adam J. Richter \ /
adam@yggdrasil.com | g g d r a s i l