linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: David Hildenbrand <david@redhat.com>,
	Matthew Wilcox <willy@infradead.org>,
	Jane Chu <jane.chu@oracle.com>
Cc: linux-mm@kvack.org
Subject: Re: updated documentation: Splitting pinned folios
Date: Thu, 14 Mar 2024 10:51:12 -0700	[thread overview]
Message-ID: <280792da-8ad3-4004-9668-b9a9a265ea32@nvidia.com> (raw)
In-Reply-To: <d9c06bec-805f-4d53-9f91-6b8ad29fcb6b@redhat.com>

On 3/14/24 09:22, David Hildenbrand wrote:
> On 14.03.24 03:46, John Hubbard wrote:
>> On 3/13/24 2:20 AM, David Hildenbrand wrote:
>> ...
>>> The description is wrong. Whoever calls split_huge_page_to_list() 
>>> must hold a folio reference.
>>>
>>> That folio reference will be transferred to @page (not the head page) 
>>> once split. So @page can be used by the caller after the split 
>>> succeeded.
>>>
>>
>> David and all, does this updated draft comment look accurate?
>>
> 
> Note that in mm-unstable (maybe even mm-stable already), the function is 
> now called split_huge_page_to_list_to_order().

Aha, yes already in mm-stable, and the comment is quite heavily modified
there, too. But it's straightforward to merge in relevant parts of what
we're trying to say here.

I can send out an actual patch after the merge window finishes.

> 
>> /*
>>    * This function splits a huge page into normal pages. @page can 
>> point to any
>>    * subpage of the huge page to split. The split operation does not 
>> change the
>>    * position of @page.
>>    *
>>    * Prerequisites:
>>    *
>>    * 1) The caller must hold a reference on the @page's owning folio, 
>> also known as
>>    *    the huge page.
>>    *
>>    * 2) The huge page must be locked.
>>    *
>>    * 3) The folio must not be pinned. Pinned folios will not be split; 
>> instead,
>>    *    the caller will receive an -EBUSY.
> 
> Maybe focus on unexpected folio references:
> 
> 3) The folio must not be pinned. Any unexpected folio references, 
> including GUP pins, will result in the folio not getting split; instead ...

Yes, saying "unexpected" does make it clearer, agreed.

> 
>>    * >    * After splitting, the folio's refcount is transfered to @page 
> (not the head
> 
> s/transfered/transferred/
> 
>>    * page, unless @page is actually the head page). The other subpages 
>> may be
>>    * freed if they are not mapped.
> 
> "folio's refcount" might be a bit misleading. It's more like
> 
> "The caller's folio reference will be transferred to @page, resulting in 
> a raised refcount of @page after this call ... "

heh, my wording was actually wrong! Thanks for correcting it. I didn't
see where the @page picked up the folio's reference, so I thought I
must have misread your original explanation.


thanks,
-- 
John Hubbard
NVIDIA



  reply	other threads:[~2024-03-14 17:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13  3:16 Matthew Wilcox
2024-03-13  9:20 ` David Hildenbrand
2024-03-13 15:27   ` Matthew Wilcox
2024-03-13 16:53     ` David Hildenbrand
2024-03-13 18:52       ` Jane Chu
2024-03-13 22:25     ` John Hubbard
2024-03-14  2:46   ` updated documentation: " John Hubbard
2024-03-14 16:22     ` David Hildenbrand
2024-03-14 17:51       ` John Hubbard [this message]
2024-03-14 17:45     ` Matthew Wilcox
2024-03-14 17:57       ` John Hubbard

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=280792da-8ad3-4004-9668-b9a9a265ea32@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=david@redhat.com \
    --cc=jane.chu@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /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