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 784E3ECAAA3 for ; Fri, 26 Aug 2022 06:23:42 +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:Date: Message-ID:From:References:CC:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HOWg8ZYbTdqiXKLl5EVlOBCqlQe6ueb2dqJbwZfmM9s=; b=SZ+glVNjrvPabiXPoVTn+ILHuN 14gb3ACwNv2Itdt9pyxPNejCMTo59vuS8Yu7AW1O7TOtcYXiJ971hwTuCiC+YGHyZ3q6UpY4BUNcH et7h1F0xXcJsZcv9TAMIrdyphq34ustFcpS3vjlHPH2qNMXY24m+lrZLz0+t56qoaZl7S7YLnB8jn i2KiQ30J0V+nnaY1rkZOSidYy8GiCJpfISlbnt01ekkOSydTHA1kTFvwIt/devWzuvd1yX2FIjgVi AMWv53wNWG5mbDjuACFPiWKLg3qYMKON7Blo0e5Hay1b3fQp9qkiuwEdppPVpILZXUSXvFBIehoZY VTyXUAMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oRSjt-00Ec2N-Nv; Fri, 26 Aug 2022 06:22:45 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oRSjn-00EbzC-Ss for linux-arm-kernel@lists.infradead.org; Fri, 26 Aug 2022 06:22:42 +0000 Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MDV5x6bRWz19VbC; Fri, 26 Aug 2022 14:19:01 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 14:22:34 +0800 Received: from [10.174.178.55] (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 26 Aug 2022 14:22:33 +0800 Subject: Re: [PATCH 2/2] ARM: Replace this_cpu_* with raw_cpu_* in panic_bad_stack() To: Mark Rutland CC: Catalin Marinas , Will Deacon , Russell King , , , References: <20220825063154.69-1-thunder.leizhen@huawei.com> <20220825063154.69-3-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: <7a905d7a-9670-a672-07ca-4e2ed37a35ac@huawei.com> Date: Fri, 26 Aug 2022 14:22:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220825_232240_316743_24E30B4A X-CRM114-Status: GOOD ( 21.47 ) 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 2022/8/25 21:32, Mark Rutland wrote: > 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. Yes, right. Sorry, I'm stuck in this_cpu_read()'s analysis. > > 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. OK, I will delete the description about risk. The risk I mentioned in the commit message was mainly to show that using raw_cpu_read() would be better than using this_cpu_read() in this case. > > 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 >> > . > -- Regards, Zhen Lei _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel