mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Yichong Chen <chenyichong@uniontech.com>,
	Muchun Song <muchun.song@linux.dev>,
	Oscar Salvador <osalvador@suse.de>,
	David Hildenbrand <david@kernel.org>,
	Andrew Barry <abarry@cray.com>,
	David Gibson <david@gibson.dropbear.id.au>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hugetlb: fix subpool release race
Date: Mon, 20 Jul 2026 16:27:21 -0700	[thread overview]
Message-ID: <20260720162721.fd07cbcb5625c7ad38725a36@linux-foundation.org> (raw)
In-Reply-To: <20260720143130.516711-1-joshua.hahnjy@gmail.com>

On Mon, 20 Jul 2026 07:31:29 -0700 Joshua Hahn <joshua.hahnjy@gmail.com> wrote:

> Hello Yichong, thank you for the patch!
> 
> > unlock_or_release_subpool() drops spool->lock before checking whether the
> > subpool can be freed.  However, subpool_is_free() reads fields that are
> > updated under spool->lock, including count, used_hpages and rsv_hpages.
> > 
> > Another thread can update those fields before the first thread evaluates
> > subpool_is_free(), allowing both threads to observe the final freeable
> > state and release the subpool.
> 
> I don't think that the race you are mentioning can be hit in practice (i.e.
> there is no user-visible change for this) since two threads cannot actually
> observe the freeable state at the same time.
> 
> subpool_is_free() does an early exit on spool->count so it will never reach
> the inside if block and have two threads try to decrement the
> spool->hstate and free the spool twice. I'm wondering if we need the Fixes
> tag in this case.
> 
> I do think that this is not obvious though, so having the subpool_is_free
> check inside the locked section makes sense to me too.
> 
> Reviewed-by: Joshua Hahn <joshua.hahnjy@gmail.com>

Thanks.  Yichong, can you please consider Joshua's observations and
perhaps resend with a more accurate changelog?

      reply	other threads:[~2026-07-20 23:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20  8:50 Yichong Chen
2026-07-20 14:31 ` Joshua Hahn
2026-07-20 23:27   ` Andrew Morton [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=20260720162721.fd07cbcb5625c7ad38725a36@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=abarry@cray.com \
    --cc=chenyichong@uniontech.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=david@kernel.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --cc=osalvador@suse.de \
    /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

all inboxes | Powered by JetHome®