clockevents: avoid unnecessary reprograming of event timer
PATCH 1/1 clockevents: avoid unnecessary reprograming of event timer
From: Michael Davidson <[email protected]>
Don't reprogram the event timer if it is already set to expire at the correct time.
---
kernel/time/clockevents.c +3 -0
@@ -103,6 +103,9 @@if (delta <=0 )return -ETIME ; +if (ktime_equal (dev->next_event, expires)) +return 0 ; + dev->next_event = expires;if (dev->mode ==CLOCK_EVT_MODE_SHUTDOWN )
Quoted 10 lines · Michael Davidson
From: Michael Davidson <[email protected]>
Don't reprogram the event timer if it is already set to expire at the correct time.
Signed-off-by Michael Davidson <[email protected]>---
kernel/time/clockevents.c line 108
Quoted 6 lines
kernel/time/clockevents.c +3
-0@@ -103,6 +103,9 @@if (delta <=0 )return -ETIME ; +if (ktime_equal (dev->next_event, expires)) +return 0 ; +
Hm, given that a good high-res source has nanoseconds resolution, what's the chance of this optimization triggering in practice? Near zero i think - unless we trigger useless reprogramming without having added or removed any new timers - but then we should concentrate on analyzing the reason for that redundant reprogramming.
Does it trigger often for you?
Ingo
Quoted 11 lines · Ingo Molnar
kernel/time/clockevents.c line 108
Quoted 3 lines
kernel/time/clockevents.c +3
-0+if (ktime_equal (dev->next_event, expires)) +return 0 ; +Hm, given that a good high-res source has nanoseconds resolution, what's the chance of this optimization triggering in practice? Near zero i think - unless we trigger useless reprogramming without having added or removed any new timers - but then we should concentrate on analyzing the reason for that redundant reprogramming.
Does it trigger often for you?
The only point where this should trigger is when we come out of C2/C3 and switch the local APIC timer back on. There we reload the next_event which was discarded in the hardware before we entered C2/C3 and switched to the broadcast timer. So this change would prevent the rearming of the local APIC after coming out of C2/C3 and probably give us some new C-State related headaches.
Thanks,
tglx
Quoted 11 lines · Thomas Gleixner
Quoted 10 lines · Ingo Molnar
kernel/time/clockevents.c line 108
Quoted 3 lines
kernel/time/clockevents.c +3
-0+if (ktime_equal (dev->next_event, expires)) +return 0 ; +Hm, given that a good high-res source has nanoseconds resolution, what's the chance of this optimization triggering in practice? Near zero i think - unless we trigger useless reprogramming without having added or removed any new timers - but then we should concentrate on analyzing the reason for that redundant reprogramming.
Quoted 8 lines
Quoted 1 line
Does it trigger often for you?
The only point where this should trigger is when we come out of C2/C3 and switch the local APIC timer back on. There we reload the
next_eventwhich was discarded in the hardware before we entered C2/C3 and switched to the broadcast timer. So this change would prevent the rearming of the local APIC after coming out of C2/C3 and probably give us some new C-State related headaches.
yes, that was my other thought. Albeit arguably the CE code should set next_event to -1 or so when suspending, out of caution, right?
Ingo
Quoted 8 lines · Ingo Molnar
Hm, given that a good high-res source has nanoseconds resolution, what's the chance of this optimization triggering in practice? Near zero i think - unless we trigger useless reprogramming without having added or removed any new timers - but then we should concentrate on analyzing the reason for that redundant reprogramming.
Does it trigger often for you?
Yes - running 2.6.26 built with CONFIG_NO_HZ on a 4 core AMD system, depending on the workload I see it trigger between 40 and 100 times a second.
I will take a closer look at why this is happening.
md