Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp396721imi; Fri, 22 Jul 2022 01:12:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uPqioUyVUX4NJCYcRHVy2vvyUMbAnbSZZhFhXWm/SgEF2wksZ1tTImeWcA1cGnQgrwQaLN X-Received: by 2002:a17:902:8a82:b0:16c:3024:69c2 with SMTP id p2-20020a1709028a8200b0016c302469c2mr2456414plo.154.1658477551210; Fri, 22 Jul 2022 01:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658477551; cv=none; d=google.com; s=arc-20160816; b=mcooI2YFrwtOM7ByM85pF1w0DeRKWQe+cRN8GTXeHsZx4uN/hA7QQPHvenZkqf008d G6QZkLw9Lp7iBXtMkZs3Z04VJmkIvTE5ombEifXUoAmwwJC1W6W1JTBVONCTaiwSch2h 7EooxUG4rQW1qV4aCSvIzGjdYRumieaqyqV1ZbkjSuYzcfuk63o9uqLiilu8Cdfen/aH UfdVYr2jd/Lgtgp57Bvlw51sm7gbbZ9usa4iuThEGILuxeixpLm5BVtX31JcqiFbrmf3 2RzoIqSqm8j/bFfwiiEw65m9mfvFXK60RaN3szWL7+E+0fLBHXslkuUB2BIb48pvVaVP QSsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=iKIaSypFVYjNqK3UF0MeX1uLadeX9F3Ok+Ln5q+DbjI=; b=t1bprYJFvEQ78dDe2CmbJ9zgfQCJ9a9oI1GBejlLegObXfQfCnKXupKTWTEtuUDNyl A0IGHcPkXNKIbecPjeVjdVhzI8dL9sMTZs6mvGhuKp15PeQvZ0IjabQXIejUgnKWm02T BFRCgnXK0ya7JEF0DmgifiNP56LD0y80ydcXyOYUKA5VlM6lwbISw1paL1ZhHWfm7ksl CwkcYzANI7V9nednExADEDHv6DOR+9iXUftuURIN1eNYmceumkGu7Wfp1acPCWgqzckM DyR51wKXgKhtNtxHGZ7OMPvhG0fBvx7OsRMvl0TNNSue8SpGWFkXE0q25w1364t1LAi9 vqvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=VUqsj7ke; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 85-20020a630158000000b00419cb1b88fcsi5083520pgb.859.2022.07.22.01.12.16; Fri, 22 Jul 2022 01:12:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=VUqsj7ke; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234091AbiGVHnS (ORCPT + 99 others); Fri, 22 Jul 2022 03:43:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbiGVHnQ (ORCPT ); Fri, 22 Jul 2022 03:43:16 -0400 Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E169474CF for ; Fri, 22 Jul 2022 00:43:14 -0700 (PDT) Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-31e7ca45091so39523997b3.3 for ; Fri, 22 Jul 2022 00:43:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atishpatra.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iKIaSypFVYjNqK3UF0MeX1uLadeX9F3Ok+Ln5q+DbjI=; b=VUqsj7keIvOwEm3DCbFmxPyirWn7ZQoYV/6Oa7SWUtEp+DwZ2XdPOSzxBlZreg9Q+I OXt24U5uowN/S/d5PWcRxWvlOXhnilAgAVtmiQNQPCSaKAS/A8GfUVuZN4VvTx9NWIi3 8O7XKCNXDyKUGia51sEQkHG/LNz/1eyxPbIhc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iKIaSypFVYjNqK3UF0MeX1uLadeX9F3Ok+Ln5q+DbjI=; b=O+xml+vPByAQdFhEVmE9UB3hJLus3m9c+yWoPoRw7twcDXMVuyEvJPSFvxDkpNsIg7 996wYlN8FOqCfNQjZozJfHLqdKpi7CGdQg/3WKCwQmx0s/p0I0YZByviCDln7+UZjDGB F4UYROF3aBa2f3bQ/CpDpM6z9q0Jcy+YhcCP86bTZ+08UaErkcDgIAyWyI3KzSsHAk4w wJpOlkGQy5Iu914xn+Un4F45seZWUW2U7w4xK8I0sDwazcaHPHPkqdSo9Uk9264L+Vcm 11sXdJ06hOA8Kp+5V++9DgcfsEXrax7Z0vsOrt9fD3VegSrUtsTHttquovk89k5ek/F5 IsSQ== X-Gm-Message-State: AJIora94n/0sD58nrsVrqCIIFeRsjgO0GCPcBnNkPAw/ukChTN4Dd/x5 GXp/ulUdWWp4CzwOKEmlqAecAQVtCLKIEsXWWH8R X-Received: by 2002:a81:9182:0:b0:31e:68cd:3d5c with SMTP id i124-20020a819182000000b0031e68cd3d5cmr2003480ywg.194.1658475793496; Fri, 22 Jul 2022 00:43:13 -0700 (PDT) MIME-Version: 1.0 References: <20220717101323.370245-1-xianting.tian@linux.alibaba.com> <20220717101323.370245-3-xianting.tian@linux.alibaba.com> In-Reply-To: <20220717101323.370245-3-xianting.tian@linux.alibaba.com> From: Atish Patra Date: Fri, 22 Jul 2022 00:43:02 -0700 Message-ID: Subject: Re: [PATCH 2/5] RISC-V: use __smp_processor_id() instead of smp_processor_id() To: Xianting Tian Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , =?UTF-8?Q?Heiko_St=C3=BCbner?= , Guo Ren , Nick Kossifidis , Alexandre Ghiti , linux-riscv , "linux-kernel@vger.kernel.org List" , crash-utility@redhat.com, huanyi.xj@alibaba-inc.com, Heinrich Schuchardt , k-hagio-ab@nec.com, hschauhan@nulltrace.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 17, 2022 at 3:14 AM Xianting Tian wrote: > > Use __smp_processor_id() to avoid check the preemption context when > CONFIG_DEBUG_PREEMPT enabled, as we will enter crash kernel and no > return. > > Without the patch, > [ 103.781044] sysrq: Trigger a crash > [ 103.784625] Kernel panic - not syncing: sysrq triggered crash > [ 103.837634] CPU1: off > [ 103.889668] CPU2: off > [ 103.933479] CPU3: off > [ 103.939424] Starting crashdump kernel... > [ 103.943442] BUG: using smp_processor_id() in preemptible [00000000] code: sh/346 > [ 103.950884] caller is debug_smp_processor_id+0x1c/0x26 > [ 103.956051] CPU: 0 PID: 346 Comm: sh Kdump: loaded Not tainted 5.10.113-00002-gce03f03bf4ec-dirty #149 > [ 103.965355] Call Trace: > [ 103.967805] [] walk_stackframe+0x0/0xa2 > [ 103.973206] [] show_stack+0x32/0x3e > [ 103.978258] [] dump_stack_lvl+0x72/0x8e > [ 103.983655] [] dump_stack+0x14/0x1c > [ 103.988705] [] check_preemption_disabled+0x9e/0xaa > [ 103.995057] [] debug_smp_processor_id+0x1c/0x26 > [ 104.001150] [] machine_kexec+0x22/0xd0 > [ 104.006463] [] __crash_kexec+0x6a/0xa4 > [ 104.011774] [] panic+0xfc/0x2b0 > [ 104.016480] [] sysrq_reset_seq_param_set+0x0/0x70 > [ 104.022745] [] __handle_sysrq+0x8c/0x154 > [ 104.028229] [] write_sysrq_trigger+0x5a/0x6a > [ 104.034061] [] proc_reg_write+0x58/0xd4 > [ 104.039459] [] vfs_write+0x7e/0x254 > [ 104.044509] [] ksys_write+0x58/0xbe > [ 104.049558] [] sys_write+0xe/0x16 > [ 104.054434] [] ret_from_syscall+0x0/0x2 > [ 104.067863] Will call new kernel at ecc00000 from hart id 0 > [ 104.074939] FDT image at fc5ee000 > [ 104.079523] Bye... > > With the patch we can got clear output, > [ 67.740553] sysrq: Trigger a crash > [ 67.744166] Kernel panic - not syncing: sysrq triggered crash > [ 67.809123] CPU1: off > [ 67.865210] CPU2: off > [ 67.909075] CPU3: off > [ 67.919123] Starting crashdump kernel... > [ 67.924900] Will call new kernel at ecc00000 from hart id 0 > [ 67.932045] FDT image at fc5ee000 > [ 67.935560] Bye... > > Fixes: 0e105f1d0037 ("riscv: use hart id instead of cpu id on machine_kexec") > Reviewed-by: Guo Ren > Signed-off-by: Xianting Tian > --- > arch/riscv/kernel/machine_kexec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/riscv/kernel/machine_kexec.c b/arch/riscv/kernel/machine_kexec.c > index df8e24559035..86d1b5f9dfb5 100644 > --- a/arch/riscv/kernel/machine_kexec.c > +++ b/arch/riscv/kernel/machine_kexec.c > @@ -171,7 +171,7 @@ machine_kexec(struct kimage *image) > struct kimage_arch *internal = &image->arch; > unsigned long jump_addr = (unsigned long) image->start; > unsigned long first_ind_entry = (unsigned long) &image->head; > - unsigned long this_cpu_id = smp_processor_id(); > + unsigned long this_cpu_id = __smp_processor_id(); > unsigned long this_hart_id = cpuid_to_hartid_map(this_cpu_id); > unsigned long fdt_addr = internal->fdt_addr; > void *control_code_buffer = page_address(image->control_code_page); > -- > 2.17.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv Reviewed-by: Atish Patra -- Regards, Atish