From: "Adam J. Richter" <adam@yggdrasil.com>
To: maneesh@in.ibm.com
Cc: akpm@osdl.org, chrisw@osdl.org, greg@kroah.com,
linux-kernel@vger.kernel.org,
viro@parcelfarce.linux.theplanet.co.uk
Subject: Re: [Patch] Do not allocate sysfs_dirent.s_children for non-directories
Date: Thu, 30 Dec 2004 09:33:32 -0800 [thread overview]
Message-ID: <200412301733.iBUHXW719876@adam.yggdrasil.com> (raw)
On Thu, 30 Dec 2004 19:05:29 +0530, Maneesh Soni wrote:
>On Thu, Dec 02, 2004 at 07:20:35PM -0800, Adam J. Richter wrote:
>> The following patch, against a heavily hacked 2.6.10-rc2-bk15
>> sysfs tree, removes the s_children field from sysfs_dirent and
>> creates a new structure just for directories named sysfs_dir, which
>> embeds a sysfs_dirent and also adds s_children. Directories allocate
>> a sysfs_dir; non-directories allocate a sysfs_dirent. There are
>> two separate kmem caches for the different data types.
>>
>> Not allocating s_children from each non-directory saves
>> two pointers (8 bytes) for each of the 2573 non-directory nodes
>> in my sysfs tree, or about 20kB on unswappable memory, but
>> having another kmem cache probably wastes an average of half
>> a page in memory fragmentation and then there is are few
>> bytes from the new code and the additional kmem_cache_t
>> structure, so I would guess it probably saves about 16kB in
>> practice.
>>
>> In the future, I hope to make a similar change for symbolic
>> links.
>>
>> By the way, this patch will also make it easier for me to
>> try to unpin sysfs directories because there are a few other
>> fields specific to directories that I would want to store
>> in sysfs_dir.
>>
>Apart from a couple of diff'ing related comments, I feel the code looks
>some what complicated. I think we can directly link sysfs_dir to
>directory dentries and sysfs_dirent to non-directory dentries instead
>of always linking sysfs_dirent to d_fsdata. To differentiate between the
>two types of structures linked to dentry's d_fsdata field, we can use
>S_ISDIR(dentry->d_inode->i_mode). This will avoid using container_of() and
>the dentry_to_sysfs_dir() conversions.
>Most of the places we may not need to find what type of struct d_fsdata points
>to. Like in sysfs_make_dirent(), first param has to be sysfs_dir as the parent
>dentry corresponds to a sysfs directory.
>In sysfs_lookup() also, we know parent dentry corresponds to sysfs directory
>so dentry's d_fsdata will point to sysfs_dir instead of sysfs_dirent.
In the future, I want to make a change so that attributes in
a named struct attribute_group do not each have a struct dirent.
In that case, it is possible that the attribute_group will only need
a struct sysfs_dirent, not a struct sysfs_dir.
__ ______________
Adam J. Richter \ /
adam@yggdrasil.com | g g d r a s i l
next reply other threads:[~2004-12-30 17:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-30 17:33 Adam J. Richter [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-12-03 3:20 Adam J. Richter
2004-12-30 13:35 ` Maneesh Soni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200412301733.iBUHXW719876@adam.yggdrasil.com \
--to=adam@yggdrasil.com \
--cc=akpm@osdl.org \
--cc=chrisw@osdl.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maneesh@in.ibm.com \
--cc=viro@parcelfarce.linux.theplanet.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®