[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210115092013.61012-1-linmiaohe@huawei.com>
Date: Fri, 15 Jan 2021 04:20:13 -0500
From: Miaohe Lin <linmiaohe@...wei.com>
To: <akpm@...ux-foundation.org>, <mike.kravetz@...cle.com>
CC: <david@...hat.com>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>, <linmiaohe@...wei.com>
Subject: [PATCH v2] mm/hugetlb: avoid unnecessary hugetlb_acct_memory() call
When gbl_reserve is 0, hugetlb_acct_memory() will do nothing except holding
and releasing hugetlb_lock. We should avoid this unnecessary hugetlb_lock
lock/unlock cycle which is happening on 'most' hugetlb munmap operations by
check delta against 0 at the beginning of hugetlb_acct_memory.
Reviewed-by: David Hildenbrand <david@...hat.com>
Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
---
mm/hugetlb.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 4f67f6b159c7..da064cb8fd53 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3591,6 +3591,9 @@ static int hugetlb_acct_memory(struct hstate *h, long delta)
{
int ret = -ENOMEM;
+ if (!delta)
+ return 0;
+
spin_lock(&hugetlb_lock);
/*
* When cpuset is configured, it breaks the strict hugetlb page
--
2.19.1
Powered by blists - more mailing lists