linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joel Savitz <jsavitz@redhat.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Michael Ellerman <mpe@ellerman.id.au>,
	 Nicholas Piggin <npiggin@gmail.com>,
	Christophe Leroy <christophe.leroy@csgroup.eu>,
	 "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>,
	Benjamin Gray <bgray@linux.ibm.com>,
	 Paul Mackerras <paulus@ozlabs.org>,
	linuxppc-dev@lists.ozlabs.org,
	 Gonzalo Siero <gsierohu@redhat.com>
Subject: Re: [PATCH] powerpc: align memory_limit to 16MB in early_parse_mem
Date: Mon, 1 Apr 2024 10:17:19 -0400	[thread overview]
Message-ID: <CAL1p7m5VHGL+-st7zgGA9LPft6DND=qz0ifiD_ki1hLvfRv=7Q@mail.gmail.com> (raw)
In-Reply-To: <CAL1p7m5BoxFDeK0MryQCmTDCeBLN3rMLRGx3cHa6teS02wsgZw@mail.gmail.com>

On Tue, Mar 26, 2024 at 12:45 AM Joel Savitz <jsavitz@redhat.com> wrote:
>
> On Fri, Mar 8, 2024 at 5:18 AM Aneesh Kumar K.V <aneesh.kumar@kernel.org> wrote:
> >
> > Joel Savitz <jsavitz@redhat.com> writes:
> >
> > > On 64-bit powerpc, usage of a non-16MB-aligned value for the mem= kernel
> > > cmdline parameter results in a system hang at boot.
> > >
> > > For example, using 'mem=4198400K' will always reproduce this issue.
> > >
> > > This patch fixes the problem by aligning any argument to mem= to 16MB
> > > corresponding with the large page size on powerpc.
> > >
> > > Fixes: 2babf5c2ec2f ("[PATCH] powerpc: Unify mem= handling")
> > > Co-developed-by: Gonzalo Siero <gsierohu@redhat.com>
> > > Signed-off-by: Gonzalo Siero <gsierohu@redhat.com>
> > > Signed-off-by: Joel Savitz <jsavitz@redhat.com>
> > > ---
> > >  arch/powerpc/kernel/prom.c | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> > > index 0b5878c3125b..8cd3e2445d8a 100644
> > > --- a/arch/powerpc/kernel/prom.c
> > > +++ b/arch/powerpc/kernel/prom.c
> > > @@ -82,8 +82,12 @@ static int __init early_parse_mem(char *p)
> > >  {
> > >       if (!p)
> > >               return 1;
> > > -
> > > +#ifdef CONFIG_PPC64
> > > +     /* Align to 16 MB == size of ppc64 large page */
> > > +     memory_limit = ALIGN(memparse(p, &p), 0x1000000);
> > > +#else
> > >       memory_limit = PAGE_ALIGN(memparse(p, &p));
> > > +#endif
> > >       DBG("memory limit = 0x%llx\n", memory_limit);
> > >
> > >       return 0;
> > > --
> > > 2.43.0
> >
> > Can you try this change?
> >
> > commit 5555bc55e1aa71f545cff31e1eccdb4a2e39df84
> > Author: Aneesh Kumar K.V (IBM) <aneesh.kumar@kernel.org>
> > Date:   Fri Mar 8 14:45:26 2024 +0530
> >
> >     powerpc/mm: Align memory_limit value specified using mem= kernel parameter
> >
> >     The value specified for the memory limit is used to set a restriction on
> >     memory usage. It is important to ensure that this restriction is within
> >     the linear map kernel address space range. The hash page table
> >     translation uses a 16MB page size to map the kernel linear map address
> >     space. htab_bolt_mapping() function aligns down the size of the range
> >     while mapping kernel linear address space. Since the memblock limit is
> >     enforced very early during boot, before we can detect the type of memory
> >     translation (radix vs hash), we align the memory limit value specified
> >     as a kernel parameter to 16MB. This alignment value will work for both
> >     hash and radix translations.
> >
> >     Signed-off-by: Aneesh Kumar K.V (IBM) <aneesh.kumar@kernel.org>
> >
> > diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> > index 0b5878c3125b..9bd965d35352 100644
> > --- a/arch/powerpc/kernel/prom.c
> > +++ b/arch/powerpc/kernel/prom.c
> > @@ -824,8 +824,11 @@ void __init early_init_devtree(void *params)
> >                 reserve_crashkernel();
> >         early_reserve_mem();
> >
> > -       /* Ensure that total memory size is page-aligned. */
> > -       limit = ALIGN(memory_limit ?: memblock_phys_mem_size(), PAGE_SIZE);
> > +       if (memory_limit > memblock_phys_mem_size())
> > +               memory_limit = 0;
> > +
> > +       /* Align down to 16 MB which is large page size with hash page translation */
> > +       limit = ALIGN_DOWN(memory_limit ?: memblock_phys_mem_size(), SZ_16M);
> >         memblock_enforce_memory_limit(limit);
> >
> >  #if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_PPC_4K_PAGES)
> > diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
> > index e67effdba85c..d6410549e141 100644
> > --- a/arch/powerpc/kernel/prom_init.c
> > +++ b/arch/powerpc/kernel/prom_init.c
> > @@ -817,8 +817,8 @@ static void __init early_cmdline_parse(void)
> >                 opt += 4;
> >                 prom_memory_limit = prom_memparse(opt, (const char **)&opt);
> >  #ifdef CONFIG_PPC64
> > -               /* Align to 16 MB == size of ppc64 large page */
> > -               prom_memory_limit = ALIGN(prom_memory_limit, 0x1000000);
> > +               /* Align down to 16 MB which is large page size with hash page translation */
> > +               prom_memory_limit = ALIGN_DOWN(prom_memory_limit, SZ_16M);
> >  #endif
> >         }
> >
> >
>
> Sorry for the delayed reply. I just tested this patch and it fixes the
> bug for me.

Hi,

Just a quick follow up on this.

The above patch fixed the bug for me.

How do we want to proceed?

Best,
Joel Savitz


  reply	other threads:[~2024-04-01 14:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01 20:30 [PATCH] powerpc: align memory_limit to 16MB in early_parse_mem Joel Savitz
2024-03-01 23:23 ` Michael Ellerman
2024-03-02 23:59   ` Joel Savitz
2024-03-08  9:30     ` Michael Ellerman
2024-03-04  6:58   ` Aneesh Kumar K.V
2024-03-08 10:18 ` Aneesh Kumar K.V
2024-03-26  4:45   ` Joel Savitz
2024-04-01 14:17     ` Joel Savitz [this message]
2024-04-10 15:22       ` Joel Savitz
2024-04-10 15:31         ` Christophe Leroy
2024-04-10 16:52           ` Joel Savitz

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='CAL1p7m5VHGL+-st7zgGA9LPft6DND=qz0ifiD_ki1hLvfRv=7Q@mail.gmail.com' \
    --to=jsavitz@redhat.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=bgray@linux.ibm.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=gsierohu@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=npiggin@gmail.com \
    --cc=paulus@ozlabs.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;
as well as URLs for NNTP newsgroup(s).