From mboxrd@z Thu Jan 1 00:00:00 1970 From: Josef Bacik Subject: [PATCH 2/8] inode: add hlist_fake to avoid the inode hash lock in evict Date: Tue, 23 Jun 2015 20:23:56 -0700 Message-ID: <1435116242-27495-3-git-send-email-jbacik@fb.com> References: <1435116242-27495-1-git-send-email-jbacik@fb.com> Mime-Version: 1.0 Content-Type: text/plain To: , , , , , Return-path: Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:39971 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752667AbbFXDYg (ORCPT ); Tue, 23 Jun 2015 23:24:36 -0400 In-Reply-To: <1435116242-27495-1-git-send-email-jbacik@fb.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Some filesystems don't use the VFS inode hash and fake the fact they are hashed so that all the writeback code works correctly. However, this means the evict() path still tries to remove the inode from the hash, meaning that the inode_hash_lock() needs to be taken unnecessarily. Hence under certain workloads the inode_hash_lock can be contended even if the inode is never actually hashed. To avoid this add hlist_fake to test if the inode isn't actually hashed to avoid taking the hash lock on inodes that have never been hashed. Based on Dave Chinner's inode: add IOP_NOTHASHED to avoid inode hash lock in evict basd on Al's suggestions. Thanks, Signed-off-by: Josef Bacik Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig Tested-by: Dave Chinner --- include/linux/fs.h | 2 +- include/linux/list.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index b577e80..6d51f47 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2564,7 +2564,7 @@ static inline void insert_inode_hash(struct inode *inode) extern void __remove_inode_hash(struct inode *); static inline void remove_inode_hash(struct inode *inode) { - if (!inode_unhashed(inode)) + if (!inode_unhashed(inode) && !hlist_fake(&inode->i_hash)) __remove_inode_hash(inode); } diff --git a/include/linux/list.h b/include/linux/list.h index feb773c..3e3e64a 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -672,6 +672,11 @@ static inline void hlist_add_fake(struct hlist_node *n) n->pprev = &n->next; } +static inline bool hlist_fake(struct hlist_node *h) +{ + return h->pprev == &h->next; +} + /* * Move a list from one list head to another. Fixup the pprev * reference of the first entry if it exists. -- 2.1.0