From patchwork Fri Oct 21 20:35:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaohua Li X-Patchwork-Id: 9390107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 40F7060762 for ; Fri, 21 Oct 2016 20:44:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32CC729F31 for ; Fri, 21 Oct 2016 20:44:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2757C29F52; Fri, 21 Oct 2016 20:44:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B577A29F31 for ; Fri, 21 Oct 2016 20:44:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933706AbcJUUoN (ORCPT ); Fri, 21 Oct 2016 16:44:13 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:52072 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933651AbcJUUoH (ORCPT ); Fri, 21 Oct 2016 16:44:07 -0400 Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.17/8.16.0.17) with SMTP id u9LKi5Hs026235 for ; Fri, 21 Oct 2016 13:44:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=tJJu699+xoFB4eHHJbMnsDKJbE+Rrge+SUIapsrSnwQ=; b=UoJpNwSJhglA9CffDBNKqJLallF2hFHVaHfrLtnNgOq6h8atZGta56hABS0u6U4ra7wk yXqADohi14YHdWthj/lZCZ83H4lg3J0AtDQEE03cGLlGQDEpWJdBGhozj3Oj4ZlBT/iY DUeH9oE9K7DCHY0iIRxnc++zjfIWmuXsF6A= Received: from mail.thefacebook.com ([199.201.64.23]) by m0089730.ppops.net with ESMTP id 267q1k93vk-4 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 21 Oct 2016 13:44:06 -0700 Received: from mx-out.facebook.com (192.168.52.123) by PRN-CHUB08.TheFacebook.com (192.168.16.18) with Microsoft SMTP Server (TLS) id 14.3.294.0; Fri, 21 Oct 2016 13:35:15 -0700 Received: from facebook.com (2401:db00:21:603d:face:0:19:0) by mx-out.facebook.com (10.212.236.89) with ESMTP id defa7ed297cd11e69a310002c95209d8-30de0a50 for ; Fri, 21 Oct 2016 13:35:14 -0700 Received: by devbig638.prn2.facebook.com (Postfix, from userid 11222) id 3922D42C11F5; Fri, 21 Oct 2016 13:35:14 -0700 (PDT) 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 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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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