linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: takahiro.akashi@linaro.org (AKASHI Takahiro)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v15 15/20] arm64: kdump: reserve memory for crash dump kernel
Date: Thu, 31 Mar 2016 16:19:03 +0900	[thread overview]
Message-ID: <20160331071903.GB2267@linaro.org> (raw)
In-Reply-To: <56EC441E.2040606@arm.com>

On Fri, Mar 18, 2016 at 06:08:30PM +0000, James Morse wrote:
> Hi!
> 
> On 14/03/16 17:48, Geoff Levand wrote:
> > From: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > 
> > On the startup of primary kernel, the memory region used by crash dump
> > kernel must be specified by "crashkernel=" kernel parameter.
> > reserve_crashkernel() will allocate and reserve the region for later use.
> > 
> > User space tools, like kexec-tools, will be able to find that region marked
> > as "Crash kernel" in /proc/iomem.
> 
> [NB: Re-ordered diff hunks ]
> 
> > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> > index 7802f21..4edf181 100644
> > --- a/arch/arm64/mm/init.c
> > +++ b/arch/arm64/mm/init.c
> > @@ -171,6 +229,8 @@ void __init arm64_memblock_init(void)
> >  		memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start);
> >  #endif
> >
> > +	reserve_crashkernel();
> > +
> >  	early_init_fdt_scan_reserved_mem();
> >
> >  	/* 4GB maximum for 32-bit only capable devices */
> >
> 
> 
> This is 'nit' territory, but if you were to make this:
> >	if (IS_ENABLED(CONFIG_KEXEC_CORE))
> >		reserve_crashkernel();
> 
> then the #ifdefs around reserve_crashkernel() can go, and the compiler will work
> out that this static function can be optimised out. It also means the
> compiler performs its checks, even if CONFIG_KEXEC_CORE isn't selected. The same
> trick can be applied in patch 18 (around reserve_elfcorehdr()).

It will also make the code more understandable.

Thanks,
-Takahiro AKASHI

