From: Mike Rapoport <rppt@kernel.org>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Guenter Roeck <linux@roeck-us.net>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm-treewide-redefine-max_order-sanely-fix.txt
Date: Fri, 7 Apr 2023 21:03:24 +0300 [thread overview]
Message-ID: <ZDBa7HWZK69dKKzH@kernel.org> (raw)
In-Reply-To: <20230407124054.27iiers6o36pdfei@box.shutemov.name>
On Fri, Apr 07, 2023 at 03:40:54PM +0300, Kirill A. Shutemov wrote:
> On Thu, Apr 06, 2023 at 03:44:23PM -0700, Andrew Morton wrote:
> > On Fri, 7 Apr 2023 00:14:31 +0300 Mike Rapoport <rppt@kernel.org> wrote:
> >
> > > > > Shouldn't that be
> > > > > else
> > > > > order = 0;
> > > > > ?
> > > >
> > > > +Mike.
> > > >
> > > > No. start == 0 is MAX_ORDER-aligned. We want to free the pages in the
> > > > largest chunks alignment allows.
> > >
> > > Right. Before the changes to MAX_ORDER it was
> > >
> > > order = min(MAX_ORDER - 1UL, __ffs(start));
> > >
> > > which would evaluate to 10.
> > >
> > > I'd just prefer the comment to include the explanation about why we choose
> > > MAX_ORDER for start == 0. Say
> > >
> > > /*
> > > * __ffs() behaviour is undefined for 0 and we want to free the
> > > * pages in the largest chunks alignment allows, so set order to
> > > * MAX_ORDER when start == 0
> > > */
> >
> > Meanwhile I'd like to fix "various boot failures (hang) on arm targets"
> > in -next, so I queued up Kirill's informal fix for now.
>
> Here's my variant of the fix up with more vervose comments.
>
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 7911224b1ed3..381e36ac9e4d 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -2043,7 +2043,16 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
> int order;
>
> while (start < end) {
> - order = min_t(int, MAX_ORDER, __ffs(start));
> + /*
> + * Free the pages in the largest chunks alignment allows.
> + *
> + * __ffs() behaviour is undefined for 0. start == 0 is
> + * MAX_ORDER-aligned, Set order to MAX_ORDER for the case.
^ small s
otherwise feel free to add
Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>
> + */
> + if (start)
> + order = min_t(int, MAX_ORDER, __ffs(start));
> + else
> + order = MAX_ORDER;
>
> while (start + (1UL << order) > end)
> order--;
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index c8f0a8c2d049..8e0fa209d533 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -605,7 +605,18 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages)
> * this and the first chunk to online will be pageblock_nr_pages.
> */
> for (pfn = start_pfn; pfn < end_pfn;) {
> - int order = min_t(int, MAX_ORDER, __ffs(pfn));
> + int order;
> +
> + /*
> + * Free to online pages in the largest chunks alignment allows.
> + *
> + * __ffs() behaviour is undefined for 0. start == 0 is
> + * MAX_ORDER-aligned, Set order to MAX_ORDER for the case.
> + */
> + if (pfn)
> + order = min_t(int, MAX_ORDER, __ffs(pfn));
> + else
> + order = MAX_ORDER;
>
> (*online_page_callback)(pfn_to_page(pfn), order);
> pfn += (1UL << order);
> --
> Kiryl Shutsemau / Kirill A. Shutemov
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2023-04-07 18:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 5:20 Guenter Roeck
2023-04-06 7:25 ` Kirill A. Shutemov
2023-04-06 13:57 ` Guenter Roeck
2023-04-06 15:10 ` Kirill A. Shutemov
2023-04-06 18:23 ` Guenter Roeck
2023-04-06 21:14 ` Mike Rapoport
2023-04-06 22:44 ` Andrew Morton
2023-04-07 12:40 ` Kirill A. Shutemov
2023-04-07 18:03 ` Mike Rapoport [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=ZDBa7HWZK69dKKzH@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@roeck-us.net \
/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