Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2155342ybl; Sat, 7 Dec 2019 09:20:45 -0800 (PST) X-Google-Smtp-Source: APXvYqwINAVr92QLleE2DtsUwJAFFlAf/nxRLGXdxtkKWwEXlfV1nQqw0IX2Mf5jPii5HSM3eoZN X-Received: by 2002:a9d:464:: with SMTP id 91mr16452451otc.255.1575739245161; Sat, 07 Dec 2019 09:20:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575739245; cv=none; d=google.com; s=arc-20160816; b=tSUQQyptaYY8ocXHKBI11h8eODd3b6qnJ7OF8tMnkt11LQgXY5C9mpjzqb+aJoQb5q EYbEMYne3Gvgc6koX4Y4KUd9Kz+wZMh8hE+IYwjCeAIex7FJo6MadoK4B/KgiX6wF40/ 9Pqn+i88tO/IHV9BB1ouQgUGG30S4G8MJnR4d20SJ0u61bYp8LYjR6P/nHvxS5KQYMe0 /QPodw9RVHdS6LrBiN6SqA/L+KQFQTigxIq31nC7kwUJoYAU5tBKcaOHTb9qDNTPPczA BJ3lTnbdlLx85ut5Cl3CFUMB8RtdTiTpGjbr6QDuYvISMgriiwVyuTZfLISZYyqtYD0F WTYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id :dkim-signature; bh=wGJwZeRsClNhRcvPcTvmKeYbUIim15sV8rYIdLlEYjE=; b=baTYispMz8ZvZHPIBuWvoT6ohnWZvCiD+Yd0mhny/fuUd0ec+uAm4S7M8lbqOMKphS b91d26le+PQZInkurE8GTK4ZpgZa4bAacl8SG4ZOhztaIkTGViNksP8YsZqhTQQqt6uK m3WBAGiZxlbM62IpQKGhDU41BHS+hjAr4KivhF1dpY1tNVXfZOxQcrKsy9L7udu3Lvk/ sGEP5Xclt2CN2QPDifDHsUMlTJRBRUp9gAjZMwWgUdo/Xk0S9iMjh+y9KlMw9e35zyr6 SVlpr0cY0mf3XGmaxE7sUj0BVBhGXUVpj9kCabf60S5spDxxR05fYEgaaynkYpIPF9c3 OYPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=M+x2cjaW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u132si8469918oig.93.2019.12.07.09.20.33; Sat, 07 Dec 2019 09:20:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=M+x2cjaW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbfLGRUH (ORCPT + 99 others); Sat, 7 Dec 2019 12:20:07 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:45141 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726420AbfLGRUH (ORCPT ); Sat, 7 Dec 2019 12:20:07 -0500 Received: from localhost (mailhub1-ext [192.168.12.233]) by localhost (Postfix) with ESMTP id 47Vbmz65Bwz9vBLP; Sat, 7 Dec 2019 18:20:03 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=M+x2cjaW; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id IWhZ83DmAviw; Sat, 7 Dec 2019 18:20:03 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 47Vbmz4WTnz9vBLM; Sat, 7 Dec 2019 18:20:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1575739203; bh=wGJwZeRsClNhRcvPcTvmKeYbUIim15sV8rYIdLlEYjE=; h=From:Subject:To:Cc:Date:From; b=M+x2cjaWxqN4gPz82Gm0NQGkLddH8L8Fxp54s2uZ9RC/Y/A7Mr5SbaQ/KYpI+ixiQ dy3n1Wd1EzRmsohwZiaOJCGZM2gtQEk+79CKv9C3I1lw6xjH/X6klmRjHRru3sSy9L YOgETHy8kRIG2wjXdIq8SB8OQpzzLSh6afRW/Wh4= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4E78B8B7AC; Sat, 7 Dec 2019 18:20:05 +0100 (CET) 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 gw4CgMiQ6qPD; Sat, 7 Dec 2019 18:20:05 +0100 (CET) Received: from po16098vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 02DB28B772; Sat, 7 Dec 2019 18:20:05 +0100 (CET) Received: by po16098vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 756A463154; Sat, 7 Dec 2019 17:20:04 +0000 (UTC) Message-Id: <72a6cd86137b2a7ab835213cf5c74df6ed2f6ea7.1575739197.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH v5] powerpc/irq: inline call_do_irq() and call_do_softirq() on PPC32 To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Sat, 7 Dec 2019 17:20:04 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org call_do_irq() and call_do_softirq() are simple enough to be worth inlining. Inlining them avoids an mflr/mtlr pair plus a save/reload on stack. It also allows GCC to keep the saved ksp_limit in an nonvolatile reg. This is inspired from S390 arch. Several other arches do more or less the same. The way sparc arch does seems odd thought. Signed-off-by: Christophe Leroy Reviewed-by: Segher Boessenkool --- v2: no change. v3: no change. v4: - comment reminding the purpose of the inline asm block. - added r2 as clobbered reg v5: - Limiting the change to PPC32 for now. - removed r2 from the clobbered regs list (on PPC32 r2 points to current all the time) - Removed patch 1 and merged ksp_limit handling in here. --- arch/powerpc/include/asm/irq.h | 2 ++ arch/powerpc/kernel/irq.c | 48 ++++++++++++++++++++++++++++++++++++++++++ arch/powerpc/kernel/misc_32.S | 39 ---------------------------------- 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h index 814dfab7e392..e4a92f0b4ad4 100644 --- a/arch/powerpc/include/asm/irq.h +++ b/arch/powerpc/include/asm/irq.h @@ -56,8 +56,10 @@ extern void *mcheckirq_ctx[NR_CPUS]; extern void *hardirq_ctx[NR_CPUS]; extern void *softirq_ctx[NR_CPUS]; +#ifdef CONFIG_PPC64 void call_do_softirq(void *sp); void call_do_irq(struct pt_regs *regs, void *sp); +#endif extern void do_IRQ(struct pt_regs *regs); extern void __init init_IRQ(void); extern void __do_irq(struct pt_regs *regs); diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index 5645bc9cbc09..240eca12c71d 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c @@ -611,6 +611,54 @@ static inline void check_stack_overflow(void) #endif } +#ifdef CONFIG_PPC32 +static inline void call_do_softirq(const void *sp) +{ + register unsigned long ret asm("r3"); + unsigned long limit = current->thread.ksp_limit; + + /* Adjust the stack limit */ + current->thread.ksp_limit = (unsigned long)sp; + + /* Temporarily switch r1 to sp, call __do_softirq() then restore r1. */ + asm volatile( + " "PPC_STLU" 1, %2(%1);\n" + " mr 1, %1;\n" + " bl %3;\n" + " "PPC_LL" 1, 0(1);\n" : + "=r"(ret) : + "b"(sp), "i"(THREAD_SIZE - STACK_FRAME_OVERHEAD), "i"(__do_softirq) : + "lr", "xer", "ctr", "memory", "cr0", "cr1", "cr5", "cr6", "cr7", + "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"); + + /* Restore stack limit */ + current->thread.ksp_limit = limit; +} + +static inline void call_do_irq(struct pt_regs *regs, void *sp) +{ + register unsigned long r3 asm("r3") = (unsigned long)regs; + unsigned long limit = current->thread.ksp_limit; + + /* Adjust the stack limit */ + current->thread.ksp_limit = (unsigned long)sp; + + /* Temporarily switch r1 to sp, call __do_irq() then restore r1 */ + asm volatile( + " "PPC_STLU" 1, %2(%1);\n" + " mr 1, %1;\n" + " bl %3;\n" + " "PPC_LL" 1, 0(1);\n" : + "+r"(r3) : + "b"(sp), "i"(THREAD_SIZE - STACK_FRAME_OVERHEAD), "i"(__do_irq) : + "lr", "xer", "ctr", "memory", "cr0", "cr1", "cr5", "cr6", "cr7", + "r0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"); + + /* Restore stack limit */ + current->thread.ksp_limit = limit; +} +#endif + void __do_irq(struct pt_regs *regs) { unsigned int irq; diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S index d80212be8698..341a3cd199cb 100644 --- a/arch/powerpc/kernel/misc_32.S +++ b/arch/powerpc/kernel/misc_32.S @@ -28,45 +28,6 @@ .text /* - * We store the saved ksp_limit in the unused part - * of the STACK_FRAME_OVERHEAD - */ -_GLOBAL(call_do_softirq) - mflr r0 - stw r0,4(r1) - lwz r10,THREAD+KSP_LIMIT(r2) - stw r3, THREAD+KSP_LIMIT(r2) - stwu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r3) - mr r1,r3 - stw r10,8(r1) - bl __do_softirq - lwz r10,8(r1) - lwz r1,0(r1) - lwz r0,4(r1) - stw r10,THREAD+KSP_LIMIT(r2) - mtlr r0 - blr - -/* - * void call_do_irq(struct pt_regs *regs, void *sp); - */ -_GLOBAL(call_do_irq) - mflr r0 - stw r0,4(r1) - lwz r10,THREAD+KSP_LIMIT(r2) - stw r4, THREAD+KSP_LIMIT(r2) - stwu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r4) - mr r1,r4 - stw r10,8(r1) - bl __do_irq - lwz r10,8(r1) - lwz r1,0(r1) - lwz r0,4(r1) - stw r10,THREAD+KSP_LIMIT(r2) - mtlr r0 - blr - -/* * This returns the high 64 bits of the product of two 64-bit numbers. */ _GLOBAL(mulhdu) -- 2.13.3