> > @@ -66,6 +67,63 @@ static int __init early_initrd(char *p)
> >  early_param("initrd", early_initrd);
> >  #endif
> >  
> > +#ifdef CONFIG_KEXEC_CORE
> > +/*
> > + * reserve_crashkernel() - reserves memory for crash kernel
> > + *
> > + * This function reserves memory area given in "crashkernel=" kernel command
> > + * line parameter. The memory reserved is used by dump capture kernel when
> > + * primary kernel is crashing.
> > + */
> > +static void __init reserve_crashkernel(void)
> > +{
> > +	unsigned long long crash_size = 0, crash_base = 0;
> > +	int ret;
> > +
> > +	ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
> > +				&crash_size, &crash_base);
> > +	if (ret)
> > +		return;
> > +
> > +	if (crash_base == 0) {
> > +		crash_base = memblock_find_in_range(0,
> > +				MEMBLOCK_ALLOC_ACCESSIBLE, crash_size, 1 << 21);
> > +		if (crash_base == 0) {
> > +			pr_warn("Unable to allocate crashkernel (size:%llx)\n",
> > +				crash_size);
> > +			return;
> > +		}
> > +		memblock_reserve(crash_base, crash_size);
> > +
> > +	} else {
> > +		/* User specifies base address explicitly. */
> > +		if (!memblock_is_region_memory(crash_base, crash_size) ||
> > +			memblock_is_region_reserved(crash_base, crash_size)) {
> > +			pr_warn("crashkernel has wrong address or size\n");
> > +			return;
> > +		}
> > +
> > +		if (crash_base & ((1 << 21) - 1)) {
> > +			pr_warn("crashkernel base address is not 2MB aligned\n");
> > +			return;
> > +		}
> > +
> > +		memblock_reserve(crash_base, crash_size);
> > +	}
> > +
> > +	pr_info("Reserving %lldMB of memory at %lldMB for crashkernel\n",
> > +		crash_size >> 20, crash_base >> 20);
> > +
> > +	crashk_res.start = crash_base;
> > +	crashk_res.end = crash_base + crash_size - 1;
> > +}
> > +#else
> > +static void __init reserve_crashkernel(void)
> > +{
> > +	;
> > +}
> > +#endif /* CONFIG_KEXEC_CORE */
> > +
> >  /*
> >   * Return the maximum physical address for ZONE_DMA (DMA_BIT_MASK(32)). It
> >   * currently assumes that for memory starting above 4G, 32-bit devices will
> 
> 
> Thanks,
> 
> James
> 

  reply	other threads:[~2016-03-31  7:19 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-14 17:47 [PATCH v15 00/20] arm64 kexec kernel patches v15 Geoff Levand
2016-03-14 17:48 ` [PATCH v15 04/20] arm64: Add new hcall HVC_CALL_FUNC Geoff Levand
2016-03-14 17:48 ` [PATCH v15 03/20] arm64: Convert hcalls to use HVC immediate value Geoff Levand
2016-03-15 13:50   ` Dave Martin
2016-03-15 18:15     ` Geoff Levand
2016-03-16 13:50       ` Dave Martin
2016-03-16 14:09         ` Marc Zyngier
2016-03-17 16:47           ` Geoff Levand
2016-03-14 17:48 ` [PATCH v15 12/20] arm64/kexec: Add core kexec support Geoff Levand
2016-03-14 17:48 ` [PATCH v15 05/20] arm64: kvm: allows kvm cpu hotplug Geoff Levand
2016-03-14 17:48 ` [PATCH v15 01/20] arm64: Fold proc-macros.S into assembler.h Geoff Levand
2016-03-14 17:48 ` [PATCH v15 06/20] arm64: kernel: Include _AC definition in page.h Geoff Levand
2016-03-14 17:48 ` [PATCH v15 08/20] arm64: Add new asm macro copy_page Geoff Levand
2016-03-14 17:48 ` [PATCH v15 07/20] arm64: Promote KERNEL_START/KERNEL_END definitions to a header file Geoff Levand
2016-03-14 17:48 ` [PATCH v15 13/20] arm64/kexec: Enable kexec in the arm64 defconfig Geoff Levand
2016-03-14 17:48 ` [PATCH v15 09/20] arm64: Add back cpu_reset routines Geoff Levand
2016-03-14 17:48 ` [PATCH v15 02/20] arm64: Cleanup SCTLR flags Geoff Levand
2016-03-14 17:48 ` [PATCH v15 10/20] Revert "arm64: mm: remove unused cpu_set_idmap_tcr_t0sz function" Geoff Levand
2016-03-14 17:48 ` [PATCH v15 11/20] Revert "arm64: remove dead code" Geoff Levand
2016-03-14 17:48 ` [PATCH v15 16/20] arm64: limit memory regions based on DT property, usable-memory Geoff Levand
2016-03-14 17:48 ` [PATCH v15 18/20] arm64: kdump: add kdump support Geoff Levand
2016-03-14 17:48 ` [PATCH v15 15/20] arm64: kdump: reserve memory for crash dump kernel Geoff Levand
2016-03-18 18:08   ` James Morse
2016-03-31  7:19     ` AKASHI Takahiro [this message]
2016-04-01  6:16       ` AKASHI Takahiro
2016-03-14 17:48 ` [PATCH v15 20/20] arm64: kdump: update a kernel doc Geoff Levand
2016-03-14 17:48 ` [PATCH v15 17/20] arm64: kdump: implement machine_crash_shutdown() Geoff Levand
2016-03-18 18:08   ` James Morse
2016-03-21 13:29     ` James Morse
2016-03-31  7:57       ` AKASHI Takahiro
2016-03-31  8:12         ` Marc Zyngier
2016-03-31 10:10           ` Mark Rutland
2016-04-01  8:45             ` AKASHI Takahiro
2016-04-01  9:36               ` Mark Rutland
2016-04-04  9:27                 ` AKASHI Takahiro
2016-03-31  7:46     ` AKASHI Takahiro
2016-03-31 10:22       ` James Morse
2016-03-14 17:48 ` [PATCH v15 14/20] arm64/kexec: Add pr_debug output Geoff Levand
2016-03-14 17:48 ` [PATCH v15 19/20] arm64: kdump: enable kdump in the arm64 defconfig Geoff Levand
2016-04-01  1:59 ` [PATCH v15 00/20] arm64 kexec kernel patches v15 Dave Young
2016-04-01 18:39   ` Geoff Levand
2016-05-17  5:42     ` Dave Young
2016-05-17  8:06       ` Marc Zyngier
2016-05-17  9:07         ` AKASHI Takahiro
2016-05-18  2:09         ` Dave Young

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=20160331071903.GB2267@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --cc=linux-arm-kernel@lists.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;
as well as URLs for NNTP newsgroup(s).