From: Bart Van Assche
Sent: 30 September 2024 19:16
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -195,7 +195,7 @@ static void hpet_timer_set_irq(struct hpet_dev *devp)
v &= ~0xffff;
for_each_set_bit(irq, &v, HPET_MAX_IRQ) {
- if (irq >= nr_irqs) {
+ if (irq >= number_of_interrupts()) {
irq = HPET_MAX_IRQ;
break;
}
This is horrid.
You've replaced the read of a global variable (which, in some cases the
compiler might be able to pull outside the loop) with a real function
call in every loop iteration.
With all the mitigations for cpu speculative execution 'issues' you
pretty much don't want trivial function calls.
If you are worried about locals shadowing globals just change one of the names.