Skip to content

Commit

Permalink
mm/hugetlb: avoid unnecessary hugetlb_acct_memory() call
Browse files Browse the repository at this point in the history
When reservation accounting remains unchanged, 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.

Link: https://lkml.kernel.org/r/20210115092013.61012-1-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Miaohe Lin authored and Linus Torvalds committed Feb 24, 2021
1 parent a1ba9da commit 0aa7f35
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0aa7f35

Please sign in to comment.