Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2838013ybc; Wed, 20 Nov 2019 22:17:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwG/bK86kI5zjzQ4UULseFFyT7VIr+Nt6yYwqJk+bpX7PYGMKBQIXBUhY1K4qZWVRXG7tWR X-Received: by 2002:a17:906:69d7:: with SMTP id g23mr11288175ejs.20.1574317047611; Wed, 20 Nov 2019 22:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574317047; cv=none; d=google.com; s=arc-20160816; b=KTmvcojKLyexvPh3JbA7lcUNGpcT7ZKhBLkKd4dtIQruid7CniOyx9prr9ioaPYu2s 835r2Q/P7kIu/Q0L1lNZ5+QNS0cr0ksJ3sXKeGZX89mdC1g9iLr7CNa7oLni/cBl4jcL EGHp+cWKKAFAdbWC023vpYqlZ6ybiJ56BzUoDTYy+p1mqemisdbE1X2FTcIZD6bXrEBs 8Fx2V5c6OR2FxEe4qKbcCYMrfcZejEq2VGYmnOrRTUC4awBVLn4gwWDeq3WtoAAwnNzu 8ojPRyKxR2e1vm6H3eg86OVLIo/W9unGF5rPQdF9TYzfXDBCiRb1btz5p7NqN8fd/Eld YcNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=LDsUJpkk5pgvnVH8L4WW/pBquHGsHTUO4GaS8yOaCDs=; b=CtjO1eQ2/sqG7nCdJ/TgLAw4sPsSrqLUX/KoxwbWsXdJ7Q+W/iFYBpzjUG9dDnK82g Ws7phwi4FbluU1gy1TUV+7Oi7azdRXuaSWC7HEADzWAt/iA6+iwiqL9D/SLu0IDBgG8b qhcmuDwmdDXgkwPHe9BSyAzucyXMCCRKfaf5FrzYwnqhIJDP8zuFeUTmCFEym0cP1Gb2 KK1jfpk16Q/TPIpfaHnRrWlDA2bxdmcL0gw774GaHNG3YmCsHxZUFlhRlEp/nkOw6p6B zi1/weWvp+bUyQSGhw1vgkQgHII8FK8z8/7BgJeABkGtItKlw1GxUpj9TaQi7512Ff+X qztQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=bYt8f7gv; 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 g17si1314675edh.379.2019.11.20.22.17.01; Wed, 20 Nov 2019 22:17:27 -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=@ellerman.id.au header.s=201909 header.b=bYt8f7gv; 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 S1726437AbfKUGOv (ORCPT + 99 others); Thu, 21 Nov 2019 01:14:51 -0500 Received: from ozlabs.org ([203.11.71.1]:57627 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725842AbfKUGOv (ORCPT ); Thu, 21 Nov 2019 01:14:51 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 47JTmm1znCz9sPL; Thu, 21 Nov 2019 17:14:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1574316888; bh=jdKLsx29Q9L7/ElLtLnnBgAqSCKsEsGccFSh1cgYUzQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=bYt8f7gvy84TtwIJFpoHoCsN1Ip6mXbPnA3PKhBuLT6ZDv9SABp/q+fdL2ju85J8S Unr/SuCxT0jHSOFG1/rcDMDoLCv+0isuRc/8vXUOH691JLFpbuto2U1K2pb7Qh8C9G phdT9SUlqtQWry5HZkg4RnA3bOCkoF47YbNzZjSy2hxyFP8W227en1MMQz4q7xziMr AKQMbY6db0esZNwhFtUvmIHVEFo7NoDB5Xz52x9RFVtTlcMboj5mdWneAeCHIMdudV fRoEK5FDmMUbxXJ9+adoXYs6ipY5sBDtp++6B3x4bWChN70af3/OfG3VvfwZPyBbGZ w4Hd8xt01XjLw== From: Michael Ellerman To: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , segher@kernel.crashing.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v4 2/2] powerpc/irq: inline call_do_irq() and call_do_softirq() In-Reply-To: <5ca6639b7c1c21ee4b4138b7cfb31d6245c4195c.1570684298.git.christophe.leroy@c-s.fr> References: <5ca6639b7c1c21ee4b4138b7cfb31d6245c4195c.1570684298.git.christophe.leroy@c-s.fr> Date: Thu, 21 Nov 2019 17:14:45 +1100 Message-ID: <877e3tbvsa.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christophe Leroy writes: > call_do_irq() and call_do_softirq() are quite similar on PPC32 and > PPC64 and are simple enough to be worth inlining. > > Inlining them avoids an mflr/mtlr pair plus a save/reload on stack. > > 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 That breaks 64-bit with GCC9: arch/powerpc/kernel/irq.c: In function 'do_IRQ': arch/powerpc/kernel/irq.c:650:2: error: PIC register clobbered by 'r2' in 'asm' 650 | asm volatile( | ^~~ arch/powerpc/kernel/irq.c: In function 'do_softirq_own_stack': arch/powerpc/kernel/irq.c:711:2: error: PIC register clobbered by 'r2' in 'asm' 711 | asm volatile( | ^~~ > diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c > index 04204be49577..d62fe18405a0 100644 > --- a/arch/powerpc/kernel/irq.c > +++ b/arch/powerpc/kernel/irq.c > @@ -642,6 +642,22 @@ void __do_irq(struct pt_regs *regs) > irq_exit(); > } > > +static inline void call_do_irq(struct pt_regs *regs, void *sp) > +{ > + register unsigned long r3 asm("r3") = (unsigned long)regs; > + > + /* 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", "r2", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"); > +} If we add a nop after the bl, so the linker could insert a TOC restore, then I don't think there's any circumstance under which we expect this to actually clobber r2, is there? cheers