irqflags: fix (at least latent) code generation issue
PATCH 1/1 irqflags: fix (at least latent) code generation issue
The conditional in local_irq_restore() otherwise can cause code bloat (the if and else blocks may get translated into separate code paths despite the generated code being identical, dependent on compiler internal heuristics). Note that this adjustment gets the code in sync with the comment preceding it (which was slightly wrong from at least from 2.6.37 onwards).
The code bloat was observed in reality with an experimental x86 patch I'm about to post as RFC.
--- include/linux/irqflags.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/irqflags.h +3 -3
@@ -85,7 +85,7 @@* The local_irq_*() APIs are equal to the raw_local_irq*() * if !TRACE_IRQFLAGS. */ -#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT +#ifdef CONFIG_TRACE_IRQFLAGS #define local_irq_enable () \ do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)#define local_irq_disable () \
@@ -131,7 +131,7 @@ } while (0) -#else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */ +#else /* !CONFIG_TRACE_IRQFLAGS */ #define local_irq_enable () do { raw_local_irq_enable(); } while (0)#define local_irq_disable () do { raw_local_irq_disable(); } while (0)
@@ -145,6 +145,6 @@#define irqs_disabled_flags (flags) (raw_irqs_disabled_flags(flags))#define safe_halt () do { raw_safe_halt(); } while (0) -#endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */ +#endif /* CONFIG_TRACE_IRQFLAGS */ #endif
Quoted 36 lines · Jan Beulich
The conditional in
local_irq_restore()otherwise can cause code bloat (the if and else blocks may get translated into separate code paths despite the generated code being identical, dependent on compiler internal heuristics). Note that this adjustment gets the code in sync with the comment preceding it (which was slightly wrong from at least from 2.6.37 onwards).The code bloat was observed in reality with an experimental x86 patch I'm about to post as RFC.
Signed-off-by Jan Beulich <[email protected]>--- include/linux/irqflags.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)include/linux/irqflags.h +2
-2@@ -85,7 +85,7 @@* The local_irq_*() APIs are equal to the raw_local_irq*() * if !TRACE_IRQFLAGS. */ -#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT +#ifdef CONFIG_TRACE_IRQFLAGS #define local_irq_enable () \ do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)#define local_irq_disable () \@@ -131,7 +131,7 @@ } while (0) -#else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */ +#else /* !CONFIG_TRACE_IRQFLAGS */ #define local_irq_enable () do { raw_local_irq_enable(); } while (0)#define local_irq_disable () do { raw_local_irq_disable(); } while (0)
include/linux/irqflags.h line 148
Quoted 5 lines
include/linux/irqflags.h +1
-1@@ -145,6 +145,6 @@#define irqs_disabled_flags (flags) (raw_irqs_disabled_flags(flags))#define safe_halt () do { raw_safe_halt(); } while (0) -#endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */ +#endif /* CONFIG_TRACE_IRQFLAGS */
So this breaks a couple of non-x86 architectures, such as MIPS:
/home/mingo/tip/include/acpi/platform/aclinuxex.h: In function 'acpi_os_allocate':/home/mingo/tip/include/acpi/platform/aclinuxex.h:86: error: implicit declaration of function 'arch_irqs_disabled'
Thanks,
Ingo
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 10.11.14 at 13:13, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
include/linux/irqflags.h +1
-1@@ -131,7 +131,7 @@ } while (0) -#else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */ +#else /* !CONFIG_TRACE_IRQFLAGS */ #define local_irq_enable () do { raw_local_irq_enable(); } while (0)#define local_irq_disable () do { raw_local_irq_disable(); } while (0)include/linux/irqflags.h line 148
Quoted 5 lines
include/linux/irqflags.h +1
-1@@ -145,6 +145,6 @@#define irqs_disabled_flags (flags) (raw_irqs_disabled_flags(flags))#define safe_halt () do { raw_safe_halt(); } while (0) -#endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */ +#endif /* CONFIG_TRACE_IRQFLAGS */ So this breaks a couple of non-x86 architectures, such as MIPS:
Quoted 4 lines
/home/mingo/tip/include/acpi/platform/aclinuxex.h: In function 'acpi_os_allocate':/home/mingo/tip/include/acpi/platform/aclinuxex.h:86: error: implicit declaration of function 'arch_irqs_disabled'
Now that I finally found time to look into this a little, I wonder what you expect: Code in linux/irqflags.h ahead of the above conditional uses arch_irqs_disable():
#define raw_irqs_disabled() (arch_irqs_disabled())
so it would seem to me that architectures are required to have the latter available. And in fact it would seem very logical to me if pieces like the definition of irqs_disabled() would be pulled out of that conditional, as their behavior shouldn't (for this one) or already doesn't (for e.g. irqs_disabled_flags() and local_save_flags()) differ between the two cases. Would, short of adding arch_irqs_disabled() for all architectures currently lacking it, uniformly using the definition from the #if portion of the conditional be an acceptable thing? If not, do you have any other suggestion on how to resolve this?
Jan