From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933546AbcBQAht (ORCPT ); Tue, 16 Feb 2016 19:37:49 -0500 Received: from jackal.aluminati.org ([72.9.247.210]:35530 "EHLO jackal.aluminati.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933343AbcBQAhr (ORCPT ); Tue, 16 Feb 2016 19:37:47 -0500 X-Quarantine-ID: <3ocMb3Jvea43> X-Spam-Flag: NO X-Spam-Score: -0.2 Subject: Re: Idea for reducing sysfs memory usage To: Greg Kroah-Hartman References: <56C3B4E9.7030207@cantab.net> <20160216235502.GA14565@kroah.com> Cc: linux-kernel@vger.kernel.org, David Ahern From: Edward Cree Message-ID: <56C3C0D2.9090407@cantab.net> Date: Wed, 17 Feb 2016 00:37:38 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.4.0 MIME-Version: 1.0 In-Reply-To: <20160216235502.GA14565@kroah.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/02/16 23:55, Greg Kroah-Hartman wrote: > On Tue, Feb 16, 2016 at 11:46:49PM +0000, Edward Cree wrote: >> Sorry if this has been suggested before, but if so I couldn't find it. >> Short version: could a sysfs dir reference a list of default attributes >> rather than having to instantiate them all? > Shorter version, why do you think it is? :) > > Have you done some testing of the amount of memory that sysfs entries > consume and found any problems with it? Two reasons: a) in his netdev1.1 talk "Scaling the Number of Network Interfaces on Linux", David Ahern claimed a memory overhead of (iirc) about 45kB per netdevice, of which he attributed (again, iirc) about 20kB to sysfs entries. He also indicated that this was a problem for his use case. (My apologies to David if I've misrepresented him. CCed him so he can correct me.) b) my reading of the code suggested it was allocating stuff for every call to sysfs_create_file() in the loop in populate_dir(). Having re-read __kernfs_new_node() and struct kernfs_node, I now realise I misinterpreted them - the name isn't being allocated at all (kstrdup_const()) and the struct kernfs_node consists chiefly (if not entirely) of fields specific to the individual file rather than shareable between multiple instances. So there isn't any memory we can save here. Sorry for the noise. -- -ed