[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191206205953.GQ3152@gate.crashing.org>
Date: Fri, 6 Dec 2019 14:59:53 -0600
From: Segher Boessenkool <segher@...nel.crashing.org>
To: Christophe Leroy <christophe.leroy@....fr>
Cc: Michael Ellerman <mpe@...erman.id.au>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH v4 2/2] powerpc/irq: inline call_do_irq() and call_do_softirq()
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
Powered by blists - more mailing lists