From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7690AC28D13 for ; Thu, 25 Aug 2022 13:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=taN4iJ/GWcB6s/240l22djrPaxB3iyGlf/NIeJZnTz0=; b=domPWx/4sIUCpW lcPZfinwDISkJmG/qtwRsXkhKKCr1PU4GxN/nBJKvOC6LUQl9oV9QU8PFaA30V6VEjMdYo/1WFXmn gA7T4RX71ekLL6rpmRDwVxKKEweku5O6AwYLALHKBf5c6r31hpzgPTU2UGEPMUqD4SG3Ft4SpSb92 Zi1bHriKsJAqA1k5SfNll5R3xUQzY+GbyLO1Qqi1ZXxa7mQ9ODAaTOL7rOuaP6+CABc1EVbIsGTWh /akTmVS2Qac1nVGHwNFMtQ6knv/a7aBpdShj15B5ibNRt/UrxglU4Z9vw2SRz26NXNSeH6Nc5Zhvg PqlQPLejsIBCvOzDW/KQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oRCyl-00Eq2k-Ay; Thu, 25 Aug 2022 13:33:03 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oRCyX-00Epvu-IV for linux-arm-kernel@lists.infradead.org; Thu, 25 Aug 2022 13:32:52 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6ABA3D6E; Thu, 25 Aug 2022 06:32:52 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.47.11]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 902443F71A; Thu, 25 Aug 2022 06:32:46 -0700 (PDT) Date: Thu, 25 Aug 2022 14:32:43 +0100 From: Mark Rutland To: Zhen Lei Cc: Catalin Marinas , Will Deacon , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, patches@armlinux.org.uk Subject: Re: [PATCH 2/2] ARM: Replace this_cpu_* with raw_cpu_* in panic_bad_stack() Message-ID: References: <20220825063154.69-1-thunder.leizhen@huawei.com> <20220825063154.69-3-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220825063154.69-3-thunder.leizhen@huawei.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220825_063249_685239_0A9CA9D8 X-CRM114-Status: GOOD ( 21.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Aug 25, 2022 at 02:31:54PM +0800, Zhen Lei wrote: > The hardware automatically disable the IRQ interrupt before jumping to the > interrupt or exception vector. Therefore, the preempt_disable() operation > in this_cpu_read() after macro expansion is unnecessary. In fact, function > this_cpu_read() may trigger scheduling, see pseudocode below. > > Pseudocode of this_cpu_read(xx): > preempt_disable_notrace(); > raw_cpu_read(xx); > if (unlikely(__preempt_count_dec_and_test())) > __preempt_schedule_notrace(); > > Therefore, use raw_cpu_* instead of this_cpu_* to eliminate potential > hazards. At the very least, it reduces a few lines of assembly code. I think if scheduling is a problem here, something should increment the preempt_count as is done on arm64, since any other operation in this function could end up causing preemption. Regardless, I also think it's sensible to use raw_cpu_*() here, but I don't think that actually fixes the problem the commit message describes. Thanks, Mark. > > Signed-off-by: Zhen Lei > --- > KernelVersion: v6.0-rc2 > arch/arm/kernel/traps.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c > index 1518a1f443ff866..d5903d790cf3b7e 100644 > --- a/arch/arm/kernel/traps.c > +++ b/arch/arm/kernel/traps.c > @@ -927,9 +927,9 @@ asmlinkage void handle_bad_stack(struct pt_regs *regs) > { > unsigned long tsk_stk = (unsigned long)current->stack; > #ifdef CONFIG_IRQSTACKS > - unsigned long irq_stk = (unsigned long)this_cpu_read(irq_stack_ptr); > + unsigned long irq_stk = (unsigned long)raw_cpu_read(irq_stack_ptr); > #endif > - unsigned long ovf_stk = (unsigned long)this_cpu_read(overflow_stack_ptr); > + unsigned long ovf_stk = (unsigned long)raw_cpu_read(overflow_stack_ptr); > > console_verbose(); > pr_emerg("Insufficient stack space to handle exception!"); > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel