linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jinjiang Tu <tujinjiang@huawei.com>
To: David Hildenbrand <david@redhat.com>, <muchun.song@linux.dev>,
	<akpm@linux-foundation.org>, <mel@csn.ul.ie>,
	<lee.schermerhorn@hp.com>, <andi@firstfloor.org>
Cc: <linux-mm@kvack.org>
Subject: Re: [PATCH] mm/hugetlb: fix set_max_huge_pages() when there are surplus pages
Date: Thu, 27 Feb 2025 11:11:25 +0800	[thread overview]
Message-ID: <44267aae-4209-c5d2-9d0a-b9eeb4bd4bf0@huawei.com> (raw)
In-Reply-To: <cb19453c-a7bb-48e0-977c-716fb28be716@redhat.com>


在 2025/2/26 23:57, David Hildenbrand 写道:
> On 25.02.25 15:19, Jinjiang Tu wrote:
>> In set_max_huge_pages(), min_count should mean the acquired persistent
>> huge pages, but it contains surplus huge pages. It will leads to failing
>
> s/leads/lead/
>
>> to freeing free huge pages for a Node.
>>
>> Steps to reproduce:
>> 1) create 5 huge pages in Node 0
>> 2) run a program to use all the huge pages
>> 3) create 5 huge pages in Node 1
>> 4) echo 0 > nr_hugepages for Node 1 to free the huge pages
>>
>> The result:
>>          Node 0    Node 1
>> Total     5         5
>> Free      0         5
>> Surp      5         5
>
> Can you also share the results after your change?
With this patch, step 4) destroys the 5 huge pages in Node 1

The result with this patch:
          Node 0    Node 1
Total     5             0
Free      0             0
Surp     5             0
>
>
>>
>> Fixes: 9a30523066cd ("hugetlb: add per node hstate attributes")
>> Signed-off-by: Jinjiang Tu <tujinjiang@huawei.com>
>> ---
>>   mm/hugetlb.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
>> index 163190e89ea1..783faec7360b 100644
>> --- a/mm/hugetlb.c
>> +++ b/mm/hugetlb.c
>> @@ -3758,7 +3758,7 @@ static int set_max_huge_pages(struct hstate *h, 
>> unsigned long count, int nid,
>>        * and won't grow the pool anywhere else. Not until one of the
>>        * sysctls are changed, or the surplus pages go out of use.
>>        */
>> -    min_count = h->resv_huge_pages + h->nr_huge_pages - 
>> h->free_huge_pages;
>> +    min_count = h->resv_huge_pages + persistent_huge_pages(h) - 
>> h->free_huge_pages;
>>       min_count = max(count, min_count);
>>       try_to_free_low(h, min_count, nodes_allowed);
>
>


  reply	other threads:[~2025-02-27  3:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 14:19 Jinjiang Tu
2025-02-26 15:57 ` David Hildenbrand
2025-02-27  3:11   ` Jinjiang Tu [this message]
2025-02-27  6:19     ` Oscar Salvador
2025-02-27  7:06       ` Jinjiang Tu
2025-03-04 13:44       ` Jinjiang Tu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44267aae-4209-c5d2-9d0a-b9eeb4bd4bf0@huawei.com \
    --to=tujinjiang@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=david@redhat.com \
    --cc=lee.schermerhorn@hp.com \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    --cc=muchun.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox