Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1549768imd; Thu, 1 Nov 2018 18:18:52 -0700 (PDT) X-Google-Smtp-Source: AJdET5d0+PmvB/u0QjtkN/YOU1OQj3kLUWm3sAlxYlrih67WQy303+90WOLqqUxe0DFeVKjCJiR4 X-Received: by 2002:a62:de84:: with SMTP id h126-v6mr9810601pfg.129.1541121532930; Thu, 01 Nov 2018 18:18:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541121532; cv=none; d=google.com; s=arc-20160816; b=WYyWCR9tncCLpX3NE7olC+cn4E3ARE/UetYgcehoddh7SnFDjBxIGRaoWzJDJZFqca B1Hjun4LIbe5kQUTj94q8BVE0N1hldF2VE16oauC+2DAuteYZ3OVSH7OcScf4OJVRljm AfmV90ytYm+zjTKCq9fiJWDi/PjSqzBhOnZ5Oo7hotYWv1iCFOZ/CCVmFVBXuhwrQ+q6 2SH8coZU3MP7l1q/rLOoFER1GQ80RtyFwDOYXUjqz4Yih/cd/Quk74U7kUxYNWn5AWAN RHZRGY+PWirEkkj+QIBm/X3b/b94chwFMRxl5jbYXWTNeP+yNg2/JFzvrUHpVeWnm7/r inOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=rS0b5Dtibeln3vCa6vtqfYoQxFAT6GwslUhnvK12ekM=; b=gcAIb08oAaRvpUKkwleQvOCDIstxBF9gTBFNjw15neCf4rjG8uD0xfJnxQCoffvqdj ThUJcy8/3ozzkAd4v2Ng4n1C35zDbw4hRd6Q27jJ0uF97EZmkwAFDcOcbG5wpaKYzsTX vZ2WCDMQaXdtcMT6EBKMNUBNoFfh0iZBZjiy0JxSpS6vVnJcpo62KKEghcVHGq604SHc Oe6Co6WBczNxQCdw3v6PJ7nXPtenim2R0tkBViNjDtdPVuaRsuwyyxBSVdcvMIkcL6fo 4Ipj3QTvF860hOlFxkJuUy0T9yAMG/wRCigc4aSLFG4i7SEYkQzQf4D5vbwhd2iS634q IpHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3-v6si28191346pld.137.2018.11.01.18.18.23; Thu, 01 Nov 2018 18:18:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726190AbeKBKWz (ORCPT + 99 others); Fri, 2 Nov 2018 06:22:55 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:46913 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725961AbeKBKWz (ORCPT ); Fri, 2 Nov 2018 06:22:55 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 2E6A1D09CC4A7; Fri, 2 Nov 2018 09:17:34 +0800 (CST) Received: from [127.0.0.1] (10.177.25.132) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.408.0; Fri, 2 Nov 2018 09:17:26 +0800 Subject: Re: [PATCH] ARM:kexec:offline panic_smp_self_stop CPU To: Russell King - ARM Linux References: <1541071249-15660-1-git-send-email-wangyufen@huawei.com> <20181101113430.GO30658@n2100.armlinux.org.uk> CC: , , , , , , , , , From: wangyufen Message-ID: <5BDBA58C.9090803@huawei.com> Date: Fri, 2 Nov 2018 09:17:00 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20181101113430.GO30658@n2100.armlinux.org.uk> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.132] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/11/1 19:34, Russell King - ARM Linux wrote: > On Thu, Nov 01, 2018 at 07:20:49PM +0800, Wang Yufen wrote: >> From: Yufen Wang >> >> In case panic() and panic() called at the same time on different CPUS. >> For example: >> CPU 0: >> panic() >> __crash_kexec >> machine_crash_shutdown >> crash_smp_send_stop >> machine_kexec >> BUG_ON(num_online_cpus() > 1); >> >> CPU 1: >> panic() >> local_irq_disable >> panic_smp_self_stop >> >> If CPU 1 calls panic_smp_self_stop() before crash_smp_send_stop(), kdump >> fails. CPU1 can't receive the ipi irq, CPU1 will be always online. >> I changed BUG_ON to WARN in kexec crash as arm64 does, kdump also fails. >> Because num_online_cpus() > 1, can't disable the L2 in _soft_restart. >> To fix this problem, this patch split out the panic_smp_self_stop() >> and add set_cpu_online(smp_processor_id(), false). > Thanks. > > I think this may as well go into arch/arm/kernel/smp.c - it won't be > required for single-CPU systems, since there aren't "other" CPUs. > > It's probably also worth a comment above the function as to why we > have this. Thanks. I will send v2. >> Signed-off-by: Yufen Wang >> --- >> arch/arm/kernel/setup.c | 10 ++++++++++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c >> index 31940bd..151861f 100644 >> --- a/arch/arm/kernel/setup.c >> +++ b/arch/arm/kernel/setup.c >> @@ -602,6 +602,16 @@ static void __init smp_build_mpidr_hash(void) >> } >> #endif >> >> +void panic_smp_self_stop(void) >> +{ >> + printk(KERN_DEBUG "CPU %u will stop doing anything useful since another CPU has paniced\n", >> + smp_processor_id()); >> + set_cpu_online(smp_processor_id(), false); >> + while (1) >> + cpu_relax(); >> + >> +} >> + >> static void __init setup_processor(void) >> { >> struct proc_info_list *list; >> -- >> 2.7.4 >> >>