From: Mike Rapoport <rppt@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Albert Ou <aou@eecs.berkeley.edu>,
Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Frank Rowand <frowand.list@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Heiko Carstens <hca@linux.ibm.com>,
Ingo Molnar <mingo@redhat.com>,
"Kirill A. Shutemov" <kirill@shutemov.name>,
Len Brown <lenb@kernel.org>, Marc Zyngier <maz@kernel.org>,
Mike Rapoport <rppt@linux.ibm.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Peter Zijlstra <peterz@infradead.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Rob Herring <robh+dt@kernel.org>,
Russell King <linux@armlinux.org.uk>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Thomas Gleixner <tglx@linutronix.de>,
Vasily Gorbik <gor@linux.ibm.com>, Will Deacon <will@kernel.org>,
devicetree@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org,
linux-mm@kvack.org, linux-riscv@lists.infradead.org,
linux-s390@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH v3] memblock: make memblock_find_in_range method private
Date: Tue, 3 Aug 2021 22:07:37 +0300 [thread overview]
Message-ID: <YQmT+Z9QhcwI43GK@kernel.org> (raw)
In-Reply-To: <20210803180526.GD5786@arm.com>
On Tue, Aug 03, 2021 at 07:05:26PM +0100, Catalin Marinas wrote:
> On Tue, Aug 03, 2021 at 09:42:18AM +0300, Mike Rapoport wrote:
> > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> > index 8490ed2917ff..0bffd2d1854f 100644
> > --- a/arch/arm64/mm/init.c
> > +++ b/arch/arm64/mm/init.c
> > @@ -74,6 +74,7 @@ phys_addr_t arm64_dma_phys_limit __ro_after_init;
> > static void __init reserve_crashkernel(void)
> > {
> > unsigned long long crash_base, crash_size;
> > + unsigned long long crash_max = arm64_dma_phys_limit;
> > int ret;
> >
> > ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
> > @@ -84,33 +85,18 @@ static void __init reserve_crashkernel(void)
> >
> > crash_size = PAGE_ALIGN(crash_size);
> >
> > - if (crash_base == 0) {
> > - /* Current arm64 boot protocol requires 2MB alignment */
> > - crash_base = memblock_find_in_range(0, arm64_dma_phys_limit,
> > - crash_size, SZ_2M);
> > - if (crash_base == 0) {
> > - pr_warn("cannot allocate crashkernel (size:0x%llx)\n",
> > - crash_size);
> > - return;
> > - }
> > - } else {
> > - /* User specifies base address explicitly. */
> > - if (!memblock_is_region_memory(crash_base, crash_size)) {
> > - pr_warn("cannot reserve crashkernel: region is not memory\n");
> > - return;
> > - }
> > + /* User specifies base address explicitly. */
> > + if (crash_base)
> > + crash_max = crash_base + crash_size;
> >
> > - if (memblock_is_region_reserved(crash_base, crash_size)) {
> > - pr_warn("cannot reserve crashkernel: region overlaps reserved memory\n");
> > - return;
> > - }
> > -
> > - if (!IS_ALIGNED(crash_base, SZ_2M)) {
> > - pr_warn("cannot reserve crashkernel: base address is not 2MB aligned\n");
> > - return;
> > - }
> > + /* Current arm64 boot protocol requires 2MB alignment */
> > + crash_base = memblock_phys_alloc_range(crash_size, SZ_2M,
> > + crash_base, crash_max);
> > + if (!crash_base) {
> > + pr_warn("cannot allocate crashkernel (size:0x%llx)\n",
> > + crash_size);
> > + return;
> > }
> > - memblock_reserve(crash_base, crash_size);
>
> We'll miss a bit on debug information provided to the user in case of a
> wrong crash_base/size option on the command line. Not sure we care much,
> though the alignment would probably be useful (maybe we document it
> somewhere).
It is already documented:
Documentation/admin-guide/kdump/kdump.rst:
On arm64, use "crashkernel=Y[@X]". Note that the start address of
the kernel, X if explicitly specified, must be aligned to 2MiB (0x200000).
> What I haven't checked is whether memblock_phys_alloc_range() aims to
> get a 2MB aligned end (size) as well. If crash_size is not 2MB aligned,
> crash_max wouldn't be either and the above could fail. We only care
> about the crash_base to be aligned but the memblock_phys_alloc_range()
> doc says that both the start and size would be aligned to this.
The doc lies :)
memblock_phys_alloc_range() boils down to
for_each_free_mem_range_reverse(i, nid, flags, &this_start, &this_end,
NULL) {
/* clamp this_{start,end} to the user defined limits */
cand = round_down(this_end - size, align);
if (cand >= this_start)
return cand;
}
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2021-08-03 19:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-03 6:42 Mike Rapoport
2021-08-03 18:05 ` Catalin Marinas
2021-08-03 19:07 ` Mike Rapoport [this message]
2021-08-04 10:02 ` Catalin Marinas
2021-08-09 19:06 ` Guenter Roeck
2021-08-10 18:55 ` Mike Rapoport
2021-08-10 19:21 ` Guenter Roeck
2021-08-11 7:36 ` Mike Rapoport
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=YQmT+Z9QhcwI43GK@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=aou@eecs.berkeley.edu \
--cc=borntraeger@de.ibm.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=gor@linux.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=hca@linux.ibm.com \
--cc=hpa@zytor.com \
--cc=kirill@shutemov.name \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=luto@kernel.org \
--cc=maz@kernel.org \
--cc=mingo@redhat.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=peterz@infradead.org \
--cc=rjw@rjwysocki.net \
--cc=robh+dt@kernel.org \
--cc=rppt@linux.ibm.com \
--cc=tglx@linutronix.de \
--cc=tsbogend@alpha.franken.de \
--cc=will@kernel.org \
--cc=x86@kernel.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