From: Maneesh Soni <maneesh@in.ibm.com>
To: "Adam J. Richter" <adam@yggdrasil.com>
Cc: greg@kroah.com, linux-kernel@vger.kernel.org
Subject: Re: [Patch] Delete sysfs_dirent.s_count, saving ~100kB on my system
Date: Mon, 22 Nov 2004 16:53:09 -0600 [thread overview]
Message-ID: <20041122225309.GB12858@in.ibm.com> (raw)
In-Reply-To: <200411221917.iAMJHXg02123@freya.yggdrasil.com>
On Tue, Nov 23, 2004 at 03:17:33AM +0800, Adam J. Richter wrote:
> The following patch against linux-2.6.10-rc2-bk6 removes
> the s_count field from sysfs_dirent. This reduces sizeof(sysfs_dirent)
> from 36 to 32 bytes on 32-bit machines, resulting in big space
> savings because it reduces the size that kmalloc actually uses for
> the allocation from 64 to 32 bytes, and there is one of these for
> every node in sysfs, of which there are 3405 on the modest desktop
> machine that I'm using to compose this email. That's a savings of
> 108,960 bytes of unswappable kernel memory in this case.
>
> Reference counting appears to me to be unnecessary on this
> data structure. sysfs_dirent exists when a node name is registered in
> sysfs, and it does not exist when the node name is not registered.
> It does not matter if a program is still holding a reference to the
> struct inode when sysfs_dirent is deleted, since sysfs_dirent is only
> relevant to directory lookup operations. It also should not matter if the
> system is freeing the struct inode and the struct dentry to save
> space. As long as the file is registered in sysfs, the sysfs_dirent
> is not freed.
>
> Removing sysfs_dirent.s_count results in the removal of other
> supporting code, including sysfs_dentry_ops, for a net deletion of
> 39 lines of code.
>
> I have only tested this patch by mounting /sys, and running
> some "find" commands on it, plugging and unplugging a USB device,
> and verifying that the number of entries in sysfs increased and
> decreased accordingly. I am running it on the system on which I
> am composing this email.
>
The idea for having ref count for sysfs_dirent was to keep the sysfs_dirents
around as long as there are live dentries corresponding to sysfs objects.
There can be open files (live dentries) but files getting removed. IMO,
without having ref count for sysfs_dirent, we could end up loosing the
sysfs_dirent and end up in inconsistent sysfs_dirent tree with respect to
dentry tree. If we could maintain the consistency without refcounts then
it is good to reduce the size of sysfs_dirent structure.
Could you also test the patch like this, on an SMP box. Basically
opening/closing sysfs files and simultaneously inserting & removing dummy
module. This is just to make sure that we don't have any races
particularly in dir and file operations. I will also test the patch tonight.
# while true; do find /sys/class/net/ | xargs cat; done
# while true; do insmod dummy.ko; rmmod dummy; done
# while true; do ls -lR /sys > /dev/null; done
Thanks
Maneesh
--
Maneesh Soni
Linux Technology Center,
IBM Austin
email: maneesh@in.ibm.com
Phone: 1-512-838-1896 Fax:
T/L : 6781896
next prev parent reply other threads:[~2004-11-22 22:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-22 19:17 Adam J. Richter
2004-11-22 22:53 ` Maneesh Soni [this message]
2004-11-23 4:08 Adam J. Richter
2004-12-01 18:56 Adam J. Richter
2004-12-01 21:07 ` Andrew Morton
2004-12-01 23:51 ` Chris Wright
2004-12-17 23:27 ` Greg KH
2004-12-30 13:34 ` Maneesh Soni
2004-12-02 2:59 Adam J. Richter
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=20041122225309.GB12858@in.ibm.com \
--to=maneesh@in.ibm.com \
--cc=adam@yggdrasil.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/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®