Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/54BE5F8E02000078000570A7@mail.emea.novell.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Jan Beulich and committed by
Ingo Molnar
db2dcb4f 02cea395

+22 -21
+22 -21
include/linux/irqflags.h
··· 85 85 * The local_irq_*() APIs are equal to the raw_local_irq*() 86 86 * if !TRACE_IRQFLAGS. 87 87 */ 88 - #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT 88 + #ifdef CONFIG_TRACE_IRQFLAGS 89 89 #define local_irq_enable() \ 90 90 do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0) 91 91 #define local_irq_disable() \ ··· 107 107 raw_local_irq_restore(flags); \ 108 108 } \ 109 109 } while (0) 110 - #define local_save_flags(flags) \ 111 - do { \ 112 - raw_local_save_flags(flags); \ 113 - } while (0) 114 - 115 - #define irqs_disabled_flags(flags) \ 116 - ({ \ 117 - raw_irqs_disabled_flags(flags); \ 118 - }) 119 - 120 - #define irqs_disabled() \ 121 - ({ \ 122 - unsigned long _flags; \ 123 - raw_local_save_flags(_flags); \ 124 - raw_irqs_disabled_flags(_flags); \ 125 - }) 126 110 127 111 #define safe_halt() \ 128 112 do { \ ··· 115 131 } while (0) 116 132 117 133 118 - #else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */ 134 + #else /* !CONFIG_TRACE_IRQFLAGS */ 119 135 120 136 #define local_irq_enable() do { raw_local_irq_enable(); } while (0) 121 137 #define local_irq_disable() do { raw_local_irq_disable(); } while (0) ··· 124 140 raw_local_irq_save(flags); \ 125 141 } while (0) 126 142 #define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0) 127 - #define local_save_flags(flags) do { raw_local_save_flags(flags); } while (0) 128 - #define irqs_disabled() (raw_irqs_disabled()) 129 - #define irqs_disabled_flags(flags) (raw_irqs_disabled_flags(flags)) 130 143 #define safe_halt() do { raw_safe_halt(); } while (0) 131 144 145 + #endif /* CONFIG_TRACE_IRQFLAGS */ 146 + 147 + #define local_save_flags(flags) raw_local_save_flags(flags) 148 + 149 + /* 150 + * Some architectures don't define arch_irqs_disabled(), so even if either 151 + * definition would be fine we need to use different ones for the time being 152 + * to avoid build issues. 153 + */ 154 + #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT 155 + #define irqs_disabled() \ 156 + ({ \ 157 + unsigned long _flags; \ 158 + raw_local_save_flags(_flags); \ 159 + raw_irqs_disabled_flags(_flags); \ 160 + }) 161 + #else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */ 162 + #define irqs_disabled() raw_irqs_disabled() 132 163 #endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */ 164 + 165 + #define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags) 133 166 134 167 #endif