[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ec379097-ab86-4bd0-8b6c-7611b3cf9194@huawei.com>
Date: Thu, 10 Apr 2025 08:51:00 +0800
From: mawupeng <mawupeng1@...wei.com>
To: <joshua.hahnjy@...il.com>
CC: <mawupeng1@...wei.com>, <akpm@...ux-foundation.org>,
<mike.kravetz@...cle.com>, <david@...hat.com>, <muchun.song@...ux.dev>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH] mm: hugetlb: Fix incorrect fallback for subpool
On 2025/4/9 21:58, Joshua Hahn wrote:
> On Tue, 25 Mar 2025 14:16:34 +0800 Wupeng Ma <mawupeng1@...wei.com> wrote:
>
>> During our testing with hugetlb subpool enabled, we observe that
>> hstate->resv_huge_pages may underflow into negative values. Root cause
>> analysis reveals a race condition in subpool reservation fallback handling
>> as follow:
>>
>> hugetlb_reserve_pages()
>> /* Attempt subpool reservation */
>> gbl_reserve = hugepage_subpool_get_pages(spool, chg);
>>
>> /* Global reservation may fail after subpool allocation */
>> if (hugetlb_acct_memory(h, gbl_reserve) < 0)
>> goto out_put_pages;
>>
>> out_put_pages:
>> /* This incorrectly restores reservation to subpool */
>> hugepage_subpool_put_pages(spool, chg);
>>
>> When hugetlb_acct_memory() fails after subpool allocation, the current
>> implementation over-commits subpool reservations by returning the full
>> 'chg' value instead of the actual allocated 'gbl_reserve' amount. This
>> discrepancy propagates to global reservations during subsequent releases,
>> eventually causing resv_huge_pages underflow.
>>
>> This problem can be trigger easily with the following steps:
>> 1. reverse hugepage for hugeltb allocation
>> 2. mount hugetlbfs with min_size to enable hugetlb subpool
>> 3. alloc hugepages with two task(make sure the second will fail due to
>> insufficient amount of hugepages)
>> 4. with for a few seconds and repeat step 3 which will make
>> hstate->resv_huge_pages to go below zero.
>>
>> To fix this problem, return corrent amount of pages to subpool during the
>> fallback after hugepage_subpool_get_pages is called.
>>
>> Fixes: 1c5ecae3a93f ("hugetlbfs: add minimum size accounting to subpools")
>> Signed-off-by: Wupeng Ma <mawupeng1@...wei.com>
>> ---
>
> Hi Wupeng,
>
> I hope you are doing well! It's been a while since this fix was sent in, and
> there hasn't been any comments on the test either. Would you consider sending
> this patch again without the RFC tag? I think that might help in the way of
> moving this patch forward : -)
Ok, I'll resend it without the RFC tag.
>
> Thank you again for this fix! Have a great day!
> Joshua
Powered by blists - more mailing lists