linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Jinjiang Tu <tujinjiang@huawei.com>,
	akpm@linux-foundation.org, muchun.song@linux.dev,
	osalvador@suse.de
Cc: linux-mm@kvack.org, wangkefeng.wang@huawei.com, sunnanyong@huawei.com
Subject: Re: [PATCH] mm/hugetlb: fix surplus pages in dissolve_free_huge_page()
Date: Mon, 3 Mar 2025 12:47:48 +0100	[thread overview]
Message-ID: <15add3ed-8b0e-4d12-8c91-225bb23df828@redhat.com> (raw)
In-Reply-To: <21afe09a-8f79-45ad-1b23-7fcb67218ea2@huawei.com>

On 03.03.25 12:23, Jinjiang Tu wrote:
> 
> 在 2025/3/3 19:16, Jinjiang Tu 写道:
>>
>> 在 2025/3/3 18:25, David Hildenbrand 写道:
>>> On 03.03.25 07:09, Jinjiang Tu wrote:
>>>> In dissolve_free_huge_page(), free huge pages are dissolved without
>>>> adjusting surplus count. However, free huge pages may be accounted as
>>>> surplus pages, and will lead to wrong surplus count.
>>>>
>>>> Steps to reproduce:
>>>> 1) create 64 huge pages for node1
>>>> 2) run a program to reserve (don't consume) all the huge pages
>>>> 3) echo 0 > nr_huge_pages for node1. After this step, free huge
>>>> pages in
>>>> Node1 are surplus.
>>>> 4) create 80 huge pages for node0
>>>> 5) offline memory of node1 and kill the program in step 2)
>>>
>>> Can you elaborate the "offline memory" part? How much are you
>>> offlining (the complete node vs a single memory block?)
>> I reproduce this issue on qemu. The memory onlining and offlining
>> operations are:
>>
>> 1)Node1 is memory-less at first. Hot-add memory to node1 by executing
>> the two commands in qemu monitor
>> object_add memory-backend-ram,id=mem1,size=1G
>> device_add pc-dimm,id=dimm1,memdev=mem1,node=1
>>
>> 2)online one memory block of Node1 with:
>> echo online_movable > /sys/devices/system/node/node1/memoryX/state
>>
>> 3) offline the memory block of Node1 with:
>> echo offline > /sys/devices/system/node/node1/memoryX/state
> The memory range to offline contains the free surplus huge pages created
> in step1) ~ step3)

Okay, that makes it a lot clearer. Can you make that clearer in the 
patch description?

The problem appears when memory offlining stumbles over a free hugetlb 
folio. We'll call 
dissolve_free_hugetlb_folios()->dissolve_free_hugetlb_folio() to 
dissolve it, but don't adjust accounting with surplus pages properly.

I'll note that there is another dissolve_free_hugetlb_folio() caller in 
the memory-failure path that might similarly be affected.

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2025-03-03 11:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-03  6:09 Jinjiang Tu
2025-03-03 10:25 ` David Hildenbrand
2025-03-03 11:16   ` Jinjiang Tu
2025-03-03 11:23     ` Jinjiang Tu
2025-03-03 11:47       ` David Hildenbrand [this message]
2025-03-03 12:10         ` Jinjiang Tu
2025-03-03 13:45 ` David Hildenbrand
2025-03-04  3:50   ` Jinjiang Tu
2025-03-04 10:15     ` David Hildenbrand

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=15add3ed-8b0e-4d12-8c91-225bb23df828@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --cc=osalvador@suse.de \
    --cc=sunnanyong@huawei.com \
    --cc=tujinjiang@huawei.com \
    --cc=wangkefeng.wang@huawei.com \
    /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