irq: Track the interrupt timings
PATCH v4 1/1 irq: Track the interrupt timings
The interrupt framework gives a lot of information about each interrupt.
It does not keep track of when those interrupts occur though.
This patch provides a mean to record the elapsed time between successive interrupt occurrences in a per-IRQ per-CPU circular buffer to help with the prediction of the next occurrence using a statistical model.
A new function is added to browse the different interrupts and retrieve the timing information stored in it.
A static key is introduced so when the irq prediction is switched off at runtime, we can reduce the overhead near to zero. The irq timings is supposed to be potentially used by different sub-systems and for this reason the static key is a ref counter, so when the last use releases the irq timings that will result on the effective deactivation of the irq measurement.
---
V4:
- Added a static key
- Added more comments for irq_timings_get_next()
- Unified some function names to be prefixed by 'irq_timings_...'
- Fixed a rebase error
V3:
- Replaced ktime_get() by local_clock()
- Shared irq are not handled
- Simplified code by adding the timing in the irqdesc struct
- Added a function to browse the irq timings
V2:
- Fixed kerneldoc comment
- Removed data field from the struct irq timing
- Changed the lock section comment
- Removed semi-colon style with empty stub
- Replaced macro by static inline
- Fixed static functions declaration
RFC:
- initial posting
--- include/linux/interrupt.h | 18 +++++++ include/linux/irqdesc.h | 4 ++ kernel/irq/Kconfig | 3 ++ kernel/irq/Makefile | 1 + kernel/irq/handle.c | 2 + kernel/irq/internals.h | 59 ++++++++++++++++++++ kernel/irq/irqdesc.c | 6 +++ kernel/irq/manage.c | 3 ++ kernel/irq/timings.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 229 insertions(+) create mode 100644 kernel/irq/timings.c
include/linux/interrupt.h +18 -0
@@ -665,6 +665,24 @@ static inline void init_irq_proc(void) }#endif +#ifdef CONFIG_IRQ_TIMINGS + +#define IRQ_TIMINGS_SHIFT 3 +#define IRQ_TIMINGS_SIZE (1 << IRQ_TIMINGS_SHIFT) +#define IRQ_TIMINGS_MASK (IRQ_TIMINGS_SIZE - 1) + +struct irq_timings { +u32 values[IRQ_TIMINGS_SIZE ];/* our circular buffer */ +u64 sum;/* sum of values */ +u64 timestamp;/* latest timestamp */ +unsigned int w_index;/* current buffer index */ +}; + +struct irq_timings *irq_timings_get_next (int *irq); +void irq_timings_get (void ); +void irq_timings_put (void ); +#endif +struct seq_file ;int show_interrupts (struct seq_file *p,void *v);int arch_show_interrupts (struct seq_file *p,int prec);
include/linux/irqdesc.h +4 -0
@@ -12,6 +12,7 @@ struct proc_dir_entry;struct module ;struct irq_desc ;struct irq_domain ; +struct irq_timings ;struct pt_regs ;/**
@@ -51,6 +52,9 @@ struct irq_desc {struct irq_data irq_data;unsigned int __percpu *kstat_irqs;irq_flow_handler_t handle_irq; +#ifdef CONFIG_IRQ_TIMINGS +struct irq_timings __percpu *timings; +#endif #ifdef CONFIG_IRQ_PREFLOW_FASTEOI irq_preflow_handler_t preflow_handler;#endif
kernel/irq/Kconfig +3 -0
@@ -81,6 +81,9 @@ config GENERIC_MSI_IRQ_DOMAIN config HANDLE_DOMAIN_IRQ bool +config IRQ_TIMINGS + bool + config IRQ_DOMAIN_DEBUG bool "Expose hardware/virtual IRQ mapping via debugfs" depends on IRQ_DOMAIN && DEBUG_FS
kernel/irq/Makefile +1 -0
@@ -9,3 +9,4 @@ obj-$(CONFIG_GENERIC_IRQ_MIGRATION) += cpuhotplug.o obj-$(CONFIG_PM_SLEEP) += pm.o obj-$(CONFIG_GENERIC_MSI_IRQ) += msi.o obj-$(CONFIG_GENERIC_IRQ_IPI) += ipi.o +obj-$(CONFIG_IRQ_TIMINGS) += timings.o
kernel/irq/handle.c +2 -0
@@ -138,6 +138,8 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc)unsigned int flags =0 , irq = desc->irq_data.irq;struct irqaction *action; +handle_timings (desc); +for_each_action_of_desc (desc, action) {irqreturn_t res;
kernel/irq/internals.h +59 -0
68 lines not on this page · raw message
kernel/irq/irqdesc.c +6 -0
@@ -174,6 +174,9 @@ static struct irq_desc *alloc_desc(int irq, int node, struct module *owner)if (alloc_masks (desc, gfp, node)) goto err_kstat; +if (alloc_timings (desc)) + goto err_mask; +raw_spin_lock_init (&desc->lock);lockdep_set_class (&desc->lock, &irq_desc_lock_class);init_rcu_head (&desc->rcu);
@@ -182,6 +185,8 @@ static struct irq_desc *alloc_desc(int irq, int node, struct module *owner)return desc; +err_mask: +free_masks (desc); err_kstat:free_percpu (desc->kstat_irqs); err_desc:
@@ -193,6 +198,7 @@ static void delayed_free_desc(struct rcu_head *rhp) { struct irq_desc *desc = container_of(rhp, struct irq_desc, rcu); +free_timings (desc);free_masks (desc);free_percpu (desc->kstat_irqs);kfree (desc);
kernel/irq/manage.c +3 -0
@@ -1343,6 +1343,8 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)__enable_irq (desc); } +setup_timings (desc, new); +raw_spin_unlock_irqrestore (&desc->lock, flags);/*
@@ -1465,6 +1467,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)irq_settings_clr_disable_unlazy (desc);irq_shutdown (desc);irq_release_resources (desc); +remove_timings (desc); }#ifdef CONFIG_SMP
kernel/irq/timings.c new file +133 -0
133 lines not on this page · raw message
Signature · 1 line
1.9.1
Quoted 32 lines · Daniel Lezcano
The interrupt framework gives a lot of information about each interrupt.
It does not keep track of when those interrupts occur though.
This patch provides a mean to record the elapsed time between successive interrupt occurrences in a per-IRQ per-CPU circular buffer to help with the prediction of the next occurrence using a statistical model.
A new function is added to browse the different interrupts and retrieve the timing information stored in it.
A static key is introduced so when the irq prediction is switched off at runtime, we can reduce the overhead near to zero. The irq timings is supposed to be potentially used by different sub-systems and for this reason the static key is a ref counter, so when the last use releases the irq timings that will result on the effective deactivation of the irq measurement.
Signed-off-by Daniel Lezcano <[email protected]>Acked-by Nicolas Pitre <[email protected]>---
V4:
- Added a static key
- Added more comments forirq_timings_get_next()
- Unified some function names to be prefixed by 'irq_timings_...'
- Fixed a rebase error
V3:
- Replacedktime_get()bylocal_clock()
- Shared irq are not handled
- Simplified code by adding the timing in the irqdesc struct
- Added a function to browse the irq timings
V2:
- Fixed kerneldoc comment
Quoted 8 lines
- Removed data field from the struct irq timing
- Changed the lock section comment
- Removed semi-colon style with empty stub
- Replaced macro by static inline
- Fixed static functions declaration
RFC:
- initial posting
---
Hi Thomas,
do you think this patch is acceptable ?
Quoted 17 lines · Daniel Lezcano
The interrupt framework gives a lot of information about each interrupt.
It does not keep track of when those interrupts occur though.
This patch provides a mean to record the elapsed time between successive interrupt occurrences in a per-IRQ per-CPU circular buffer to help with the prediction of the next occurrence using a statistical model.
A new function is added to browse the different interrupts and retrieve the timing information stored in it.
A static key is introduced so when the irq prediction is switched off at runtime, we can reduce the overhead near to zero. The irq timings is supposed to be potentially used by different sub-systems and for this reason the static key is a ref counter, so when the last use releases the irq timings that will result on the effective deactivation of the irq measurement.
Quoted 8 lines
Signed-off-by Daniel Lezcano <[email protected]>Acked-by Nicolas Pitre <[email protected]>---
V4:
- Added a static key
- Added more comments forirq_timings_get_next()
- Unified some function names to be prefixed by 'irq_timings_...'
- Fixed a rebase error
Hi Thomas,
I believe all the comments were addressed.
I can imagine you are very busy at the moment. Is there something else I should fix or is the patch ok for you ?
Thanks.
-- Daniel
Thanks,
kernel/irq/internals.h irq_pm_install_action(struct irq_desc *desc, struct irqaction *action) { } · line 246
Quoted 4 lines · Daniel Lezcano
kernel/irq/internals.h +4
-0+static inline void setup_timings (struct irq_desc *desc,struct irqaction *act) +{ +/* +* Timers are deterministic, so no need to do any measurement
Deterministic is a confusing wording here. We don't need the measurement because the idle code already knows the next expiry event.
kernel/irq/timings.c line 5
Quoted 6 lines
kernel/irq/timings.c new file +5
-0@@ -0,0 +1,133 @@ +/* +* linux/kernel/irq/timings.c +* +* Copyright (C) 2016, Linaro Ltd - Daniel Lezcano <[email protected]> +*
Please add an explicit License one liner. The folks doing license analysis will be grateful.
kernel/irq/timings.c line 17
Quoted 3 lines
kernel/irq/timings.c new file +3
-0+DEFINE_STATIC_KEY_FALSE (irq_timing_enabled); + +void irq_timings_get (void )
_enable/disable() please.
Quoted 15 lines
kernel/irq/timings.c new file +15
-0+{ +static_branch_inc (&irq_timing_enabled); +} + +void irq_timings_put (void ) +{ +static_branch_dec (&irq_timing_enabled); +} + +/** +* __handle_timings - stores an irq timing when an interrupt occurs +* +* @desc: the irq descriptor +* +* For all interruptions with their IRQS_TIMINGS flag set, the function
kernel/irq/timings.c line 42
Quoted 10 lines
kernel/irq/timings.c new file +10
-0+* computes the time interval between two interrupt events and store it +* in a circular buffer. +*/ +void __handle_timings (struct irq_desc *desc) +{ +struct irq_timings *timings; +u64 prev, now, diff; + +if (!(desc->istate &IRQS_TIMINGS )) +return ;
Please have this check in the handle_timings() inline. No need to take a function call for the timer interrupt.
kernel/irq/timings.c line 54
Quoted 12 lines
kernel/irq/timings.c new file +12
-0+ + timings =this_cpu_ptr (desc->timings); + now =local_clock (); + prev = timings->timestamp; + timings->timestamp = now; + +/* +* If it is the first interrupt of the series, we can't +* compute an interval, just store the timestamp and exit. +*/ +if (unlikely (!prev)) +return ;
The delta will be large enough that you drop out in the check below. So you can spare that conditional.
kernel/irq/timings.c line 62
Quoted 8 lines
kernel/irq/timings.c new file +8
-0+ + diff = now - prev; + +/* +* microsec (actually 1024th of a milisec) precision is good +* enough for our purpose. +*/ + diff >>=10 ;
And that shift instruction is required because of the following?
Review
Quoted 2 lines
(quoted diff) +1
-0* Otherwise we know the magnitude of diff is + * well within 32 bits.
AFAICT that's pointless. You are not saving anything because NSEC_PER_SEC is smaller than 2^32 and your 8 values are not going to overflow 64 bit in the sum.
kernel/irq/timings.c line 73
Quoted 4 lines
kernel/irq/timings.c new file +4
-0+*/ +if (unlikely (diff >USEC_PER_SEC )) { +memset (timings,0 ,sizeof (*timings)); + timings->timestamp = now;
Redundant store.
Quoted 5 lines
kernel/irq/timings.c new file +5
-0+return ; + } + +/* The oldest value corresponds to the next index. */ + timings->w_index = (timings->w_index +1 ) &IRQ_TIMINGS_MASK ;
kernel/irq/timings.c line 88
Quoted 10 lines
kernel/irq/timings.c new file +10
-0+ +/* +* Remove the oldest value from the summing. If this is the +* first time we go through this array slot, the previous +* value will be zero and we won't substract anything from the +* current sum. Hence this code relies on a zero-ed structure. +*/ + timings->sum -= timings->values[timings->w_index]; + timings->values[timings->w_index] = diff; + timings->sum += diff;
Now the real question is whether you really need all that math, checks and memsets in the irq hotpath. If you make the storage slightly larger then you can just store the values unconditionally in the circular buffer and do all the computational stuff when you really it.
Thanks,
tglx
Quoted 17 lines · Thomas Gleixner
Thanks,
kernel/irq/timings.c line 54
Quoted 11 lines · Daniel Lezcano
kernel/irq/timings.c new file +11
-0+ timings =this_cpu_ptr (desc->timings); + now =local_clock (); + prev = timings->timestamp; + timings->timestamp = now; + +/* +* If it is the first interrupt of the series, we can't +* compute an interval, just store the timestamp and exit. +*/ +if (unlikely (!prev)) +return ;The delta will be large enough that you drop out in the check below. So you can spare that conditional.
Fair enough.
Quoted 10 lines
kernel/irq/timings.c line 62
Quoted 7 lines
kernel/irq/timings.c new file +7
-0+ diff = now - prev; + +/* +* microsec (actually 1024th of a milisec) precision is good +* enough for our purpose. +*/ + diff >>=10 ;And that shift instruction is required because of the following?
Quoted 6 lines
kernel/irq/timings.c line 69
Quoted 2 lines
* Otherwise we know the magnitude of diff is
kernel/irq/timings.c new file +1
-0+* well within 32 bits. AFAICT that's pointless. You are not saving anything because
NSEC_PER_SECis smaller than 2^32 and your 8 values are not going to overflow 64 bit in the sum.
Those values are squared later, so we really want 32 bits here.
Quoted 6 lines
kernel/irq/timings.c line 73
Quoted 4 lines
kernel/irq/timings.c new file +4
-0+*/ +if (unlikely (diff >USEC_PER_SEC )) { +memset (timings,0 ,sizeof (*timings)); + timings->timestamp = now;Redundant store.
We just trashed all our data with the memset so the current timestamp needs to be restored.
Quoted 12 lines
Quoted 12 lines
kernel/irq/timings.c new file +12
-0+return ; + } + +/* The oldest value corresponds to the next index. */ + timings->w_index = (timings->w_index +1 ) &IRQ_TIMINGS_MASK ; + +/* +* Remove the oldest value from the summing. If this is the +* first time we go through this array slot, the previous +* value will be zero and we won't substract anything from the +* current sum. Hence this code relies on a zero-ed structure. +*/
Quoted 8 lines
kernel/irq/timings.c line 88
Quoted 3 lines
kernel/irq/timings.c new file +3
-0+ timings->sum -= timings->values[timings->w_index]; + timings->values[timings->w_index] = diff; + timings->sum += diff;Now the real question is whether you really need all that math, checks and memsets in the irq hotpath. If you make the storage slightly larger then you can just store the values unconditionally in the circular buffer and do all the computational stuff when you really it.
Well... given that you need an IRQ everytime you come out of idle that means there will always be more IRQs than entries into idle, so you're probably right.
Nicolas
Quoted 11 lines · Nicolas Pitre
Quoted 10 lines · Thomas Gleixner
kernel/irq/timings.c line 62
Quoted 7 lines
kernel/irq/timings.c new file +7
-0+ diff = now - prev; + +/* +* microsec (actually 1024th of a milisec) precision is good +* enough for our purpose. +*/ + diff >>=10 ;And that shift instruction is required because of the following?
Quoted 8 lines
Quoted 6 lines
kernel/irq/timings.c line 69
Quoted 2 lines
* Otherwise we know the magnitude of diff is
kernel/irq/timings.c new file +1
-0+* well within 32 bits. AFAICT that's pointless. You are not saving anything because
NSEC_PER_SECis smaller than 2^32 and your 8 values are not going to overflow 64 bit in the sum.Those values are squared later, so we really want 32 bits here.
Well, you can do sum >> 10 exaclty once when you calculate stuff.
Quoted 9 lines
Quoted 6 lines
kernel/irq/timings.c line 73
Quoted 4 lines
kernel/irq/timings.c new file +4
-0+*/ +if (unlikely (diff >USEC_PER_SEC )) { +memset (timings,0 ,sizeof (*timings)); + timings->timestamp = now;Redundant store.
We just trashed all our data with the memset so the current timestamp needs to be restored.
So why doing a full memset and not only on the array ?
Quoted 8 lines
Quoted 4 lines
Now the real question is whether you really need all that math, checks and memsets in the irq hotpath. If you make the storage slightly larger then you can just store the values unconditionally in the circular buffer and do all the computational stuff when you really it.
Well... given that you need an IRQ everytime you come out of idle that means there will always be more IRQs than entries into idle, so you're probably right.
Glad you agree.
Thanks,
tglx
Quoted 19 lines · Thomas Gleixner
Quoted 18 lines · Nicolas Pitre
Quoted 16 lines · Thomas Gleixner
kernel/irq/timings.c line 62
Quoted 7 lines
kernel/irq/timings.c new file +7
-0+ diff = now - prev; + +/* +* microsec (actually 1024th of a milisec) precision is good +* enough for our purpose. +*/ + diff >>=10 ;And that shift instruction is required because of the following?
kernel/irq/timings.c line 69
Quoted 2 lines
* Otherwise we know the magnitude of diff is
kernel/irq/timings.c new file +1
-0+* well within 32 bits. AFAICT that's pointless. You are not saving anything because
NSEC_PER_SECis smaller than 2^32 and your 8 values are not going to overflow 64 bit in the sum.
Quoted 3 lines
Quoted 1 line
Those values are squared later, so we really want 32 bits here.
Well, you can do sum >> 10 exaclty once when you calculate stuff.
Given your later argument I agree.
Quoted 11 lines
Quoted 9 lines
Quoted 6 lines
kernel/irq/timings.c line 73
Quoted 4 lines
kernel/irq/timings.c new file +4
-0+*/ +if (unlikely (diff >USEC_PER_SEC )) { +memset (timings,0 ,sizeof (*timings)); + timings->timestamp = now;Redundant store.
We just trashed all our data with the memset so the current timestamp needs to be restored.
So why doing a full memset and not only on the array ?
Go figure. This code has come a long way.
Quoted 15 lines
Quoted 8 lines
Quoted 4 lines
Now the real question is whether you really need all that math, checks and memsets in the irq hotpath. If you make the storage slightly larger then you can just store the values unconditionally in the circular buffer and do all the computational stuff when you really it.
Well... given that you need an IRQ everytime you come out of idle that means there will always be more IRQs than entries into idle, so you're probably right.
Glad you agree.
Thanks,
tglx
On 06/10/2016 04:52 PM, Thomas Gleixner wrote:
Hi Thomas,
[ ... ]
Quoted 5 lines
Quoted 5 lines
kernel/irq/timings.c new file +5
-0+ now =local_clock (); + prev = timings->timestamp; + timings->timestamp = now; + +/*
Quoted 8 lines
kernel/irq/timings.c line 54
Quoted 5 lines
kernel/irq/timings.c new file +5
-0+* If it is the first interrupt of the series, we can't +* compute an interval, just store the timestamp and exit. +*/ +if (unlikely (!prev)) +return ;The delta will be large enough that you drop out in the check below. So you can spare that conditional.
Good point.
Quoted 18 lines
kernel/irq/timings.c line 62
Quoted 8 lines
kernel/irq/timings.c new file +8
-0+ + diff = now - prev; + +/* +* microsec (actually 1024th of a milisec) precision is good +* enough for our purpose. +*/ + diff >>=10 ;And that shift instruction is required because of the following?
kernel/irq/timings.c line 69
Quoted 2 lines
* Otherwise we know the magnitude of diff is
kernel/irq/timings.c new file +1
-0+* well within 32 bits. AFAICT that's pointless. You are not saving anything because
NSEC_PER_SECis smaller than 2^32 and your 8 values are not going to overflow 64 bit in the sum.
Quoted 6 lines
kernel/irq/timings.c line 73
Quoted 4 lines
kernel/irq/timings.c new file +4
-0+*/ +if (unlikely (diff >USEC_PER_SEC )) { +memset (timings,0 ,sizeof (*timings)); + timings->timestamp = now;Redundant store.
Yeah, I thought it was more efficient than:
memset(timings->value, 0, sizeof(timings->value)); timings->w_index = 0; timings->sum = 0;
Quoted 12 lines
Quoted 12 lines
kernel/irq/timings.c new file +12
-0+return ; + } + +/* The oldest value corresponds to the next index. */ + timings->w_index = (timings->w_index +1 ) &IRQ_TIMINGS_MASK ; + +/* +* Remove the oldest value from the summing. If this is the +* first time we go through this array slot, the previous +* value will be zero and we won't substract anything from the +* current sum. Hence this code relies on a zero-ed structure. +*/
Quoted 8 lines
kernel/irq/timings.c line 88
Quoted 3 lines
kernel/irq/timings.c new file +3
-0+ timings->sum -= timings->values[timings->w_index]; + timings->values[timings->w_index] = diff; + timings->sum += diff;Now the real question is whether you really need all that math, checks and memsets in the irq hotpath. If you make the storage slightly larger then you can just store the values unconditionally in the circular buffer and do all the computational stuff when you really it.
Yes, that was one concern when I wrote the code: do some basic computation when an interrupt occurs, and the rest after or do the entire math when entering idle.
If the storage is a bit larger (let's say 16 values) and there is no memset and the sum is not computed, at least we need a count for the number of values in the array before this one is fulfilled, otherwise the statistics will be wrong as we will take into account the entire array with old values, no ?
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 11 lines · Daniel Lezcano
Quoted 8 lines · Thomas Gleixner
kernel/irq/timings.c line 88
Quoted 3 lines
kernel/irq/timings.c new file +3
-0+ timings->sum -= timings->values[timings->w_index]; + timings->values[timings->w_index] = diff; + timings->sum += diff;Now the real question is whether you really need all that math, checks and memsets in the irq hotpath. If you make the storage slightly larger then you can just store the values unconditionally in the circular buffer and do all the computational stuff when you really it.
Quoted 8 lines
Yes, that was one concern when I wrote the code: do some basic computation when an interrupt occurs, and the rest after or do the entire math when entering idle.
If the storage is a bit larger (let's say 16 values) and there is no memset and the sum is not computed, at least we need a count for the number of values in the array before this one is fulfilled, otherwise the statistics will be wrong as we will take into account the entire array with old values, no ?
The point is not to change from 8 to 16 entries, but to store raw 64-bit timestamps instead of computed 32-bit deltas. Whether or not those timestamps are too far apart and discarded can be done at idle entry time.
Nicolas
Quoted 22 lines · Nicolas Pitre
Quoted 11 lines · Daniel Lezcano
Quoted 8 lines · Thomas Gleixner
kernel/irq/timings.c line 88
Quoted 3 lines
kernel/irq/timings.c new file +3
-0+ timings->sum -= timings->values[timings->w_index]; + timings->values[timings->w_index] = diff; + timings->sum += diff;Now the real question is whether you really need all that math, checks and memsets in the irq hotpath. If you make the storage slightly larger then you can just store the values unconditionally in the circular buffer and do all the computational stuff when you really it.
Quoted 8 lines
Yes, that was one concern when I wrote the code: do some basic computation when an interrupt occurs, and the rest after or do the entire math when entering idle.
If the storage is a bit larger (let's say 16 values) and there is no memset and the sum is not computed, at least we need a count for the number of values in the array before this one is fulfilled, otherwise the statistics will be wrong as we will take into account the entire array with old values, no ?
Quoted 4 lines
The point is not to change from 8 to 16 entries, but to store raw 64-bit timestamps instead of computed 32-bit deltas. Whether or not those timestamps are too far apart and discarded can be done at idle entry time.
Ah, ok. That makes sense.
Thanks for the clarification.
-- Daniel
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 10 lines · Nicolas Pitre
Quoted 4 lines · Daniel Lezcano
If the storage is a bit larger (let's say 16 values) and there is no memset and the sum is not computed, at least we need a count for the number of values in the array before this one is fulfilled, otherwise the statistics will be wrong as we will take into account the entire array with old values, no ?
The point is not to change from 8 to 16 entries, but to store raw 64-bit timestamps instead of computed 32-bit deltas. Whether or not those timestamps are too far apart and discarded can be done at idle entry time.
Correct, and you don't have to know how many timestamps are in the array simply because if it is cleared at init time, then any not yet set value will create a large gap, which you filter out.
The point is to make the fast path overhead as small as possible. And if that's just a store and index increment, then it can be inline and not a function call.
Thanks,
tglx