Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hongfu Li <hongfu.li@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: hongfu.li@linux.dev, hughd@google.com,
	baolin.wang@linux.alibaba.com, vivek.kasireddy@intel.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Hongfu Li <lihongfu@kylinos.cn>
Subject: Re: [PATCH] mm/memfd: don't unreserve hugetlb pages on -EEXIST in error path
Date: Tue, 1 Sep 2026 17:01:10 +0800	[thread overview]
Message-ID: <017b391d-2687-48f4-938f-b23a5b116690@linux.dev> (raw)
In-Reply-To: <20260831173513.41184f1d27cd83f2c8f9b935@linux-foundation.org>


On 9/1/26 8:35 AM, Andrew Morton wrote:
> On Mon, 31 Aug 2026 17:06:31 +0800 Hongfu Li <hongfu.li@linux.dev> wrote:
>
>> From: Hongfu Li <lihongfu@kylinos.cn>
>>
>> If hugetlb_add_to_page_cache() fails with -EEXIST, a concurrent fault has
>> already instantiated the folio in the page cache, and the reservation now
>> belongs to that folio. Calling hugetlb_unreserve_pages() in that case
>> incorrectly removes the region backing the cached folio, and a later
>> truncate or inode eviction passes a negative (chg - freed) into
>> hugepage_subpool_put_pages(), corrupting subpool and resv_huge_pages
>> accounting.
>>
>> Skip the unreserve on -EEXIST; failures other than -EEXIST leave the
>> reservation unconsumed and still unreserve it.
> Thanks.
>
> AI review might have found another bug and it suggests that your
> proposal only partially fixes this bug:
>
> 	https://sashiko.dev/#/patchset/20260831090631.29227-1-hongfu.li@linux.dev

Thank you for the reminder.

I have carefully gone through the Sashiko review report.
The issue it pointed out is valid. I will address this
remaining problem and send out a v2 patch shortly.

-- 
Best regards,
Hongfu



      reply	other threads:[~2026-09-01  9:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31  9:06 [PATCH] mm/memfd: don't unreserve hugetlb pages on -EEXIST in error path Hongfu Li
2026-09-01  0:35 ` Andrew Morton
2026-09-01  9:01   ` Hongfu Li [this message]

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=017b391d-2687-48f4-938f-b23a5b116690@linux.dev \
    --to=hongfu.li@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=hughd@google.com \
    --cc=lihongfu@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=vivek.kasireddy@intel.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