linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: dennis.chen@arm.com (Dennis Chen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v22 1/8] arm64: kdump: reserve memory for crash dump kernel
Date: Wed, 20 Jul 2016 11:48:40 +0800	[thread overview]
Message-ID: <20160720034838.GB30575@arm.com> (raw)
In-Reply-To: <20160719132736.GB21007@leverpostej>

On Tue, Jul 19, 2016 at 02:27:54PM +0100, Mark Rutland wrote:
> On Tue, Jul 19, 2016 at 08:48:57AM -0400, Mark Salter wrote:
> > On Tue, 2016-07-19 at 18:41 +0800, Dennis Chen wrote:
> > > On Tue, Jul 19, 2016 at 07:28:16PM +0900, AKASHI Takahiro wrote:
> > > > On Tue, Jul 19, 2016 at 05:39:07PM +0800, Dennis Chen wrote:
> > > > > On Tue, Jul 12, 2016 at 02:05:07PM +0900, AKASHI Takahiro wrote:
> > > > > > +/*
> > > > > > + * 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)
> > > > > > +{
> > > > > > +?????int ret;
> > > > > > +
> > > > > > +?????ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
> > > > > > +?????????????????????????????&crash_size, &crash_base);
> > > > > > +?????/* no crashkernel= or invalid value specified */
> > > > > > +?????if (ret || !crash_size)
> > > > > > +?????????????return;
> > > > > > +
> > > > > > +?????if (crash_base == 0) {
> > > > > > +?????????????/* Current arm64 boot protocol requires 2MB alignment */
> > > > > > +?????????????crash_base = memblock_find_in_range(0,
> > > > > > +?????????????????????????????MEMBLOCK_ALLOC_ACCESSIBLE, crash_size, SZ_2M);
> > > > > > +?????????????if (crash_base == 0) {
> > > > > > +?????????????????????pr_warn("Unable to allocate crashkernel (size:%llx)\n",
> > > > > > +?????????????????????????????crash_size);
> > > > > > +?????????????????????return;
> > > > > > +?????????????}
> > > > > > +?????????????memblock_reserve(crash_base, crash_size);
> > > > > > 
> > > > > I am not pretty sure the context here, but
> > > > > can we use below code piece instead of the above lines?
> > > > > ????????if (crash_base == 0)
> > > > > ????????????????memblock_alloc(crash_size, SZ_2M);
> > > > Either would be fine here.
> > > > 
> > > Hello AKASHI, maybe you can succeed to find the base with memblock_find_in_range(),?
> > > but that doesn't mean you will also succeed to reserve them with memblock_reserve followed.
> > 
> > We avoid memblock_alloc() here because it panics on failure. This could happen
> > if user asks for an unusually large crashkernel size. Better to print a message
> > and keep booting. Checking the return value of memblock_reserve() seems like a
> > good thing to do though.
> 
> Another option would be to add a memblock_try_alloc() function to the
> memblock API, which in case of failure returns 0 rather than triggering
> a panic(). We'd still have to check the return value, but all the
> memblock manipulation would be in one place.
> 
> It looks like adding that is fairly simple:
> 
> phys_addr_t __init memblock_try_alloc(phys_addr_t size, phys_addr_t align)
> {
> 	return __memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ACCESSIBLE);
> }
>
Hi Mark, memblock_alloc() should remove the panic just as we did in kmalloc IMO, as a memory allocation
API, it should handover the failure case to the user and the latter should make the final decision.
Just take a look at the usage case of the memblock_alloc() in the kernel tree, codes have been messed
up by -- some codes check the return value of memblock_alloc, while others not.

Thanks,
Dennis 
> 
> Thanks,
> Mark.
> 

  parent reply	other threads:[~2016-07-20  3:48 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-12  5:05 [PATCH v22 0/8] arm64: add kdump support AKASHI Takahiro
2016-07-12  5:05 ` [PATCH v22 1/8] arm64: kdump: reserve memory for crash dump kernel AKASHI Takahiro
2016-07-13  9:12   ` Suzuki K Poulose
2016-07-13 15:42     ` AKASHI Takahiro
2016-07-19  9:39   ` Dennis Chen
2016-07-19 10:28     ` AKASHI Takahiro
2016-07-19 10:41       ` Dennis Chen
2016-07-19 12:48         ` Mark Salter
2016-07-19 13:27           ` Mark Rutland
2016-07-20  2:17             ` AKASHI Takahiro
2016-07-20  3:48             ` Dennis Chen [this message]
2016-07-19 23:34           ` AKASHI Takahiro
2016-07-12  5:05 ` [PATCH v22 2/8] arm64: limit memory regions based on DT property, usable-memory-range AKASHI Takahiro
2016-07-18 18:04   ` James Morse
2016-07-19  8:35     ` AKASHI Takahiro
2016-07-19 10:06       ` Dennis Chen
2016-07-19 11:01         ` AKASHI Takahiro
2016-07-20  3:39           ` Dennis Chen
2016-07-20  4:22             ` AKASHI Takahiro
2016-07-20  4:36               ` Dennis Chen
2016-07-21  0:57     ` AKASHI Takahiro
2016-07-22 13:55       ` James Morse
2016-07-25  5:27         ` AKASHI Takahiro
2016-08-04  6:21           ` AKASHI Takahiro
2016-08-09 16:22             ` James Morse
2016-07-12  5:05 ` [PATCH v22 3/8] arm64: kdump: implement machine_crash_shutdown() AKASHI Takahiro
2016-07-13  9:32   ` Suzuki K Poulose
2016-07-13 16:00     ` AKASHI Takahiro
2016-07-12  5:05 ` [PATCH v22 4/8] arm64: kdump: add kdump support AKASHI Takahiro
2016-07-12  5:05 ` [PATCH v22 5/8] arm64: kdump: add VMCOREINFO's for user-space coredump tools AKASHI Takahiro
2016-07-12  5:05 ` [PATCH v22 6/8] arm64: kdump: enable kdump in the arm64 defconfig AKASHI Takahiro
2016-07-12  5:05 ` [PATCH v22 7/8] arm64: kdump: update a kernel doc AKASHI Takahiro
2016-07-12  5:05 ` [PATCH v22 8/8] Documentation: dt: chosen properties for arm64 kdump AKASHI Takahiro
2016-07-12 10:07   ` Mark Rutland
2016-07-13 15:14     ` AKASHI Takahiro

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=20160720034838.GB30575@arm.com \
    --to=dennis.chen@arm.com \
    --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).