Migrate and enhance IRQ statistics
PATCH 2/3 Migrate and enhance IRQ statistics
This patch migrates the xnintr hits statistics to the new xnstat subsystem and introduces per-CPU runtime statistics to xnintr entities. The latter allows to differentiate between ISR and thread activity under /proc/xenomai/stat.
For querying the xnintr statistics, a scalable service based on IRQ list revisions is introduced (xnintr_query), just like it already exists for threads.
Accounting model:
- hits are only counted if the ISR returns XN_ISR_HANDLED
- runtime is accounted over each ISR invocation, independent of its return value
As a hopefully not critical side effect, the native intr services now only reports non-zero hit counters if XENO_OPT_STATS in enabled. This fact is documented in the rt_intr_info structure.
Jan
--- include/native/intr.h | 3 - include/nucleus/intr.h | 19 +++++- ksrc/nucleus/intr.c | 131 ++++++++++++++++++++++++++++++++++++++++++++--- ksrc/nucleus/module.c | 35 ++++++++++++ ksrc/skins/native/intr.c | 28 +++++++--- 5 files changed, 196 insertions(+), 20 deletions(-)
include/nucleus/intr.h +16 -3
@@ -39,6 +39,8 @@ #if defined(__KERNEL__) || defined(__XENO_SIM__) +#include <nucleus/stat.h> + typedef struct xnintr { #if defined(CONFIG_XENO_OPT_SHIRQ_LEVEL) || defined(CONFIG_XENO_OPT_SHIRQ_EDGE)
@@ -51,8 +53,6 @@ typedef struct xnintr {void *cookie;/* !< User-defined cookie value. */ -unsigned long hits;/* !< Number of receipts (since attachment). */ -xnflags_t flags;/* !< Creation flags. */ unsigned irq;/* !< IRQ number. */
@@ -61,9 +61,18 @@ typedef struct xnintr {const char *name;/* !< Symbolic name. */ +struct { +xnstat_counter_t hits;/* !< Number of handled receipts since attachment. */ +xnstat_runtime_t account;/* !< Runtime accounting entity */ + } stat[RTHAL_NR_CPUS ]; + } xnintr_t;extern xnintr_t nkclock; +#ifdef CONFIG_XENO_OPT_STATS +extern int xnintr_count; +extern int xnintr_list_rev; +#endif #ifdef __cplusplusextern "C" {
@@ -94,10 +103,14 @@ int xnintr_detach(xnintr_t *intr);int xnintr_enable (xnintr_t *intr);int xnintr_disable (xnintr_t *intr); - +xnarch_cpumask_t xnintr_affinity (xnintr_t *intr,xnarch_cpumask_t cpumask); +int xnintr_query (int irq,int *cpu,xnintr_t **prev,int revision,char *name, +unsigned long *hits,xnticks_t *runtime, +xnticks_t *account_period); + #ifdef __cplusplus }#endif
ksrc/nucleus/intr.c +124 -7
248 lines not on this page · raw message
ksrc/nucleus/module.c +34 -1
@@ -351,7 +351,7 @@ static int stat_seq_open(struct inode *istruct seq_file *seq;xnholder_t *holder;struct stat_seq_info *stat_info; -int err, count, thrq_rev; +int err, count, thrq_rev, intr_rev, irq;spl_t s;if (!nkpod)
@@ -364,6 +364,9 @@ static int stat_seq_open(struct inode *i holder =getheadq (&nkpod->threadq); thrq_rev = nkpod->threadq_rev; + count += xnintr_count *RTHAL_NR_CPUS ; + intr_rev = xnintr_list_rev; +xnlock_put_irqrestore (&nklock, s);if (iter)
@@ -425,6 +428,36 @@ static int stat_seq_open(struct inode *ixnlock_put_irqrestore (&nklock, s); } +/* Iterate over all IRQ numbers, ... */ +for (irq =0 ; irq <RTHAL_NR_IRQS ; irq++) { +xnintr_t *prev =NULL ; +int cpu =0 ; +int err; + +/* ...over all shared IRQs on all CPUs */ +while (1 ) { + stat_info = &iter->stat_info[iter->nentries]; + stat_info->cpu = cpu; + + err =xnintr_query (irq, &cpu, &prev, intr_rev, + stat_info->name, + &stat_info->csw, + &stat_info->runtime, + &stat_info->account_period); +if (err ==EAGAIN ) + goto restart; +if (err) +break ;/* line unused or end of chain */ + + stat_info->pid =0 ; + stat_info->status =0 ; + stat_info->ssw =0 ; + stat_info->pf =0 ; + + iter->nentries++; + }; + } + seq = (struct seq_file *)file->private_data; seq->private = iter;
include/native/intr.h +2 -1
@@ -36,7 +36,8 @@ typedef struct rt_intr_info {unsigned irq;/* !< Interrupt request number. */ -unsigned long hits;/* !< Number of receipts (since attachment). */ +unsigned long hits;/* !< Number of receipts (since attachment), 0 if +statistics support is disable in the nucleus. */ char name[XNOBJECT_NAME_LEN ];/* !< Symbolic name. */
ksrc/skins/native/intr.c +20 -8
@@ -47,6 +47,17 @@ void __native_intr_pkg_cleanup(void)rt_intr_delete (link2intr (holder)); } +static unsigned long __intr_get_hits (RT_INTR *intr) +{ +unsigned long sum =0 ; +int cpu; + +for (cpu =0 ; cpu <XNARCH_NR_CPUS ; cpu++) + sum +=xnstat_counter_get (&intr->intr_base.stat[cpu].hits); + +return sum; +} +#ifdef CONFIG_XENO_EXPORT_REGISTRY static int __intr_read_proc(char *page,
@@ -56,16 +67,17 @@ static int __intr_read_proc(char *page,RT_INTR *intr = (RT_INTR *)data;char *p = page;int len; +spl_t s; + +xnlock_get_irqsave (&nklock, s);#ifdef CONFIG_XENO_OPT_PERVASIVE {xnpholder_t *holder; -spl_t s; - -xnlock_get_irqsave (&nklock, s); p +=sprintf (p,"hits=%lu, pending=%u, mode=0x%x\n" , - intr->intr_base.hits, intr->pending, intr->mode); +__intr_get_hits (intr), intr->pending, + intr->mode);/* Pended interrupt -- dump waiters. */
@@ -78,13 +90,13 @@ static int __intr_read_proc(char *page,nextpq (xnsynch_wait_queue (&intr->synch_base), holder); } - -xnlock_put_irqrestore (&nklock, s); }#else /* !CONFIG_XENO_OPT_PERVASIVE */ - p +=sprintf (p,"hits=%lu\n" , intr->intr_base.hits); + p +=sprintf (p,"hits=%lu\n" ,__intr_get_hits (intr));#endif /* CONFIG_XENO_OPT_PERVASIVE */ +xnlock_put_irqrestore (&nklock, s); + len = (p - page) - off;if (len <= off + count) *eof =1 ;
@@ -512,7 +524,7 @@ int rt_intr_inquire(RT_INTR *intr, RT_IN }strcpy (info->name, intr->name); - info->hits = intr->intr_base.hits; + info->hits =__intr_get_hits (intr); info->irq = intr->intr_base.irq; unlock_and_exit:
Quoted 9 lines · Jan Kiszka
This patch migrates the xnintr hits statistics to the new xnstat subsystem and introduces per-CPU runtime statistics to xnintr entities. The latter allows to differentiate between ISR and thread activity under
/proc/xenomai/stat.For querying the xnintr statistics, a scalable service based on IRQ list revisions is introduced (
xnintr_query), just like it already exists for threads.
Quoted 9 lines
Accounting model:
- hits are only counted if the ISR returnsXN_ISR_HANDLED
- runtime is accounted over each ISR invocation, independent of its return valueAs a hopefully not critical side effect, the native intr services now only reports non-zero hit counters if
XENO_OPT_STATSin enabled. This fact is documented in thert_intr_infostructure.
This patch causes an oops on process cleanup here - I'm still investigating (likely an outdated xnstat_runtime reference)...
Jan