All of lore.kernel.org
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v22 1/8] arm64: kdump: reserve memory for crash dump kernel
Date: Tue, 19 Jul 2016 14:27:54 +0100	[thread overview]
Message-ID: <20160719132736.GB21007@leverpostej> (raw)
In-Reply-To: <1468932537.27473.6.camel@redhat.com>

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);
}

Thanks,
Mark.

WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: Mark Salter <msalter@redhat.com>
Cc: Pratyush Anand <panand@redhat.com>,
	geoff@infradead.org, catalin.marinas@arm.com,
	will.deacon@arm.com, AKASHI Takahiro <takahiro.akashi@linaro.org>,
	robh+dt@kernel.org, james.morse@arm.com,
	bauerman@linux.vnet.ibm.com, Dennis Chen <dennis.chen@arm.com>,
	nd@arm.com, dyoung@redhat.com, kexec@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v22 1/8] arm64: kdump: reserve memory for crash dump kernel
Date: Tue, 19 Jul 2016 14:27:54 +0100	[thread overview]
Message-ID: <20160719132736.GB21007@leverpostej> (raw)
In-Reply-To: <1468932537.27473.6.camel@redhat.com>

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);
}

Thanks,
Mark.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2016-07-19 13:27 UTC|newest]

Thread overview: 70+ 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 ` AKASHI Takahiro
2016-07-12  5:05 ` [PATCH v22 1/8] arm64: kdump: reserve memory for crash dump kernel AKASHI Takahiro
2016-07-12  5:05   ` AKASHI Takahiro
2016-07-13  9:12   ` Suzuki K Poulose
2016-07-13  9:12     ` Suzuki K Poulose
2016-07-13 15:42     ` AKASHI Takahiro
2016-07-13 15:42       ` AKASHI Takahiro
2016-07-19  9:39   ` Dennis Chen
2016-07-19  9:39     ` Dennis Chen
2016-07-19 10:28     ` AKASHI Takahiro
2016-07-19 10:28       ` AKASHI Takahiro
2016-07-19 10:41       ` Dennis Chen
2016-07-19 10:41         ` Dennis Chen
2016-07-19 12:48         ` Mark Salter
2016-07-19 12:48           ` Mark Salter
2016-07-19 13:27           ` Mark Rutland [this message]
2016-07-19 13:27             ` Mark Rutland
2016-07-20  2:17             ` AKASHI Takahiro
2016-07-20  2:17               ` AKASHI Takahiro
2016-07-20  3:48             ` Dennis Chen
2016-07-20  3:48               ` Dennis Chen
2016-07-19 23:34           ` AKASHI Takahiro
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-12  5:05   ` AKASHI Takahiro
2016-07-18 18:04   ` James Morse
2016-07-18 18:04     ` James Morse
2016-07-19  8:35     ` AKASHI Takahiro
2016-07-19  8:35       ` AKASHI Takahiro
2016-07-19 10:06       ` Dennis Chen
2016-07-19 10:06         ` Dennis Chen
2016-07-19 11:01         ` AKASHI Takahiro
2016-07-19 11:01           ` AKASHI Takahiro
2016-07-20  3:39           ` Dennis Chen
2016-07-20  3:39             ` Dennis Chen
2016-07-20  4:22             ` AKASHI Takahiro
2016-07-20  4:22               ` AKASHI Takahiro
2016-07-20  4:36               ` Dennis Chen
2016-07-20  4:36                 ` Dennis Chen
2016-07-21  0:57     ` AKASHI Takahiro
2016-07-21  0:57       ` AKASHI Takahiro
2016-07-22 13:55       ` James Morse
2016-07-22 13:55         ` James Morse
2016-07-25  5:27         ` AKASHI Takahiro
2016-07-25  5:27           ` AKASHI Takahiro
2016-08-04  6:21           ` AKASHI Takahiro
2016-08-04  6:21             ` AKASHI Takahiro
2016-08-09 16:22             ` James Morse
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-12  5:05   ` AKASHI Takahiro
2016-07-13  9:32   ` Suzuki K Poulose
2016-07-13  9:32     ` Suzuki K Poulose
2016-07-13 16:00     ` AKASHI Takahiro
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   ` 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   ` 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   ` AKASHI Takahiro
2016-07-12  5:05 ` [PATCH v22 7/8] arm64: kdump: update a kernel doc AKASHI Takahiro
2016-07-12  5:05   ` AKASHI Takahiro
2016-07-12  5:05 ` [PATCH v22 8/8] Documentation: dt: chosen properties for arm64 kdump AKASHI Takahiro
2016-07-12  5:05   ` AKASHI Takahiro
2016-07-12 10:07   ` Mark Rutland
2016-07-12 10:07     ` Mark Rutland
2016-07-13 15:14     ` AKASHI Takahiro
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=20160719132736.GB21007@leverpostej \
    --to=mark.rutland@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.