Return-Path: Date: Fri, 20 Jul 2018 12:15:09 +0100 From: Al Viro To: Vlastimil Babka Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Matthew Wilcox Subject: Re: [PATCH] fs/seq_file: remove kmalloc(ops) for single_open seqfiles Message-ID: <20180720111509.GB30522@ZenIV.linux.org.uk> References: <20180720102952.30935-1-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180720102952.30935-1-vbabka@suse.cz> Sender: owner-linux-mm@kvack.org List-ID: On Fri, Jul 20, 2018 at 12:29:52PM +0200, Vlastimil Babka wrote: > single_open() currently allocates seq_operations with kmalloc(). This is > suboptimal, because that's four pointers, of which three are constant, and > only the 'show' op differs. We also have to be careful to use single_release() > to avoid leaking the ops structure. > > Instead of this we can have a fixed single_show() function and constant ops > structure for these seq_files. We can store the pointer to the 'show' op as > a new field of struct seq_file. That's also not terribly elegant, because the > field is there also for non-single_open() seq files, but it's a single pointer > in an already existing (and already relatively large) structure instead of > an extra kmalloc of four pointers, so the tradeoff is OK. ... except that piling indirect calls is costly and ->show() is called a lot more than open() is.