linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Frank van der Linden <fvdl@google.com>
To: Roman Gushchin <roman.gushchin@linux.dev>
Cc: linux-mm@kvack.org, muchun.song@linux.dev,
	akpm@linux-foundation.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] mm/hugetlb: pass correct order_per_bit to cma_declare_contiguous_nid
Date: Thu, 4 Apr 2024 12:40:58 -0700	[thread overview]
Message-ID: <CAPTztWYH5ANR2cYidf+frC2HBJiz6UUh5wC5khHJg8R-gYbcFw@mail.gmail.com> (raw)
In-Reply-To: <Zg7358ygxHBHUCy9@P9FQF9L96D.corp.robot.car>

On Thu, Apr 4, 2024 at 11:56 AM Roman Gushchin <roman.gushchin@linux.dev> wrote:
>
> On Thu, Apr 04, 2024 at 04:25:15PM +0000, Frank van der Linden wrote:
> > The hugetlb_cma code passes 0 in the order_per_bit argument to
> > cma_declare_contiguous_nid (the alignment, computed using the
> > page order, is correctly passed in).
> >
> > This causes a bit in the cma allocation bitmap to always represent
> > a 4k page, making the bitmaps potentially very large, and slower.
> >
> > So, correctly pass in the order instead.
> >
> > Signed-off-by: Frank van der Linden <fvdl@google.com>
> > Cc: Roman Gushchin <roman.gushchin@linux.dev>
> > Fixes: cf11e85fc08c ("mm: hugetlb: optionally allocate gigantic hugepages using cma")
>
> Hi Frank,
>
> there is a comment just above your changes which explains why order_per_bit is 0.
> Is this not true anymore? If so, please, fix the comment too. Please, clarify.
>
> Thanks!

Hi Roman,

I'm assuming you're referring to this comment:

/*
 * Note that 'order per bit' is based on smallest size that
 * may be returned to CMA allocator in the case of
 * huge page demotion.
 */

That comment was added in a01f43901cfb9 ("hugetlb: be sure to free
demoted CMA pages to CMA").

It talks about HUGETLB_PAGE_ORDER being the minimum order being given
back to the CMA allocator (after hugetlb demotion), therefore
order_per_bit must be HUGETLB_PAGE_ORDER. See the commit message for
that commit:

"Therefore, at region setup time we use HUGETLB_PAGE_ORDER as the
smallest possible huge page size that can be given back to CMA."

But the commit, while correctly changing the alignment, left the
order_per_bit argument at 0,  even though it clearly intended to set
it at HUGETLB_PAGE_ORDER. The confusion may have been that
cma_declare_contiguous_nid has 9 arguments, several of which can be
left at 0 meaning 'use default', so it's easy to misread.

In other words, the comment was correct, but the code was not. After
this patch, comment and code match.


  reply	other threads:[~2024-04-04 19:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-04 16:25 [PATCH 1/2] mm/cma: drop incorrect alignment check in cma_init_reserved_mem Frank van der Linden
2024-04-04 16:25 ` [PATCH 2/2] mm/hugetlb: pass correct order_per_bit to cma_declare_contiguous_nid Frank van der Linden
2024-04-04 18:56   ` Roman Gushchin
2024-04-04 19:40     ` Frank van der Linden [this message]
2024-04-04 20:45       ` Roman Gushchin
2024-04-04 20:13   ` David Hildenbrand
2024-04-04 20:52     ` Roman Gushchin
2024-04-04 22:02       ` Frank van der Linden
2024-04-04 22:20         ` Andrew Morton
2024-04-04 21:44     ` Frank van der Linden
2024-04-04 22:22       ` Frank van der Linden
2024-04-08  8:15       ` David Hildenbrand
2024-04-04 20:17   ` Andrew Morton
2024-04-04 21:58     ` Frank van der Linden
2024-04-07  8:02   ` Muchun Song
2024-04-04 20:15 ` [PATCH 1/2] mm/cma: drop incorrect alignment check in cma_init_reserved_mem Andrew Morton
2024-04-04 20:45   ` Frank van der Linden
     [not found] ` <93eccef7-a559-4ad8-be0f-8cc99c00bd09@redhat.com>
2024-04-04 20:48   ` Frank van der Linden

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=CAPTztWYH5ANR2cYidf+frC2HBJiz6UUh5wC5khHJg8R-gYbcFw@mail.gmail.com \
    --to=fvdl@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --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