Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B709FC433F5 for ; Thu, 23 Sep 2021 05:05:41 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A28261107 for ; Thu, 23 Sep 2021 05:05:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9A28261107 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4HFNQp6ql9z3bg8 for ; Thu, 23 Sep 2021 15:05:38 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=csgroup.eu (client-ip=93.17.235.10; helo=pegase2.c-s.fr; envelope-from=christophe.leroy@csgroup.eu; receiver=) Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4HFNQL2VZnz2yJv for ; Thu, 23 Sep 2021 15:05:11 +1000 (AEST) Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4HFNQB46S7z9sSs; Thu, 23 Sep 2021 07:05:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kX4FfphMJBx7; Thu, 23 Sep 2021 07:05:06 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4HFNQB30Dpz9sSd; Thu, 23 Sep 2021 07:05:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 454388B775; Thu, 23 Sep 2021 07:05:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 4VPyUceGHvhY; Thu, 23 Sep 2021 07:05:06 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.202.200]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E3ABC8B763; Thu, 23 Sep 2021 07:05:05 +0200 (CEST) Subject: Re: [PATCH v3 1/6] powerpc/64/interrupt: make normal synchronous interrupts enable MSR[EE] if possible To: Nicholas Piggin , linuxppc-dev@lists.ozlabs.org References: <20210922145452.352571-1-npiggin@gmail.com> <20210922145452.352571-2-npiggin@gmail.com> From: Christophe Leroy Message-ID: Date: Thu, 23 Sep 2021 07:05:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210922145452.352571-2-npiggin@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr-FR Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Le 22/09/2021 à 16:54, Nicholas Piggin a écrit : > Make synchronous interrupt handler entry wrappers enable MSR[EE] if > MSR[EE] was enabled in the interrupted context. IRQs are soft-disabled > at this point so there is no change to high level code, but it's a > masked interrupt could fire. > > This is a performance disadvantage for interrupts which do not later > call interrupt_cond_local_irq_enable(), because an an additional mtmsrd > or wrtee instruction is executed. However the important synchronous > interrupts (e.g., page fault) do enable interrupts, so the performance > disadvantage is mostly avoided. > > In the next patch, MSR[RI] enabling can be combined with MSR[EE] > enabling, which mitigates the performance drop for the former and gives > a performance advanage for the latter interrupts, on 64s machines. 64e > is coming along for the ride for now to avoid divergences with 64s in > this tricky code. > > Signed-off-by: Nicholas Piggin > --- > arch/powerpc/include/asm/interrupt.h | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/arch/powerpc/include/asm/interrupt.h b/arch/powerpc/include/asm/interrupt.h > index b76ab848aa0d..3802390d8eea 100644 > --- a/arch/powerpc/include/asm/interrupt.h > +++ b/arch/powerpc/include/asm/interrupt.h > @@ -150,7 +150,20 @@ static inline void interrupt_enter_prepare(struct pt_regs *regs, struct interrup > #ifdef CONFIG_PPC64 > if (irq_soft_mask_set_return(IRQS_ALL_DISABLED) == IRQS_ENABLED) > trace_hardirqs_off(); > - local_paca->irq_happened |= PACA_IRQ_HARD_DIS; > + > + /* > + * If the interrupt was taken with HARD_DIS clear, then enable MSR[EE]. > + * Asynchronous interrupts get here with HARD_DIS set (see below), so > + * this enables MSR[EE] for synchronous interrupts. IRQs remain > + * soft-masked. The interrupt handler may later call > + * interrupt_cond_local_irq_enable() to achieve a regular process > + * context. > + */ > + if (!(local_paca->irq_happened & PACA_IRQ_HARD_DIS)) { > + if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG)) > + BUG_ON(!(regs->msr & MSR_EE)); Could be: BUG_ON(IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG) && !(regs->msr & MSR_EE)); > + __hard_irq_enable(); > + } > > if (user_mode(regs)) { > CT_WARN_ON(ct_state() != CONTEXT_USER); > @@ -200,6 +213,10 @@ static inline void interrupt_exit_prepare(struct pt_regs *regs, struct interrupt > > static inline void interrupt_async_enter_prepare(struct pt_regs *regs, struct interrupt_state *state) > { > +#ifdef CONFIG_PPC64 > + /* Ensure interrupt_enter_prepare does not enable MSR[EE] */ > + local_paca->irq_happened |= PACA_IRQ_HARD_DIS; > +#endif > #ifdef CONFIG_PPC_BOOK3S_64 > if (cpu_has_feature(CPU_FTR_CTRL) && > !test_thread_local_flags(_TLF_RUNLATCH)) >