Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5551078ybc; Wed, 27 Nov 2019 05:54:02 -0800 (PST) X-Google-Smtp-Source: APXvYqyLTD1AX8yA56NMyTlV0LUG+GTQnRwBTa5WC4yGGrgDjGW3MemGO7I7/WQFuEITQcx2LcoX X-Received: by 2002:a17:906:86ca:: with SMTP id j10mr50053939ejy.200.1574862842466; Wed, 27 Nov 2019 05:54:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574862842; cv=none; d=google.com; s=arc-20160816; b=zf2eR0grCsZ4uZL0znphY7qSKqs/XFnIGcnlbNhTDZcZkjiZV2uoEE+mO+lU2snK2G cZ731preVJtvRggJ70/HeagZbigU/qZ7/oqFR30BcgJ0giv9b+EyBzq36NYGHHeHV+NK P/Lyrq52Xvevo8YKCnEtXkYJXHfXwa6Ax6hTM0tzldHfKye0mk4YEtdxzB7Itav6WW3N MCDc2i0LM1+cRE/D1g3l1aq7vtmAO9d2Rg3O46ixDRzv/zilLmg8ZNdOYRbAQvOxX6H2 7xmEcCBHOBZXHMm9Rl/6erS3mBywRTRbOte+JZmjGMl9hpmqWNPoWCytpjYkQ8KPiWGl +HgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=rc+q1YoGmH8a8vOMoySCGs9Lx4sR0OvYwsYXLQE8hK8=; b=gFjPwV8hPkOj57l9usGY3+q/jq+wC0OVhYODSabl3ZEycTn56YVm6E9iiy5cMmJqb3 gJdJpbbAMBZ9EX1U5jOWb0BnG13nzAjjy5koiQg0h2jvTnEY7P/Zo0Fe61WX8mpPyb1M u4HNvUi4J285gq2VODeOuLi8U0lEyaAc+XR5D3dDwEDwVu7vFHoj3mzaqi9p488mupWq vnikM3sK254Go2KJMpU4ywZhV9j9LFv/qW8W9TmRCHqfpLmXR3ipD0Y97uMkRMkL+Bpd Bg88+RLZIDyHCpJ7QjUXr9bqe+HV6Q+VlFeyvH2JX9/pmySAW+YwvVPOnxCnV6ViFIWa xMoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=JjS7Yv8C; 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 r1si712954edp.332.2019.11.27.05.53.38; Wed, 27 Nov 2019 05:54:02 -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=JjS7Yv8C; 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 S1726698AbfK0Nud (ORCPT + 99 others); Wed, 27 Nov 2019 08:50:33 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:34507 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726603AbfK0Nud (ORCPT ); Wed, 27 Nov 2019 08:50:33 -0500 Received: from localhost (mailhub1-ext [192.168.12.233]) by localhost (Postfix) with ESMTP id 47NMbp056Yz9v0wq; Wed, 27 Nov 2019 14:50:30 +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=JjS7Yv8C; 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 bJT7dAplImvV; Wed, 27 Nov 2019 14:50:29 +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 47NMbn68C4z9v0wn; Wed, 27 Nov 2019 14:50:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1574862629; bh=rc+q1YoGmH8a8vOMoySCGs9Lx4sR0OvYwsYXLQE8hK8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=JjS7Yv8CRT6AYv05rwiqTYrHkvuMAoCYFRbvpXPD/IhW2BKTP2ebY27gNskuXOzfs K5u5woB4w0I4IrEw3jKEHlc2J0kep7WnIXAXNATcpXktTNT5jxxEfSeSPFw71Ta/tI QunQAsQzWMZ2CYxGQVqlfspDAllEa8g7CrQsIKXU= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 466118B861; Wed, 27 Nov 2019 14:50:31 +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 gHllTL7Lgrj0; Wed, 27 Nov 2019 14:50:31 +0100 (CET) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id CCC198B85A; Wed, 27 Nov 2019 14:50:30 +0100 (CET) Subject: Re: [PATCH v4 2/2] powerpc/irq: inline call_do_irq() and call_do_softirq() To: Segher Boessenkool , Michael Ellerman Cc: Benjamin Herrenschmidt , Paul Mackerras , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <5ca6639b7c1c21ee4b4138b7cfb31d6245c4195c.1570684298.git.christophe.leroy@c-s.fr> <877e3tbvsa.fsf@mpe.ellerman.id.au> <20191121101552.GR16031@gate.crashing.org> <87y2w49rgo.fsf@mpe.ellerman.id.au> <20191125142556.GU9491@gate.crashing.org> From: Christophe Leroy Message-ID: <5fdb1c92-8bf4-01ca-f81c-214870c33be3@c-s.fr> Date: Wed, 27 Nov 2019 14:50:30 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20191125142556.GU9491@gate.crashing.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 25/11/2019 à 15:25, Segher Boessenkool a écrit : > On Mon, Nov 25, 2019 at 09:32:23PM +1100, Michael Ellerman wrote: >> Segher Boessenkool writes: >>>>> +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? >>> >>> That is mostly correct. >> >> That's the standard I aspire to :P >> >>> If call_do_irq was a no-inline function, there would not be problems. >>> >>> What TOC does __do_irq require in r2 on entry, and what will be there >>> when it returns? >> >> The kernel TOC, and also the kernel TOC, unless something's gone wrong >> or I'm missing something. > > If that is the case, we can just do the bl, no nop at all? And that works > for all of our ABIs. > > If we can be certain that we have the kernel TOC in r2 on entry to > call_do_irq, that is! (Or it establishes it itself). So what do we do ? We just drop the "r2" clobber ? Otherwise, to be on the safe side we can just save r2 in a local var before the bl and restore it after. I guess it won't collapse CPU time on a performant PPC64. Christophe