linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>,
	John Hubbard <jhubbard@nvidia.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	akpm@linux-foundation.org, songmuchun@bytedance.com,
	tsahu@linux.ibm.com, david@redhat.com
Subject: Re: [PATCH mm-unstable] mm: clarify folio_set_compound_order() zero support
Date: Thu, 8 Dec 2022 12:01:15 -0800	[thread overview]
Message-ID: <Y5JCi3h8bUzLf3cu@monkey> (raw)
In-Reply-To: <Y5I78soNmAFv7pi8@casper.infradead.org>

On 12/08/22 19:33, Matthew Wilcox wrote:
> On Thu, Dec 08, 2022 at 10:06:07AM -0800, Sidhartha Kumar wrote:
> > On 12/7/22 6:27 PM, John Hubbard wrote:
> > > On 12/7/22 17:42, Sidhartha Kumar wrote:
> > This works for me, I will take this approach along with Muchun's feedback
> > about a wrapper function so as not to touch _folio_order directly and send
> > out a new version.
> > 
> > One question I have is if I should then get rid of
> > folio_set_compound_order() as hugetlb is the only compound page user I've
> > converted to folios so far and its use can be replaced by the suggested
> > folio_set_nr_pages() and folio_set_order().
> > 
> > Hugetlb also has one has one call to folio_set_compound_order() with a
> > non-zero order, should I replace this with a call to folio_set_order() and
> > folio_set_nr_pages() as well, or keep folio_set_compound_order() and remove
> > zero order support and the comment. Please let me know which approach you
> > would prefer.
> 
> None of the above!
> 
> Whatever we're calling this function *it does not belong* in mm.h.
> Anything outside the MM calling it is going to be a disaster -- can you
> imagine what will happen if a filesystem or device driver is handed a
> folio and decides "Oh, I'll just change the size of this folio"?  It is
> an attractive nuisance and should be confined to mm/internal.h *at best*.

I suspect it was placed in mm.h as it is the 'folio version' of
set_compound_order which resides in mm.h.  But, no need to repeat that
unfortunate placement.

> 
> Equally, we *must not have* separate folio_set_order() and
> folio_set_nr_pages().  These are the same thing!  They must be kept
> in sync!  If we are to have a folio_set_order() instead of open-coding
> it, then it should also update nr_pages.

Ok.  Agree.

> So, given that this is now an internal-to-mm, if not internal-to-hugetlb
> function, I see no reason that it should not handle the case of 0.
> I haven't studied what hugetlb_dissolve does, or why it can't use the
> standard split_folio(), but I'm sure there's a good reason.

The hugetlb code is changing the compound page/folio it created from a set of
individual pages back to individual pages so they can be returned to the
low level allocator.  Somewhat like what page_alloc/page_free do.  split_folio
is overkill.  split_page would be a closer match.

It makes perfect sense to put the function in mm internal.h.

Thanks,
-- 
Mike Kravetz


  parent reply	other threads:[~2022-12-08 20:01 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 22:37 Sidhartha Kumar
2022-12-08  0:38 ` John Hubbard
2022-12-08  1:42   ` Sidhartha Kumar
2022-12-08  2:27     ` John Hubbard
2022-12-08  4:41       ` Muchun Song
2022-12-08 18:06       ` Sidhartha Kumar
2022-12-08 19:32         ` Mike Kravetz
2022-12-08 19:33         ` Matthew Wilcox
2022-12-08 19:56           ` John Hubbard
2022-12-08 20:01           ` Mike Kravetz [this message]
2022-12-08 21:58             ` Sidhartha Kumar
2022-12-08 22:01               ` John Hubbard
2022-12-08 22:12                 ` Sidhartha Kumar
2022-12-08 22:14                   ` John Hubbard
2022-12-08 22:33                     ` Sidhartha Kumar
2022-12-08 22:39                       ` John Hubbard
2022-12-09 14:27                         ` Muchun Song
2022-12-09 21:10                           ` John Hubbard
2022-12-09 21:20                             ` John Hubbard
2022-12-14  3:00                               ` Muchun Song
2022-12-08 22:04               ` Matthew Wilcox

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=Y5JCi3h8bUzLf3cu@monkey \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sidhartha.kumar@oracle.com \
    --cc=songmuchun@bytedance.com \
    --cc=tsahu@linux.ibm.com \
    --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