[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210316022758.52993-1-linmiaohe@huawei.com>
Date: Mon, 15 Mar 2021 22:27:58 -0400
From: Miaohe Lin <linmiaohe@...wei.com>
To: <akpm@...ux-foundation.org>, <mike.kravetz@...cle.com>
CC: <linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
<linmiaohe@...wei.com>
Subject: [PATCH v2 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in truncate_op case
The fault_mutex hashing overhead can be avoided in truncate_op case
because page faults can not race with truncation in this routine. So
calculate hash for fault_mutex only in !truncate_op case to save some cpu
cycles.
Reviewed-by: Mike Kravetz <mike.kravetz@...cle.com>
Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
Cc: Mike Kravetz <mike.kravetz@...cle.com>
---
v1->v2:
remove unnecessary initialization for variable hash
collect Reviewed-by tag from Mike Kravetz
---
fs/hugetlbfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index c262566f7c5d..f7ec94bc7337 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -485,7 +485,6 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
u32 hash;
index = page->index;
- hash = hugetlb_fault_mutex_hash(mapping, index);
if (!truncate_op) {
/*
* Only need to hold the fault mutex in the
@@ -493,6 +492,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
* page faults. Races are not possible in the
* case of truncation.
*/
+ hash = hugetlb_fault_mutex_hash(mapping, index);
mutex_lock(&hugetlb_fault_mutex_table[hash]);
}
--
2.19.1
Powered by blists - more mailing lists