From: James Morse <james.morse@arm.com>
To: AKASHI Takahiro <takahiro.akashi@linaro.org>
Cc: mark.rutland@arm.com, geoff@infradead.org,
catalin.marinas@arm.com, will.deacon@arm.com,
bauerman@linux.vnet.ibm.com, dyoung@redhat.com,
kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v33 07/14] arm64: hibernate: preserve kdump image around hibernation
Date: Tue, 21 Mar 2017 18:25:46 +0000 [thread overview]
Message-ID: <58D1702A.2010702@arm.com> (raw)
In-Reply-To: <20170315095941.25119-5-takahiro.akashi@linaro.org>
Hi Akashi,
On 15/03/17 09:59, AKASHI Takahiro wrote:
> Since arch_kexec_protect_crashkres() removes a mapping for crash dump
> kernel image, the loaded data won't be preserved around hibernation.
>
> In this patch, helper functions, kexec_prepare_suspend()/
> kexec_post_resume(), are additionally called before/after hibernation so
> that the relevant memory segments will be mapped again and preserved just
> as the others are.
>
> In addition, to minimize the size of hibernation image,
> kexec_is_chraskres_nosave() is added to pfn_is_nosave() in order to
(crashkres)
> recoginize only the pages that hold loaded crash dump kernel image as
(recognize)
> saveable. Hibernation excludes any pages that are marked as Reserved and
> yet "nosave."
Neat! I didn't think this would be possible without hacking kernel/power/snapshot.c.
I've given this a spin on Juno and Seattle, I even added debug_pagealloc, but
that doesn't trick it because your kexec_prepare_suspend() puts the mapping back.
Reviewed-by: James Morse <james.morse@arm.com>
Thanks,
James
Some nits about comments:
> diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c
> index 97a7384100f3..1e10fafa59bd 100644
> --- a/arch/arm64/kernel/hibernate.c
> +++ b/arch/arm64/kernel/hibernate.c
> @@ -286,6 +288,9 @@ int swsusp_arch_suspend(void)
> local_dbg_save(flags);
>
> if (__cpu_suspend_enter(&state)) {
> + /* make the crash dump kernel image visible/saveable */
> + kexec_prepare_suspend();
Strictly this is kdump not kexec, but the comment makes that clear.
> +
> sleep_cpu = smp_processor_id();
> ret = swsusp_save();
> } else {
> diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c
> index 02e4f929db3b..82f48db589cf 100644
> --- a/arch/arm64/kernel/machine_kexec.c
> +++ b/arch/arm64/kernel/machine_kexec.c
> @@ -220,7 +221,6 @@ void arch_kexec_protect_crashkres(void)
> kexec_crash_image->segment[i].memsz,
> PAGE_KERNEL_INVALID, true);
>
> -
Stray whitespace change from a previous patch?
> flush_tlb_all();
> }
>
> @@ -233,3 +233,74 @@ void arch_kexec_unprotect_crashkres(void)
> +/*
> + * kexec_is_crashres_nosave
> + *
> + * Return true only if a page is part of reserved memory for crash dump kernel,
> + * but does not hold any data of loaded kernel image.
> + *
> + * Note that all the pages in crash dump kernel memory have been initially
> + * marked as Reserved in kexec_reserve_crashkres_pages().
> + *
> + * In hibernation, the pages which are Reserved and yet "nosave"
> + * are excluded from the hibernation iamge. kexec_is_crashkres_nosave()
> + * does this check for crash dump kernel and will reduce the total size
> + * of hibernation image.
> + */
> +
> +bool kexec_is_crashkres_nosave(unsigned long pfn)
> +{
> + int i;
> + phys_addr_t addr;
> +
> + /* in reserved memory? */
Comment in the wrong place?
> + if (!crashk_res.end)
> + return false;
> +
> + addr = __pfn_to_phys(pfn);
(makes more sense here)
> + if ((addr < crashk_res.start) || (crashk_res.end < addr))
> + return false;
> +
> + /* not part of loaded kernel image? */
Comment in the wrong place?
> + if (!kexec_crash_image)
> + return true;
> +
(makes more sense here)
> + for (i = 0; i < kexec_crash_image->nr_segments; i++)
> + if (addr >= kexec_crash_image->segment[i].mem &&
> + addr < (kexec_crash_image->segment[i].mem +
> + kexec_crash_image->segment[i].memsz))
> + return false;
> +
> + return true;
> +}
> +
Thanks,
James
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2017-03-21 18:25 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 9:56 [PATCH v33 00/14] add kdump support AKASHI Takahiro
2017-03-15 9:59 ` [PATCH v33 01/14] memblock: add memblock_clear_nomap() AKASHI Takahiro
2017-03-15 9:59 ` [PATCH v33 02/14] memblock: add memblock_cap_memory_range() AKASHI Takahiro
2017-03-15 9:59 ` [PATCH v33 03/14] arm64: limit memory regions based on DT property, usable-memory-range AKASHI Takahiro
2017-03-15 9:59 ` [PATCH v33 04/14] arm64: kdump: reserve memory for crash dump kernel AKASHI Takahiro
2017-03-17 10:46 ` David Woodhouse
2017-03-17 11:31 ` AKASHI Takahiro
2017-03-17 11:32 ` David Woodhouse
2017-03-15 9:59 ` [PATCH v33 05/14] arm64: mm: allow for unmapping part of kernel mapping AKASHI Takahiro
2017-03-21 10:35 ` James Morse
2017-03-23 11:43 ` AKASHI Takahiro
2017-03-24 10:57 ` Ard Biesheuvel
2017-03-27 13:49 ` AKASHI Takahiro
2017-03-21 11:16 ` Ard Biesheuvel
2017-03-23 10:56 ` AKASHI Takahiro
2017-03-15 9:59 ` [PATCH v33 06/14] arm64: kdump: protect crash dump kernel memory AKASHI Takahiro
2017-03-15 9:59 ` [PATCH v33 07/14] arm64: hibernate: preserve kdump image around hibernation AKASHI Takahiro
2017-03-21 18:25 ` James Morse [this message]
2017-03-23 11:29 ` AKASHI Takahiro
2017-03-15 9:59 ` [PATCH v33 08/14] arm64: kdump: implement machine_crash_shutdown() AKASHI Takahiro
2017-03-15 9:59 ` [PATCH v33 09/14] arm64: kdump: add VMCOREINFO's for user-space tools AKASHI Takahiro
2017-03-15 9:59 ` [PATCH v33 10/14] arm64: kdump: provide /proc/vmcore file AKASHI Takahiro
2017-03-15 9:59 ` [PATCH v33 11/14] arm64: kdump: enable kdump in defconfig AKASHI Takahiro
2017-03-15 9:59 ` [PATCH v33 12/14] Documentation: kdump: describe arm64 port AKASHI Takahiro
2017-03-15 10:00 ` [PATCH v33 13/14] Documentation: dt: chosen properties for arm64 kdump AKASHI Takahiro
2017-03-15 10:01 ` [PATCH v33 14/14] efi/libstub/arm*: Set default address and size cells values for an empty dtb AKASHI Takahiro
2017-03-15 11:41 ` [PATCH v33 00/14] add kdump support David Woodhouse
2017-03-16 0:23 ` AKASHI Takahiro
2017-03-16 10:29 ` David Woodhouse
2017-03-17 11:43 ` David Woodhouse
2017-03-17 14:02 ` David Woodhouse
2017-03-17 15:04 ` Mark Rutland
2017-03-17 15:33 ` Mark Rutland
2017-03-17 15:47 ` David Woodhouse
2017-03-17 16:24 ` Mark Rutland
2017-03-17 16:59 ` Marc Zyngier
2017-03-17 17:10 ` Marc Zyngier
2017-03-17 20:03 ` David Woodhouse
2017-03-21 7:34 ` AKASHI Takahiro
2017-03-21 9:42 ` David Woodhouse
2017-03-20 12:42 ` Pratyush Anand
2017-03-22 16:55 ` Goel, Sameer
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=58D1702A.2010702@arm.com \
--to=james.morse@arm.com \
--cc=bauerman@linux.vnet.ibm.com \
--cc=catalin.marinas@arm.com \
--cc=dyoung@redhat.com \
--cc=geoff@infradead.org \
--cc=kexec@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=takahiro.akashi@linaro.org \
--cc=will.deacon@arm.com \
/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