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 109ADC433EF for ; Thu, 14 Jul 2022 11:56:03 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wXFb4kJpZX9tTFxtLDOvZc84s+Ck4eLsDUXhPmaq9xg=; b=wZss00YAOAPc1g SfHB6ZmMX0GNSH7jozxMb2t3dVcWrFKrRTWorbFmTlhxYxIb1x4dMrr+cttu0D8FYlR7wEBCKc4D7 rwCLgDbsa2aJ9fZgsFOnYYtflvND/qDKuoR2RBZXrUs4ZOLLuD9GgOi4xzK/61rbB9j1JFDq3j42+ le+3EC8LyDAmGbwUuLFTWnH8eqsS1TyaT0Dl2VQM7p0uSUtWYUooM8Jb29hsNhGo/ps0rMQdOeTvI YO09SCzswiS+PmY4gnWEk3TfwjzVf98WroW4PfwL+Lv80dpKOIzfcM5xNUMspsznoV6Ey65NXP+V+ jLOZJQa/KX59Z9BBof/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBxQm-00Dxez-Ap; Thu, 14 Jul 2022 11:54:56 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBxQi-00DxdT-Od for linux-arm-kernel@lists.infradead.org; Thu, 14 Jul 2022 11:54:54 +0000 Received: by mail-pf1-x430.google.com with SMTP id c3so702792pfb.13 for ; Thu, 14 Jul 2022 04:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=Lw6dnWKKf4qYinOk7C7qoIKvJa0rmL56nHVIzziCEDI=; b=LIrXPCC8wiHlukGZGVzI7u9C86bEcSuRxsq9P6/WWy40nR5ozfBg1vYRS9g6LqZMiL tYKXth80mnKIVrrg9Sj+iQWEM80ciFVFTqdxi0pHtS2gq1TkEOae1K5CRWE22bHdAYCE /vLE87kwEJEblkmittiPWzQ9Fgq8k4SpwMpUbZb4WfOqd3eblhgOsmxa6y5EMoy0MbC7 vtwJlmGjyOY/EOAdudS0V8l9LC7qfpf0IXvezSC+jFjzciYJH2WoK2a5lzJMcpkgpeOG vXTT4Wru143zHM2R/S/pvKytEqucLL8d8t9Y1+AIb22ZkOU9fRwHbrUShSRwEHhEIxRv nvNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Lw6dnWKKf4qYinOk7C7qoIKvJa0rmL56nHVIzziCEDI=; b=lGNjodliqu4J1K6NezH0MApz5ELFTVIOBDrhr51NF+NmNS9yfFVP3KxpKwLGxTMwmm Fkbr2CX3fAvp2A5fGHUA8+3gaJozMllVAvY7+c/N7QPqnOp4ebiPiywa6RGHApvQgsjm CaNfbhQ0mkvQrPutWnYhOgv8f3madr2JomoWiJPBhVST+R0EVENFgVyhLlZqNJ8czkuc HryacZkh5BcmMwwQ6iYYoxLd6pIDLQMY0yhjQHAJnL0jkVQZyG2swDMbUx20Qq0p7hKV QTnOtCV/OcHnfIDqT4ONyBVsrOGeH39QwuoYyTpwqMbnvyvfNYHCpoDvtR+mWkTb7yVZ ycsA== X-Gm-Message-State: AJIora8rN3GvOa2TdnmkwZpq1zT/q18MxwdYQCZ+YoJ776JrKYKOgR4U t40eABUufBL4ktSK/i/wXGUg9pqL7xoQ+g== X-Google-Smtp-Source: AGRyM1v7WqNekkji8fncoQyJjBPV5eBEMePg10c+cAzpKj2TVT3H27OevIw7VvL6kM9a7cMZPEj5rw== X-Received: by 2002:a63:6d5:0:b0:412:ac9d:814e with SMTP id 204-20020a6306d5000000b00412ac9d814emr7650867pgg.90.1657799691567; Thu, 14 Jul 2022 04:54:51 -0700 (PDT) Received: from [10.4.227.66] ([139.177.225.237]) by smtp.gmail.com with ESMTPSA id s67-20020a625e46000000b005258df7615bsm1481113pfb.0.2022.07.14.04.54.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Jul 2022 04:54:51 -0700 (PDT) Message-ID: <3afacff7-e559-b7b5-c65b-414ff988e696@bytedance.com> Date: Thu, 14 Jul 2022 19:54:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.0 Subject: Re: [PATCH v1 2/2] arm64: support HAVE_IRQ_EXIT_ON_IRQ_STACK Content-Language: en-US To: Arnd Bergmann Cc: Catalin Marinas , Will Deacon , Linux ARM , Linux Kernel Mailing List , Mark Rutland References: <20220708094950.41944-1-zhengqi.arch@bytedance.com> <20220708094950.41944-3-zhengqi.arch@bytedance.com> From: Qi Zheng In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220714_045452_839263_240C6895 X-CRM114-Status: GOOD ( 22.91 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2022/7/14 19:37, Arnd Bergmann wrote: > On Fri, Jul 8, 2022 at 11:49 AM Qi Zheng wrote: >> >> Since softirqs are handled on the per-CPU IRQ stack, >> let's support HAVE_IRQ_EXIT_ON_IRQ_STACK which causes >> the core code to invoke __do_softirq() directly without >> going through do_softirq_own_stack(). >> >> Signed-off-by: Qi Zheng > > Adding Mark Rutland to Cc, he's the one that worked on this area the most in the > past and should probably review your patch. I still feel like there > should be a way > to improve readability of the IRQ entry path rather than just adding another Got it. And looking forward to reviews and suggestions from Mark or anyone else. > level of indirection, but the ideas I had so far have not led to > anything useful. > > Overall I suppose your version is an improvement over the extra double stack > switch when entering softirq. > > Arnd Thanks, Qi > >> --- >> arch/arm64/Kconfig | 1 + >> arch/arm64/include/asm/exception.h | 4 +++- >> arch/arm64/kernel/entry-common.c | 30 ++++++++++++++++++++---------- >> arch/arm64/kernel/entry.S | 6 ++++-- >> arch/arm64/kernel/irq.c | 5 +++-- >> 5 files changed, 31 insertions(+), 15 deletions(-) >> >> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig >> index be0a9f0052ee..d2cc7daecce3 100644 >> --- a/arch/arm64/Kconfig >> +++ b/arch/arm64/Kconfig >> @@ -231,6 +231,7 @@ config ARM64 >> select TRACE_IRQFLAGS_SUPPORT >> select TRACE_IRQFLAGS_NMI_SUPPORT >> select HAVE_SOFTIRQ_ON_OWN_STACK >> + select HAVE_IRQ_EXIT_ON_IRQ_STACK >> help >> ARM 64-bit (AArch64) Linux support. >> >> diff --git a/arch/arm64/include/asm/exception.h b/arch/arm64/include/asm/exception.h >> index d94aecff9690..8bff0aa7ab50 100644 >> --- a/arch/arm64/include/asm/exception.h >> +++ b/arch/arm64/include/asm/exception.h >> @@ -54,7 +54,9 @@ asmlinkage void el0t_32_fiq_handler(struct pt_regs *regs); >> asmlinkage void el0t_32_error_handler(struct pt_regs *regs); >> >> asmlinkage void call_on_irq_stack(struct pt_regs *regs, >> - void (*func)(struct pt_regs *)); >> + void (*func)(struct pt_regs *), >> + void (*do_func)(struct pt_regs *, >> + void (*)(struct pt_regs *))); >> asmlinkage void asm_exit_to_user_mode(struct pt_regs *regs); >> >> void do_mem_abort(unsigned long far, unsigned long esr, struct pt_regs *regs); >> diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c >> index c75ca36b4a49..935d1ab150b5 100644 >> --- a/arch/arm64/kernel/entry-common.c >> +++ b/arch/arm64/kernel/entry-common.c >> @@ -266,14 +266,16 @@ static void __sched arm64_preempt_schedule_irq(void) >> } >> >> static void do_interrupt_handler(struct pt_regs *regs, >> - void (*handler)(struct pt_regs *)) >> + void (*handler)(struct pt_regs *), >> + void (*do_handler)(struct pt_regs *, >> + void (*)(struct pt_regs *))) >> { >> struct pt_regs *old_regs = set_irq_regs(regs); >> >> if (on_thread_stack()) >> - call_on_irq_stack(regs, handler); >> + call_on_irq_stack(regs, handler, do_handler); >> else >> - handler(regs); >> + do_handler(regs, handler); >> >> set_irq_regs(old_regs); >> } >> @@ -441,22 +443,32 @@ asmlinkage void noinstr el1h_64_sync_handler(struct pt_regs *regs) >> } >> } >> >> +static void nmi_handler(struct pt_regs *regs, void (*handler)(struct pt_regs *)) >> +{ >> + handler(regs); >> +} >> + >> static __always_inline void __el1_pnmi(struct pt_regs *regs, >> void (*handler)(struct pt_regs *)) >> { >> arm64_enter_nmi(regs); >> - do_interrupt_handler(regs, handler); >> + do_interrupt_handler(regs, handler, nmi_handler); >> arm64_exit_nmi(regs); >> } >> >> +static void irq_handler(struct pt_regs *regs, void (*handler)(struct pt_regs *)) >> +{ >> + irq_enter_rcu(); >> + handler(regs); >> + irq_exit_rcu(); >> +} >> + >> static __always_inline void __el1_irq(struct pt_regs *regs, >> void (*handler)(struct pt_regs *)) >> { >> enter_from_kernel_mode(regs); >> >> - irq_enter_rcu(); >> - do_interrupt_handler(regs, handler); >> - irq_exit_rcu(); >> + do_interrupt_handler(regs, handler, irq_handler); >> >> arm64_preempt_schedule_irq(); >> >> @@ -699,9 +711,7 @@ static void noinstr el0_interrupt(struct pt_regs *regs, >> if (regs->pc & BIT(55)) >> arm64_apply_bp_hardening(); >> >> - irq_enter_rcu(); >> - do_interrupt_handler(regs, handler); >> - irq_exit_rcu(); >> + do_interrupt_handler(regs, handler, irq_handler); >> >> exit_to_user_mode(regs); >> } >> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S >> index 254fe31c03a0..1c351391f6bd 100644 >> --- a/arch/arm64/kernel/entry.S >> +++ b/arch/arm64/kernel/entry.S >> @@ -867,7 +867,9 @@ NOKPROBE(ret_from_fork) >> >> /* >> * void call_on_irq_stack(struct pt_regs *regs, >> - * void (*func)(struct pt_regs *)); >> + * void (*func)(struct pt_regs *) >> + * void (*do_func)(struct pt_regs *, >> + * void (*)(struct pt_regs *))); >> * >> * Calls func(regs) using this CPU's irq stack and shadow irq stack. >> */ >> @@ -886,7 +888,7 @@ SYM_FUNC_START(call_on_irq_stack) >> >> /* Move to the new stack and call the function there */ >> mov sp, x16 >> - blr x1 >> + blr x2 >> >> /* >> * Restore the SP from the FP, and restore the FP and LR from the frame >> diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c >> index c36ad20a52f3..003db605bc4f 100644 >> --- a/arch/arm64/kernel/irq.c >> +++ b/arch/arm64/kernel/irq.c >> @@ -73,14 +73,15 @@ static void init_irq_stacks(void) >> #endif >> >> #ifndef CONFIG_PREEMPT_RT >> -static void ____do_softirq(struct pt_regs *regs) >> +static void ____do_softirq(struct pt_regs *regs, >> + void (*handler)(struct pt_regs *)) >> { >> __do_softirq(); >> } >> >> void do_softirq_own_stack(void) >> { >> - call_on_irq_stack(NULL, ____do_softirq); >> + call_on_irq_stack(NULL, NULL, ____do_softirq); >> } >> #endif >> >> -- >> 2.20.1 >> -- Thanks, Qi _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel