Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: AKASHI Takahiro <takahiro.akashi@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Geoff Levand <geoff@infradead.org>,
	kexec@lists.infradead.org, Will Deacon <will.deacon@arm.com>,
	marc.zyngier@arm.com, Catalin Marinas <catalin.marinas@arm.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v15 17/20] arm64: kdump: implement machine_crash_shutdown()
Date: Mon, 21 Mar 2016 13:29:28 +0000	[thread overview]
Message-ID: <56EFF738.1040308@arm.com> (raw)
In-Reply-To: <56EC440F.4050406@arm.com>

Hi!

On 18/03/16 18:08, James Morse wrote:
> On 14/03/16 17:48, Geoff Levand wrote:
>> From: AKASHI Takahiro <takahiro.akashi@linaro.org>
>>
>> Primary kernel calls machine_crash_shutdown() to shut down non-boot cpus
>> and save registers' status in per-cpu ELF notes before starting crash
>> dump kernel. See kernel_kexec().
>> Even if not all secondary cpus have shut down, we do kdump anyway.
>>
>> As we don't have to make non-boot(crashed) cpus offline (to preserve
>> correct status of cpus at crash dump) before shutting down, this patch
>> also adds a variant of smp_send_stop().

>> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
>> index b1adc51..76402c6cd 100644
>> --- a/arch/arm64/kernel/smp.c
>> +++ b/arch/arm64/kernel/smp.c
>> @@ -701,6 +705,28 @@ static void ipi_cpu_stop(unsigned int cpu)
>>  		cpu_relax();
>>  }
>>  
>> +static atomic_t waiting_for_crash_ipi;
>> +
>> +static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs)
>> +{
>> +	crash_save_cpu(regs, cpu);
>> +
>> +	raw_spin_lock(&stop_lock);
>> +	pr_debug("CPU%u: stopping\n", cpu);
>> +	raw_spin_unlock(&stop_lock);
>> +
>> +	atomic_dec(&waiting_for_crash_ipi);
>> +
>> +	local_irq_disable();
>> +
>> +	if (cpu_ops[cpu]->cpu_die)
>> +		cpu_ops[cpu]->cpu_die(cpu);
>> +
>> +	/* just in case */
>> +	while (1)
>> +		wfi();

Having thought about this some more: I don't think spinning like this is safe.
We need to spin with the MMU turned off, otherwise this core will pollute the
kdump kernel with TLB entries from the old page tables. Suzuki added code to
catch this happening with cpu hotplug (grep CPU_STUCK_IN_KERNEL in
arm64/for-next/core), but that won't help here. If 'CPU_STUCK_IN_KERNEL' was set
by a core, I don't think we can kexec/kdump for this reason.

Something like cpu_die() for spin-table is needed, naively I think it should
turn the MMU off, and jump back into the secondary_holding_pen, but the core
would still be stuck in the kernel, and the memory addresses associated with
secondary_holding_pen can't be re-used. (which is fine for kdump, but not kexec)


Thanks,

James


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

  reply	other threads:[~2016-03-21 13:29 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 09/20] arm64: Add back cpu_reset routines 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 11/20] Revert "arm64: remove dead code" 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 02/20] arm64: Cleanup SCTLR flags 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 08/20] arm64: Add new asm macro copy_page 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 06/20] arm64: kernel: Include _AC definition in page.h 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 01/20] arm64: Fold proc-macros.S into assembler.h 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 12/20] arm64/kexec: Add core kexec support Geoff Levand
2016-03-14 17:48 ` [PATCH v15 14/20] arm64/kexec: Add pr_debug output 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 20/20] arm64: kdump: update a kernel doc 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 19/20] arm64: kdump: enable kdump in the arm64 defconfig 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
2016-04-01  6:16       ` AKASHI Takahiro
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 [this message]
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-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=56EFF738.1040308@arm.com \
    --to=james.morse@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=geoff@infradead.org \
    --cc=kexec@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=marc.zyngier@arm.com \
    --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