* [PATCH v2] mm/hugetlb: avoid unnecessary hugetlb_acct_memory() call
@ 2021-01-15 9:20 Miaohe Lin
2021-01-15 9:28 ` Oscar Salvador
0 siblings, 1 reply; 4+ messages in thread
From: Miaohe Lin @ 2021-01-15 9:20 UTC (permalink / raw)
To: akpm, mike.kravetz; +Cc: david, linux-mm, linux-kernel, linmiaohe
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@redhat.com>
Signed-off-by: Miaohe Lin <linmiaohe@huawei.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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] mm/hugetlb: avoid unnecessary hugetlb_acct_memory() call
2021-01-15 9:20 [PATCH v2] mm/hugetlb: avoid unnecessary hugetlb_acct_memory() call Miaohe Lin
@ 2021-01-15 9:28 ` Oscar Salvador
2021-01-15 9:44 ` Miaohe Lin
0 siblings, 1 reply; 4+ messages in thread
From: Oscar Salvador @ 2021-01-15 9:28 UTC (permalink / raw)
To: Miaohe Lin; +Cc: akpm, mike.kravetz, david, linux-mm, linux-kernel
On Fri, Jan 15, 2021 at 04:20:13AM -0500, Miaohe Lin wrote:
> 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@redhat.com>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
I would avoid mentioning gbl_reserve as not all callers use it, and focus
on what delta means:
"When reservation accounting remains unchanged..", but anyway:
Reviewed-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE L3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] mm/hugetlb: avoid unnecessary hugetlb_acct_memory() call
2021-01-15 9:28 ` Oscar Salvador
@ 2021-01-15 9:44 ` Miaohe Lin
2021-01-19 17:44 ` Mike Kravetz
0 siblings, 1 reply; 4+ messages in thread
From: Miaohe Lin @ 2021-01-15 9:44 UTC (permalink / raw)
To: Oscar Salvador, Andrew Morton; +Cc: mike.kravetz, david, linux-mm, linux-kernel
Hi:
On 2021/1/15 17:28, Oscar Salvador wrote:
> On Fri, Jan 15, 2021 at 04:20:13AM -0500, Miaohe Lin wrote:
>> 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@redhat.com>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>
> I would avoid mentioning gbl_reserve as not all callers use it, and focus
> on what delta means:
>
> "When reservation accounting remains unchanged..", but anyway:
Sounds good. Maybe Andrew could kindly do this if this patch is picked up ?
>
> Reviewed-by: Oscar Salvador <osalvador@suse.de>
>
>
Many thanks for your review.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] mm/hugetlb: avoid unnecessary hugetlb_acct_memory() call
2021-01-15 9:44 ` Miaohe Lin
@ 2021-01-19 17:44 ` Mike Kravetz
0 siblings, 0 replies; 4+ messages in thread
From: Mike Kravetz @ 2021-01-19 17:44 UTC (permalink / raw)
To: Miaohe Lin, Oscar Salvador, Andrew Morton; +Cc: david, linux-mm, linux-kernel
On 1/15/21 1:44 AM, Miaohe Lin wrote:
> Hi:
>
> On 2021/1/15 17:28, Oscar Salvador wrote:
>> On Fri, Jan 15, 2021 at 04:20:13AM -0500, Miaohe Lin wrote:
>>> 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@redhat.com>
>>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>>
>> I would avoid mentioning gbl_reserve as not all callers use it, and focus
>> on what delta means:
>>
>> "When reservation accounting remains unchanged..", but anyway:
>
> Sounds good. Maybe Andrew could kindly do this if this patch is picked up ?
Thank you and Andrew.
Looks like Andrew updated the commit message and added to his tree.
--
Mike Kravetz
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-01-19 22:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-15 9:20 [PATCH v2] mm/hugetlb: avoid unnecessary hugetlb_acct_memory() call Miaohe Lin
2021-01-15 9:28 ` Oscar Salvador
2021-01-15 9:44 ` Miaohe Lin
2021-01-19 17:44 ` Mike Kravetz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).