Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755321AbcJUUkS (ORCPT ); Fri, 21 Oct 2016 16:40:18 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:57014 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753620AbcJUUkP (ORCPT ); Fri, 21 Oct 2016 16:40:15 -0400 From: Shaohua Li To: , CC: , Subject: [RFC] put more pressure on proc/sysfs slab shrink Date: Fri, 21 Oct 2016 13:35:14 -0700 Message-ID: X-Mailer: git-send-email 2.9.3 X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-10-21_12:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1664 Lines: 45 In our systems, proc/sysfs inode/dentry cache use more than 1G memory even memory pressure is high sometimes. Since proc/sysfs is in-memory filesystem, rebuilding the cache is fast. There is no point proc/sysfs and disk fs have equal pressure for slab shrink. One idea is directly discarding proc/sysfs inode/dentry cache rightly after the proc/sysfs file is closed. But the discarding will make proc/sysfs file open slower next time, which is 20x slower in my test if multiple applications are accessing proc files. This patch doesn't go that far. Instead, just put more pressure to shrink proc/sysfs slabs. Signed-off-by: Shaohua Li --- fs/kernfs/mount.c | 2 ++ fs/proc/inode.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c index d5b149a..5b4e747 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c @@ -161,6 +161,8 @@ static int kernfs_fill_super(struct super_block *sb, unsigned long magic) sb->s_xattr = kernfs_xattr_handlers; sb->s_time_gran = 1; + sb->s_shrink.seeks = 1; + sb->s_shrink.batch = 0; /* get root inode, initialize and unlock it */ mutex_lock(&kernfs_mutex); inode = kernfs_get_inode(sb, info->root->kn); diff --git a/fs/proc/inode.c b/fs/proc/inode.c index e69ebe6..afef9fb 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -474,6 +474,8 @@ int proc_fill_super(struct super_block *s, void *data, int silent) s->s_op = &proc_sops; s->s_time_gran = 1; + s->s_shrink.seeks = 1; + s->s_shrink.batch = 0; /* * procfs isn't actually a stacking filesystem; however, there is * too much magic going on inside it to permit stacking things on -- 2.9.3