linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Oscar Salvador <osalvador@suse.de>
To: Peter Xu <peterx@redhat.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Breno Leitao <leitao@debian.org>, Rik van Riel <riel@surriel.com>,
	Muchun Song <muchun.song@linux.dev>,
	Naoya Horiguchi <nao.horiguchi@gmail.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Ackerley Tng <ackerleytng@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v2 3/7] mm/hugetlb: Rename avoid_reserve to cow_from_owner
Date: Thu, 16 Jan 2025 11:15:09 +0100	[thread overview]
Message-ID: <Z4jcLWSLX4k-XYlg@localhost.localdomain> (raw)
In-Reply-To: <Z4U9Dy-2hnHpCBog@x1n>

On Mon, Jan 13, 2025 at 11:19:27AM -0500, Peter Xu wrote:
> Oscar,
> 
> On Mon, Jan 13, 2025 at 12:20:34PM +0100, Oscar Salvador wrote:
> > On Tue, Jan 07, 2025 at 03:39:58PM -0500, Peter Xu wrote:
> > > The old name "avoid_reserve" can be too generic and can be used wrongly in
> > > the new call sites that want to allocate a hugetlb folio.
> > > 
> > > It's confusing on two things: (1) whether one can opt-in to avoid global
> > > reservation, and (2) whether it should take more than one count.
> > > 
> > > In reality, this flag is only used in an extremely hacky path, in an
> > > extremely hacky way in hugetlb CoW path only, and always use with 1 saying
> > > "skip global reservation".  Rename the flag to avoid future abuse of this
> > > flag, making it a boolean so as to reflect its true representation that
> > > it's not a counter.  To make it even harder to abuse, add a comment above
> > > the function to explain it.
> > > 
> > > Signed-off-by: Peter Xu <peterx@redhat.com>
> > 
> > I agree that the current name is quite misleading, and this patch
> > improves the situation substantially.
> > The only thing I am missing here is that the comment you added could be
> > more explanatory as to why new call sites do not want to make use of the
> > flag.
> > 
> > IIRC, not using so, will bypass all vma level reservations as you
> 
> s/not using/using/?  Only using the flag (setting to true) will bypass vma,
> but I could have misunderstood this line..

Yes, sorry.

> > mentioned, which means that the child can get killed if the parent
> > makes use of the page, as it is the parent the only one that made a
> > reservation.
> 
> The paragraph I added on top of alloc_hugetlb_folio() is trying to suggest
> nobody should set this to true in any new paths.

Yes, you are right.
I thought we could be more categoric, but curent comment seems fine.

> So far, the reservation path should have nothing relevant to stealing page
> on its own (if that is what you meant above..) - page stealing in hugetlb
> private is done separately within the unmap_ref_private() helper.  Here the
> parent needs to bypass vma reservation because it must have consumed it
> with the folio installed in the pgtable (which is write-protected).  That
> may or may not be relevant to page stealing, e.g. if global pool still has
> free page it doesn't need to affect child from using its hugetlb pages.

No, I kind of misinterpreted this.

Now, let me see if I get this straight:

1) parent maps a hugetlb page, but not yet fault in.
2) forks, child faults-in the page
3) child doesn't have any reservation, when 'cow_from_owner' set to true
   we check whether we have a spare hugetlb page to satisfy that
4) parent faults in the page
5) we do not have spare hugetlb pages, so we 'steal' it from the child
   with unmap_ref_private.


Is my understanding correct?

-- 
Oscar Salvador
SUSE Labs


  reply	other threads:[~2025-01-16 10:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-07 20:39 [PATCH v2 0/7] mm/hugetlb: Refactor hugetlb allocation resv accounting Peter Xu
2025-01-07 20:39 ` [PATCH v2 1/7] mm/hugetlb: Fix avoid_reserve to allow taking folio from subpool Peter Xu
2025-01-13 11:02   ` Oscar Salvador
2025-01-07 20:39 ` [PATCH v2 2/7] mm/hugetlb: Stop using avoid_reserve flag in fork() Peter Xu
2025-01-13 11:05   ` Oscar Salvador
2025-01-07 20:39 ` [PATCH v2 3/7] mm/hugetlb: Rename avoid_reserve to cow_from_owner Peter Xu
2025-01-13 11:20   ` Oscar Salvador
2025-01-13 16:19     ` Peter Xu
2025-01-16 10:15       ` Oscar Salvador [this message]
2025-01-16 14:26         ` Peter Xu
2025-01-07 20:39 ` [PATCH v2 4/7] mm/hugetlb: Clean up map/global resv accounting when allocate Peter Xu
2025-01-13 22:57   ` Ackerley Tng
2025-01-14 18:25     ` Peter Xu
2025-01-07 20:40 ` [PATCH v2 5/7] mm/hugetlb: Simplify vma_has_reserves() Peter Xu
2025-01-07 20:40 ` [PATCH v2 6/7] mm/hugetlb: Drop vma_has_reserves() Peter Xu
2025-01-07 20:40 ` [PATCH v2 7/7] mm/hugetlb: Unify restore reserve accounting for new allocations Peter Xu

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=Z4jcLWSLX4k-XYlg@localhost.localdomain \
    --to=osalvador@suse.de \
    --cc=ackerleytng@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --cc=nao.horiguchi@gmail.com \
    --cc=peterx@redhat.com \
    --cc=riel@surriel.com \
    --cc=roman.gushchin@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