Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1336005

Re: Idea for reducing sysfs memory usage

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject Re: Idea for reducing sysfs memory usage
Date 2016-02-17 03:30 +0100
Message-ID <r302l-87j-1@gated-at.bofh.it> (permalink)
References <r2Xxw-6pr-11@gated-at.bofh.it> <r2XHc-6sL-5@gated-at.bofh.it> <r2YjU-6VH-3@gated-at.bofh.it> <r2YtA-70p-3@gated-at.bofh.it> <r2Z6h-7tq-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Idea for reducing sysfs memory usage Edward Cree <ec429@cantab.net> - 2016-02-17 00:50 +0100
  Re: Idea for reducing sysfs memory usage Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-02-17 01:00 +0100
    Re: Idea for reducing sysfs memory usage Edward Cree <ec429@cantab.net> - 2016-02-17 01:40 +0100
      Re: Idea for reducing sysfs memory usage David Ahern <dsa@cumulusnetworks.com> - 2016-02-17 01:50 +0100
        Re: Idea for reducing sysfs memory usage Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-02-17 03:40 +0100
      Re: Idea for reducing sysfs memory usage Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-02-17 01:50 +0100
        Re: Idea for reducing sysfs memory usage David Ahern <dsa@cumulusnetworks.com> - 2016-02-17 02:00 +0100
        Re: Idea for reducing sysfs memory usage Edward Cree <ec429@cantab.net> - 2016-02-17 02:30 +0100
          Re: Idea for reducing sysfs memory usage Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-02-17 03:30 +0100
  Re: Idea for reducing sysfs memory usage Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-02-17 01:40 +0100

csiph-web