Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1198031ybl; Fri, 6 Dec 2019 13:01:07 -0800 (PST) X-Google-Smtp-Source: APXvYqyUFCSGQXdMjDzTrYv8Vd+s9+g0yVeooqMHxfM+2eVtvXQFGbA/Vpr9pms9ZgaXFzP+3zM4 X-Received: by 2002:a9d:6395:: with SMTP id w21mr12844399otk.3.1575666067656; Fri, 06 Dec 2019 13:01:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575666067; cv=none; d=google.com; s=arc-20160816; b=PuaPtw4DfTjU6EOv1UGVNrKi//ypkAsHsS2vRS96J+MZAZ5r3th3k6/eOLYZc9bXvI P4wDUwTrCi9v3Q+FLdLFzm+QjLYqaJRJ4PDsr3oKkw/qvYRX5D/nEytuH1E/VqSDG1km h8xeym6rJthjzBQS9GjrO957iGcHS71Jxk6oKDnY3CY4Rg/flzjzXWt1uzHEkyosy1p+ /hnb6eoxhw1f3RoYluzqRGlh23Yb0QJVq6JiVOvYtoNCS9Z/PY+U3g31fKLndWVUewgp CPLp4CGWhbfUWUQqZuhtEHGOx4V4xKSWglGUbvSnEnsbjy5vc3PSWg7SgjA0IrxRyuYY XfbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=YCEF11wV6sdVBrQQM4Ei6dfFZbXmhTuVHLumrlH6GgM=; b=lbLFImaKqMsptOl+T0ctCj3hvXZPP9sFeG8Uxntcxbm+mInLI1qhXm05Am1iRzv6Ec gzrzL7eZ0od/Dq4qBksrAaswsn3C3UmF1YGaGNvmy5NeanvPX/J694BBh8o4vKP4MWzC I7Mr4nzsdNWLusgsRE/gH8uPi1uDBGbKElmyIDHgSiEbECM1X5Ml0N7JmYIw16+CMBVL YeWiIbHzZPTJkMVMFIjgRj1e7tl3VqMuoF+eOKp0gSyi/hw8jq7jm1Qj2Tvt6JmlGw8+ D1JNdrfABOZ+JYTG9C3zB6hta2Ve41BxfvIE5z6BZ1+T0TEcDJyovEEpbZsARsP61C1z DEoA== ARC-Authentication-Results: i=1; mx.google.com; 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 l131si7832432oib.174.2019.12.06.13.00.54; Fri, 06 Dec 2019 13:01:07 -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; 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 S1726388AbfLFVAX (ORCPT + 99 others); Fri, 6 Dec 2019 16:00:23 -0500 Received: from gate.crashing.org ([63.228.1.57]:47481 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726330AbfLFVAX (ORCPT ); Fri, 6 Dec 2019 16:00:23 -0500 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id xB6KxtJD020157; Fri, 6 Dec 2019 14:59:55 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id xB6Kxrxp020154; Fri, 6 Dec 2019 14:59:53 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Fri, 6 Dec 2019 14:59:53 -0600 From: Segher Boessenkool To: Christophe Leroy Cc: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , 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() Message-ID: <20191206205953.GQ3152@gate.crashing.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> <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> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 04, 2019 at 05:32:54AM +0100, Christophe Leroy wrote: > Le 29/11/2019 ? 19:46, Segher Boessenkool a ?crit?: > >The existing call_do_irq isn't C code. It doesn't do anything with r2, > >as far as I can see; __do_irq just gets whatever the caller of call_do_irq > >has. > > > >So I guess all the callers of call_do_irq have the correct r2 value always > >already? In that case everything Just Works. > > Indeed, there is only one caller for call_do_irq() which is do_IRQ(). > And do_IRQ() is also calling __do_irq() directly (when the stack pointer > is already set to IRQ stack). do_IRQ() and __do_irq() are both in > arch/powerpc/kernel/irq.c > > As far as I can see when replacing the call to call_do_irq() by a call > to __do_irq(), the compiler doesn't do anything special with r2, and > doesn't add any nop after the bl either, whereas for all calls outside > irq.c, there is a nop added. So I guess that's ok ? 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. > Now that call_do_irq() is inlined, we can even define __do_irq() as static. > > And that's the same for do_softirq_own_stack(), it is only called from > do_softirq() which is defined in the same file as __do_softirq() > (kernel/softirq.c) 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? Segher