From patchwork Tue Oct 25 18:41:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9395211 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 7DE8D6077F for ; Tue, 25 Oct 2016 18:42:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 729DB29711 for ; Tue, 25 Oct 2016 18:42:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6734229715; Tue, 25 Oct 2016 18:42:56 +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 C12A129714 for ; Tue, 25 Oct 2016 18:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759436AbcJYSmu (ORCPT ); Tue, 25 Oct 2016 14:42:50 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:48841 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759451AbcJYSmn (ORCPT ); Tue, 25 Oct 2016 14:42:43 -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 u9PIcHOs009832; Tue, 25 Oct 2016 11:42:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=D2zbywcYukyQiMRRVNMhHOsPNGJRQhlu2JQbubCbHmY=; b=TPKa5NzacQV5ftGz4DdcZ7Cd+CDSB+0+zayXixGUvWRtVYgG3jbUJpXKPV8rnvJ32Gym 1IDSXI3hhOBYV/Gm+5CNLzGQIyeU2scj5U4J3s2kNGrb+MAP+UMe46YTkS/nPkdobz/W P5Clnzc7ifJ+zfAxj/d1RLHQ75xljHvRJMo= Received: from maileast.thefacebook.com ([199.201.65.23]) by m0089730.ppops.net with ESMTP id 26abjggvp0-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 25 Oct 2016 11:42:14 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.24) with Microsoft SMTP Server (TLS) id 14.3.294.0; Tue, 25 Oct 2016 14:42:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=mKfB7UAj6UDJWhLbo9DpLvKuCbIktCwDAhvu8xjmyCA=; b=B2+eC5PD/dtFcbBG0IPbIJRqCCsHV82KV8R3JedChcz44ejVA+mGLTINSku/Do9lNT43am8WD+wPsLZCVkK4uZUDxAV9cBNN1RFZZmDarOfQeBi8MIXUViQB4ZS5TUlkhsjM8fjl56NtLo6zjz+PuMcc4Ch0N+vBkEFDzn7/gKQ= Received: from localhost (2606:a000:4381:1201:225:22ff:feb3:e51a) by DM5PR15MB1324.namprd15.prod.outlook.com (10.173.210.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Tue, 25 Oct 2016 18:42:12 +0000 From: Josef Bacik To: , , , , , , , Subject: [PATCH 5/5] fs: don't set *REFERENCED unless we are on the lru list Date: Tue, 25 Oct 2016 14:41:44 -0400 Message-ID: <1477420904-1399-6-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477420904-1399-1-git-send-email-jbacik@fb.com> References: <1477420904-1399-1-git-send-email-jbacik@fb.com> MIME-Version: 1.0 X-Originating-IP: [2606:a000:4381:1201:225:22ff:feb3:e51a] X-ClientProxiedBy: BN6PR12CA0010.namprd12.prod.outlook.com (10.168.222.20) To DM5PR15MB1324.namprd15.prod.outlook.com (10.173.210.14) X-MS-Office365-Filtering-Correlation-Id: 294ae0b1-f68e-45c6-c039-08d3fd06a240 X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1324; 2:nMCdevljRHvMpZOzmMmyprEL3eT8fTEjANukx25WB1N6OjMRa8NzUaZHB++X3/kBh+3alKg2iioFhpPzz6lq7inAXdn1J8FYRFhOgv28TPkZbYnU49p+fBMkwlEcGF6NNJfNrBsZhQA4ntLRp+EbyU66PnQDneJ2TgoNulORKh/3H1hhTnWpBoGXpp6aQsVr6Asj3w5KOORh5WJRBu1gkg==; 3:dZRKbtA3fcBjY0vJ/0ubbxgbfGVd7HvkOFAHrOaGTlYLZDZXNpVlVtzomB3YTnDz5CrbtH63vBm4tWL5TDowOGaufI5VDKmunZswAE7kMBpzxipPyPN6Gb8lktLKfW30xs6VRkig7zh2hLWyWMcvZA==; 25:Q0g0f/1z3c2WIBRspOZrEoKhCTcRZ2CmJ4ciGAnSRunaVxzqWas1mfHO9lIbnRJGaU9rk+ezxuS6zPWLIbQiSX3V04BApK+1qGC7lIqF/MnITXjj5SAxf5jZoZ5n7uBd9AD5BmImznhYN4nQxfYUDhio6El/93ufFmY+KNhu8g+bVI8GNd1t4yAJgX2rfEAl40u0/hIR6toLkd4oMm1M5LLqrAyf3wgVejrPYr1AO0Z995dtdRhwxj2hMYH8t34yrK58ZZFp7odkX9CQCr007C0r+rpaalMWuCkKKmta/syPjrnSsPlYcIXL7IcCjTpo7b8xRK65wHMiWC7Eu6TugGTWuzgpZbXwMR8vVZ3W2dSJ2P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6KgeDHl8s0g3g2O9v/qScQQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:DM5PR15MB1324; BCL:0; PCL:0; RULEID:; SRVR:DM5PR15MB1324; X-Forefront-PRVS: 01068D0A20 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(189002)(199003)(5001770100001)(97736004)(305945005)(50466002)(5660300001)(36756003)(48376002)(229853001)(101416001)(76506005)(76176999)(42186005)(105586002)(50986999)(189998001)(6116002)(107886002)(7846002)(7736002)(5003940100001)(586003)(33646002)(2906002)(19580395003)(6636002)(6666003)(106356001)(68736007)(19580405001)(92566002)(77096005)(81156014)(2201001)(81166006)(8676002)(86362001)(47776003)(2950100002)(50226002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR15MB1324; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR15MB1324; 23:vStSVYMW/HZ95W+TxeI0ZLVXArxn6j0g51L+/H2ey?= =?us-ascii?Q?E0mpdoCX6Id/QB+QmaiLDrMZbIMbQeRLNTDHOQ+QfnF7GQFV8+vG86iVPgng?= =?us-ascii?Q?hwQGQgyEX6sQodRCksj3zDckGuJ50skBXezFO71UH+gmBK+mlXLDTQFBF+16?= =?us-ascii?Q?L6o2D3AWdyQSiDD4f1ihfOQJ1Tx3hJIEr6tM0Nl4uV3++wb8DtUjTT7ROjmt?= =?us-ascii?Q?QbEoldpjUSBjQ5qfjHPf53rirpdKa+fWSyAAgakuNJSyMdv0AR5yZwhzNSc+?= =?us-ascii?Q?YfJiji1jRtCtP1kHW62YFw5QE4u222ZUCzbUoazpqmkKh8EjJigSRZdZ0xaP?= =?us-ascii?Q?e/5VVwOR06arzFUZ9ImrH22g8xJOGvHouuHkE4jTTGZ6JUQb3bwXdjEMPB+n?= =?us-ascii?Q?J3M1b+kcY5tHgIcWu74YiUWJPNjUeKisfqDrpVXCSxdPWcy8GbRW2nAfBo7G?= =?us-ascii?Q?37qaUZ6m9x/vb+XPZpm58NQYbzU0eYToxXHhvI5/MkUs5h+eBEwGZm+/OGFu?= =?us-ascii?Q?HI+nCZXJknuQPEvA9K84j73++gF902f0M6W74sN3zTJ9SkC3b+usW5tyMRye?= =?us-ascii?Q?e3M/Yu8vCh0FPl3qfpQeZEGFIjrztglGKuw75B91dt+dygsu7UfN/Fvq+HUD?= =?us-ascii?Q?TLzyVcPC8mEN0/8Iqu2ADzjODeXn0jPG/8nGesQcj0mH8P+IEz0ELkN3rbQS?= =?us-ascii?Q?5Zrrw4jn9f7mszJ5/qobEozb8bNFZfZdzsn0ADWCp79BExH2qBWI0RY4FuF1?= =?us-ascii?Q?apXi3f1KBxIpLyOzPRonEuWmN5GFUT3huasFDJ2zZPRvWot6u12dll0BNsNA?= =?us-ascii?Q?i2F2HIToCFvl1cFkLxKpTptnW0p7vA3pC7UZUpiTI3xl2Rpkaw8YkI5IszHD?= =?us-ascii?Q?emzZvaYRbU+jQHReFFWhUDIlnxpRoB81kxMYfGErGGlAmvDWnNkomjgH+O6s?= =?us-ascii?Q?KnLdTI5ZEdYN8h/5Zr+lksQforFo/UrTMpRp8kR1A85eXCufTet1xx+tlHB7?= =?us-ascii?Q?UKauPJgVLsZdCXnkDqnZttbkQyFV8E2/Yl1FOXBgz9UBvIF6YvCuf/B3lgdi?= =?us-ascii?Q?Id9alu4o5aBmQiM5K3sueebhgLPy3TLUI+ry9z2S7AVWG2mVFzBFpdu+XMlt?= =?us-ascii?Q?MXp+G/oI2z80daSvprKic+cysNm8b/I?= X-Microsoft-Exchange-Diagnostics: 1; DM5PR15MB1324; 6:hUfJ0oKbtsGIFqD771NEcpJ4XyW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kqpiUu4hVjVhEO1WMU2XEW3GRzN8+n5ofGTBRI74yRfYp6m10Xp8NSoFt84LLZoUFhRX5bepfXPnWJVlbATPNvQlEUxuYPeNyy9lzhFyY2TxYo81wk= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2016 18:42:12.1524 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR15MB1324 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-10-25_17:, , 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 With anything that populates the inode/dentry cache with a lot of one time use inodes we can really put a lot of pressure on the system for things we don't need to keep in cache. It takes two runs through the LRU to evict these one use entries, and if you have a lot of memory you can end up with 10's of millions of entries in the dcache or icache that have never actually been touched since they were first instantiated, and it will take a lot of CPU and a lot of pressure to evict all of them. So instead do what we do with pagecache, only set the *REFERENCED flags if we are being used after we've been put onto the LRU. This makes a significant difference in the system's ability to evict these useless cache entries. With a fs_mark workload that creates 40 million files we get the following results (all in files/sec) Btrfs Patched Unpatched Average Files/sec: 72209.3 63254.2 p50 Files/sec: 70850 57560 p90 Files/sec: 68757 53085 p99 Files/sec: 68757 53085 XFS Patched Unpatched Average Files/sec: 61025.5 60719.5 p50 Files/sec: 60107 59465 p90 Files/sec: 59300 57966 p99 Files/sec: 59227 57528 Ext4 Patched Unpatched Average Files/sec: 121785.4 119248.0 p50 Files/sec: 120852 119274 p90 Files/sec: 116703 112783 p99 Files/sec: 114393 104934 The reason Btrfs has a much larger improvement is because it holds a lot more things in memory so benefits more from faster slab reclaim, but across the board is an improvement for each of the file systems. Signed-off-by: Josef Bacik --- fs/dcache.c | 15 ++++++++++----- fs/inode.c | 5 ++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 5c7cc95..a558075 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -779,8 +779,6 @@ repeat: goto kill_it; } - if (!(dentry->d_flags & DCACHE_REFERENCED)) - dentry->d_flags |= DCACHE_REFERENCED; dentry_lru_add(dentry); dentry->d_lockref.count--; @@ -803,6 +801,13 @@ static inline void __dget_dlock(struct dentry *dentry) dentry->d_lockref.count++; } +static inline void __dget_dlock_reference(struct dentry *dentry) +{ + if (dentry->d_flags & DCACHE_LRU_LIST) + dentry->d_flags |= DCACHE_REFERENCED; + dentry->d_lockref.count++; +} + static inline void __dget(struct dentry *dentry) { lockref_get(&dentry->d_lockref); @@ -875,7 +880,7 @@ again: (alias->d_flags & DCACHE_DISCONNECTED)) { discon_alias = alias; } else { - __dget_dlock(alias); + __dget_dlock_reference(alias); spin_unlock(&alias->d_lock); return alias; } @@ -886,7 +891,7 @@ again: alias = discon_alias; spin_lock(&alias->d_lock); if (S_ISDIR(inode->i_mode) || !d_unhashed(alias)) { - __dget_dlock(alias); + __dget_dlock_reference(alias); spin_unlock(&alias->d_lock); return alias; } @@ -2250,7 +2255,7 @@ struct dentry *__d_lookup(const struct dentry *parent, const struct qstr *name) if (!d_same_name(dentry, parent, name)) goto next; - dentry->d_lockref.count++; + __dget_dlock_reference(dentry); found = dentry; spin_unlock(&dentry->d_lock); break; diff --git a/fs/inode.c b/fs/inode.c index 7e3ef3a..5937d3a 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -796,6 +796,8 @@ repeat: __wait_on_freeing_inode(inode); goto repeat; } + if (!list_empty(&inode->i_lru)) + inode->i_state |= I_REFERENCED; __iget(inode); spin_unlock(&inode->i_lock); return inode; @@ -823,6 +825,8 @@ repeat: __wait_on_freeing_inode(inode); goto repeat; } + if (!list_empty(&inode->i_lru)) + inode->i_state |= I_REFERENCED; __iget(inode); spin_unlock(&inode->i_lock); return inode; @@ -1463,7 +1467,6 @@ static void iput_final(struct inode *inode) drop = generic_drop_inode(inode); if (!drop && (sb->s_flags & MS_ACTIVE)) { - inode->i_state |= I_REFERENCED; inode_add_lru(inode); spin_unlock(&inode->i_lock); return;