* [PATCH] powerpc: Make hard_irq_disable() do the right thing vs. irq tracing
@ 2013-05-07 7:04 Benjamin Herrenschmidt
2013-05-07 7:15 ` tiejun.chen
0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2013-05-07 7:04 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Scott Wood, Mihai Caraman, kvm-ppc, Tiejun Chen
If hard_irq_disable() is called while interrupts are already soft-disabled
(which is the most common case) all is already well.
However you can (and in some cases want) to call it while everything is
enabled (to make sure you don't get a lazy even, for example before entry
into KVM guests) and in this case we need to inform the irq tracer that
the irqs are going off.
We have to change the inline into a macro to avoid an include circular
dependency hell hole.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
Tested on pseries, Scott, I don't expect a problem with that patch especially
since most callers already are soft disabled, so I'll merge it now along with
my other pending stuff and you can simplify your KVM one.
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index e45c494..d615b28 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -95,15 +95,13 @@ static inline bool arch_irqs_disabled(void)
#define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1)
#endif
-static inline void hard_irq_disable(void)
-{
- __hard_irq_disable();
- get_paca()->soft_enabled = 0;
- get_paca()->irq_happened |= PACA_IRQ_HARD_DIS;
-}
-
-/* include/linux/interrupt.h needs hard_irq_disable to be a macro */
-#define hard_irq_disable hard_irq_disable
+#define hard_irq_disable() do { \
+ __hard_irq_disable(); \
+ if (local_paca->soft_enabled) \
+ trace_hardirqs_off(); \
+ get_paca()->soft_enabled = 0; \
+ get_paca()->irq_happened |= PACA_IRQ_HARD_DIS; \
+} while(0)
static inline bool lazy_irq_pending(void)
{
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc: Make hard_irq_disable() do the right thing vs. irq tracing
2013-05-07 7:04 [PATCH] powerpc: Make hard_irq_disable() do the right thing vs. irq tracing Benjamin Herrenschmidt
@ 2013-05-07 7:15 ` tiejun.chen
2013-05-07 7:25 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 3+ messages in thread
From: tiejun.chen @ 2013-05-07 7:15 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: Scott Wood, Mihai Caraman, linuxppc-dev, kvm-ppc
On 05/07/2013 03:04 PM, Benjamin Herrenschmidt wrote:
> If hard_irq_disable() is called while interrupts are already soft-disabled
> (which is the most common case) all is already well.
>
> However you can (and in some cases want) to call it while everything is
> enabled (to make sure you don't get a lazy even, for example before entry
> into KVM guests) and in this case we need to inform the irq tracer that
> the irqs are going off.
>
> We have to change the inline into a macro to avoid an include circular
> dependency hell hole.
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>
> Tested on pseries, Scott, I don't expect a problem with that patch especially
> since most callers already are soft disabled, so I'll merge it now along with
> my other pending stuff and you can simplify your KVM one.
>
> diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
> index e45c494..d615b28 100644
> --- a/arch/powerpc/include/asm/hw_irq.h
> +++ b/arch/powerpc/include/asm/hw_irq.h
> @@ -95,15 +95,13 @@ static inline bool arch_irqs_disabled(void)
> #define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1)
> #endif
>
> -static inline void hard_irq_disable(void)
> -{
> - __hard_irq_disable();
> - get_paca()->soft_enabled = 0;
> - get_paca()->irq_happened |= PACA_IRQ_HARD_DIS;
> -}
> -
> -/* include/linux/interrupt.h needs hard_irq_disable to be a macro */
> -#define hard_irq_disable hard_irq_disable
> +#define hard_irq_disable() do { \
> + __hard_irq_disable(); \
> + if (local_paca->soft_enabled) \
> + trace_hardirqs_off(); \
> + get_paca()->soft_enabled = 0; \
Could we simplify this as follows:
+#define hard_irq_disable() do { \
+ __hard_irq_disable(); \
+ if (get_paca()->soft_enabled) { \
+ trace_hardirqs_off(); \
+ get_paca()->soft_enabled = 0; \
+ } \
+ get_paca()->irq_happened |= PACA_IRQ_HARD_DIS; \
+} while(0)
Tiejun
> + get_paca()->irq_happened |= PACA_IRQ_HARD_DIS; \
> +} while(0)
>
> static inline bool lazy_irq_pending(void)
> {
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] powerpc: Make hard_irq_disable() do the right thing vs. irq tracing
2013-05-07 7:15 ` tiejun.chen
@ 2013-05-07 7:25 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2013-05-07 7:25 UTC (permalink / raw)
To: tiejun.chen; +Cc: Scott Wood, Mihai Caraman, linuxppc-dev, kvm-ppc
On Tue, 2013-05-07 at 15:15 +0800, tiejun.chen wrote:
> Could we simplify this as follows:
>
> +#define hard_irq_disable() do { \
> + __hard_irq_disable(); \
> + if (get_paca()->soft_enabled) { \
> + trace_hardirqs_off(); \
> + get_paca()->soft_enabled = 0; \
> + } \
> + get_paca()->irq_happened |= PACA_IRQ_HARD_DIS; \
> +} while(0)
I'd rather not. When lockdep is not enabled trace_hardirqs_off() is a
nop and thus we have no conditional at all which is arguably better...
Cheers,
Ben.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-07 7:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-07 7:04 [PATCH] powerpc: Make hard_irq_disable() do the right thing vs. irq tracing Benjamin Herrenschmidt
2013-05-07 7:15 ` tiejun.chen
2013-05-07 7:25 ` Benjamin Herrenschmidt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).