From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Edward Cree <ec429@cantab.net>
Cc: linux-kernel@vger.kernel.org, David Ahern <dsa@cumulusnetworks.com>
Subject: Re: Idea for reducing sysfs memory usage
Date: Tue, 16 Feb 2016 18:27:59 -0800 [thread overview]
Message-ID: <20160217022759.GA26016@kroah.com> (raw)
In-Reply-To: <56C3CC43.8060706@cantab.net>
On Wed, Feb 17, 2016 at 01:26:27AM +0000, Edward Cree wrote:
> On 17/02/16 00:47, Greg Kroah-Hartman wrote:
> >How many sysfs entries are you creating for that 20kb? And how did you
> >measure it? If you don't access the files, the backing store is not
> >allocated, saving you a lot of memory.
> Thinking about this some more, could we not do the same thing with the
> struct kernfs_nodes, i.e. only allocate them when someone first accesses
> the file? Or simpler, defer allocation of all the files in the dir until
> someone first touches the directory? Of course it would add a little
> latency to that first access, but (barring differences in cache warmth) it
> would subtract the same amount of time from the initial dir creation, and
> in the case where no-one ever looks at the directory, it would save the
> memory.
> I did find a patch series from 2009 doing something vaguely similar[1], but
> a) it looks like it wasn't applied and b) it appears to involve a function
> pointer in struct sysfs_elem_dir to say how to populate the directory.
> All we need here is to get our kobj (which we have in priv member of struct
> kernfs_node) and call populate_dir(). (And remove whatever flag or mark we
> used to say "not populated yet". And some locking will be needed.)
>
> Again, no hard numbers on how much memory this would save, nor evidence
> that the "no-one ever touches the dir" case happens in practice...
someone always touches the dir to start with, if you are using udev in
your system and you have any rule files for those types of devices. So
watch out for that.
If you want to try to implement something like this, please attempt it,
I'll always review patches. But currently, I have no plans on changing
anything on my own, sorry.
thanks,
greg k-h
next prev parent reply other threads:[~2016-02-17 2:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 23:46 Idea for reducing sysfs memory usage Edward Cree
2016-02-16 23:55 ` Greg Kroah-Hartman
2016-02-17 0:37 ` Edward Cree
2016-02-17 0:44 ` David Ahern
2016-02-17 2:30 ` Greg Kroah-Hartman
2016-02-17 0:47 ` Greg Kroah-Hartman
2016-02-17 0:53 ` David Ahern
2016-02-17 1:26 ` Edward Cree
2016-02-17 2:27 ` Greg Kroah-Hartman [this message]
2016-02-17 0:38 ` Greg Kroah-Hartman
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=20160217022759.GA26016@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=dsa@cumulusnetworks.com \
--cc=ec429@cantab.net \
--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