Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1596894ybl; Wed, 18 Dec 2019 22:59:36 -0800 (PST) X-Google-Smtp-Source: APXvYqz9IdxoGjgnxv17hmz6fNS2Y8CuiCGSQdLriVEU3kEkUTNJM/XNk97A2D8XvbINlgXUyyxT X-Received: by 2002:a9d:369:: with SMTP id 96mr2795986otv.228.1576738776158; Wed, 18 Dec 2019 22:59:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576738776; cv=none; d=google.com; s=arc-20160816; b=0UDPczAxZsURCM4cKPNvSGSd5lumKQ9q02z94HWmc5l2aJAP7g8Z+MEQciJ7bkMj5G S+ycnVk1QC68jD4YUVbnQ2n5n/uOPmSUX0shaSgTch2hKyBID0DTMePjg0qaG6mALP95 7Vhsh/c+21P+v6ota10InYFlFsmaI839sjtSx841+eKRzax4dWlFNveyX02W2IJkHbc0 N3mXkNlurbixfxc0XST6LgEvj9RlQZ+tNqeTCAvzy7K6KYDT+1HJ+JPNGOKzz/drhYlT S4J77qmcrCx99tYYkRXSRryQNbSMD3NH6AMXnHZyxBLJsOZzCTbp67SThimzUOvnDe2Y AsdA== 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=MBZphaLvN7Y7xmwStybWkMj7P7KceZL2/izi15FLe2g=; b=WVZzc07lmgX0zKi05eRQRTIxg4vFafAKX5DFUj83o6hYtzT/uNmfddnu7ZgRPLWy1g /0OY25XAgUBaOEw/lYwNi4Uy+WljEiRptlVaQszbmkZuTfKdZbcrhLFAkIlPJy8rn1W4 dLiMnaCV6yvSo1tdxGJI3kU/DOElp/7Aln+W9bsvKA+G4N5WqneKS8EiJE7aqTr6CFcR a/06ZJxeT97xVXmuKCplntelYg4OY/h4F8N9FkBXVtLFbXRv3xQLEwmYlJFNBFbVWLEl t3Vf279DlnU64qhaBZosJzKi4SbmCTAUvg1J7rDcU315/s02a8ERtaJEdS714W8IjNKH ZwmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=hJIh69rg; 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 f17si2489084otq.96.2019.12.18.22.59.25; Wed, 18 Dec 2019 22:59:36 -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=hJIh69rg; 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 S1726652AbfLSG52 (ORCPT + 99 others); Thu, 19 Dec 2019 01:57:28 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:59997 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726340AbfLSG52 (ORCPT ); Thu, 19 Dec 2019 01:57:28 -0500 Received: from localhost (mailhub1-ext [192.168.12.233]) by localhost (Postfix) with ESMTP id 47djP031Kbz9v02n; Thu, 19 Dec 2019 07:57:24 +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=hJIh69rg; 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 4zsNDiTYkOWZ; Thu, 19 Dec 2019 07:57:24 +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 47djP01xGSz9v02k; Thu, 19 Dec 2019 07:57:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1576738644; bh=MBZphaLvN7Y7xmwStybWkMj7P7KceZL2/izi15FLe2g=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=hJIh69rgLLxnthcBrxF/1T3c0JibNrCX6uPNuvFpD9JKNNTFiQ78GrSzXnDytU/K0 /7Mg5YCcJule+LCPv+0KhJr3JKa9QA/Lg0A7glx6nveEy6UMuPgb99JBWJyfvyZxoI Ltss9EiGr/yr4PRRdkd7lg7xM3qM03AlU5gRdXlo= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 24BAF8B784; Thu, 19 Dec 2019 07:57:25 +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 1Y6LUm90Zee9; Thu, 19 Dec 2019 07:57:25 +0100 (CET) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 8B24F8B756; Thu, 19 Dec 2019 07:57:24 +0100 (CET) Subject: Re: [PATCH v4 2/2] powerpc/irq: inline call_do_irq() and call_do_softirq() To: Michael Ellerman , Segher Boessenkool Cc: Benjamin Herrenschmidt , Paul Mackerras , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <20191121101552.GR16031@gate.crashing.org> <87y2w49rgo.fsf@mpe.ellerman.id.au> <20191125142556.GU9491@gate.crashing.org> <5fdb1c92-8bf4-01ca-f81c-214870c33be3@c-s.fr> <20191127145958.GG9491@gate.crashing.org> <2072e066-1ffb-867e-60ec-04a6bb9075c1@c-s.fr> <20191129184658.GR9491@gate.crashing.org> <20191206205953.GQ3152@gate.crashing.org> <2a22feca-d6d6-6cb0-6c76-035234fa8742@c-s.fr> <20191207174057.GY3152@gate.crashing.org> <878snlrcrs.fsf@mpe.ellerman.id.au> From: Christophe Leroy Message-ID: <4668c204-3064-0e9e-5216-e7853f732821@c-s.fr> Date: Thu, 19 Dec 2019 07:57:24 +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: <878snlrcrs.fsf@mpe.ellerman.id.au> 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 09/12/2019 à 11:53, Michael Ellerman a écrit : > Segher Boessenkool writes: >> On Sat, Dec 07, 2019 at 10:42:28AM +0100, Christophe Leroy wrote: >>> Le 06/12/2019 à 21:59, Segher Boessenkool a écrit : >>>> If the compiler can see the callee wants the same TOC as the caller has, >>>> it does not arrange to set (and restore) it, no. If it sees it may be >>>> different, it does arrange for that (and the linker then will check if >>>> it actually needs to do anything, and do that if needed). >>>> >>>> In this case, the compiler cannot know the callee wants the same TOC, >>>> which complicates thing a lot -- but it all works out. >>> >>> Do we have a way to make sure which TOC the functions are using ? Is >>> there several TOC at all in kernel code ? >> >> Kernel modules have their own TOC, I think? > > Yes. Yes, this means that exported functions have to care about that, right ? And that's the reason why exported assembly functions like copy_page() use _GLOBAL_TOC() and not _GLOBAL() But main part of the kernel only has one TOC, so r2 can be assumed constant for non exported functions, can't it ? > >>>> I think things can still go wrong if any of this is inlined into a kernel >>>> module? Is there anything that prevents this / can this not happen for >>>> some fundamental reason I don't see? >>> >>> This can't happen can it ? >>> do_softirq_own_stack() is an outline function, defined in powerpc irq.c >>> Its only caller is do_softirq() which is an outline function defined in >>> kernel/softirq.c >>> >>> That prevents inlining, doesn't it ? >> >> Hopefully, sure. Would be nice if it was clearer that this works... It >> is too much like working by chance, the way it is :-( > > There's no way any of that code can end up in a module. Or at least if > there is, that's a bug. That's my conclusion as well. So I guess we can consider r2 as constant over those functions. > >>> Anyway, until we clarify all this I'll limit my patch to PPC32 which is >>> where the real benefit is I guess. >>> >>> At the end, maybe the solution should be to switch to IRQ stack >>> immediately in the exception entry as x86_64 do ? > > Yeah that might be cleaner. > I prepared a patch for that on PPC32, but it doesn't get rid of the IRQ stack switch completely because do_IRQ() is also called from other places like the timer interrupt. And we will still have the switch for softirqs. We could move do_softirq_own_stack() to assembly and merge it with call_do_softirq(), but a find it cleaner to inline call_do_softirq() instead, now that we have demonstrated that r2 can't change. Christophe