From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-f66.google.com ([209.85.208.66]:44006 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbeHQQcF (ORCPT ); Fri, 17 Aug 2018 12:32:05 -0400 Date: Fri, 17 Aug 2018 16:28:36 +0300 From: Alexey Dobriyan To: Shakeel Butt Cc: dhowells@redhat.com, Alexander Viro , Andrew Morton , linux-fsdevel , LKML Subject: Re: [PATCH] proc: fixup PDE allocation bloat Message-ID: <20180817132836.GA18921@avx2> References: <20180614200956.GB7137@avx2> <15003.1529008242@warthog.procyon.org.uk> <20180617215732.GA24688@avx2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Jul 19, 2018 at 05:06:55PM -0700, Shakeel Butt wrote: > On Sun, Jun 17, 2018 at 2:57 PM Alexey Dobriyan wrote: > > > > commit 24074a35c5c975c94cd9691ae962855333aac47f > > ("proc: Make inline name size calculation automatic") > > started to put PDE allocations into kmalloc-256 which is unnecessary as > > ~40 character names are very rare. > > > > Put allocation back into kmalloc-192 cache for 64-bit non-debug builds. > > > > Put BUILD_BUG_ON to know when PDE size is gotten out of control. > > > > Signed-off-by: Alexey Dobriyan > > --- > > > > fs/proc/inode.c | 6 ++++-- > > fs/proc/internal.h | 17 +++++++---------- > > 2 files changed, 11 insertions(+), 12 deletions(-) > > > > --- a/fs/proc/inode.c > > +++ b/fs/proc/inode.c > > @@ -105,8 +105,10 @@ void __init proc_init_kmemcache(void) > > kmem_cache_create("pde_opener", sizeof(struct pde_opener), 0, > > SLAB_ACCOUNT|SLAB_PANIC, NULL); > > proc_dir_entry_cache = kmem_cache_create_usercopy( > > - "proc_dir_entry", SIZEOF_PDE_SLOT, 0, SLAB_PANIC, > > - OFFSETOF_PDE_NAME, SIZEOF_PDE_INLINE_NAME, NULL); > > + "proc_dir_entry", SIZEOF_PDE, 0, SLAB_PANIC, > > Hi Alexey, can you comment if proc_dir_entry_cache should or shouldn't > have SLAB_ACCOUNT flag? It should not (but see below): SLAB_ACCOUNT is for allocations which can be done by userspace directly: open(2) directly allocates "struct file". But /proc entries aren't like that: say, /proc/cpuinfo is created by kernel and userspace can't do anything about it. Some subsystems create /proc entries based on userspace actions and those aren't related to hardware (example: xt_hashlimit.c) but those are few so kernel doesn't bother accounting those. Or in other words: user can't mkdir(1) and touch(1) and ln(1) inside /proc at will and therefore PDEs aren't accounted.