Skip to content

Commit

Permalink
Merge branch 'natoscott-pcp-percpu-intr'
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastien GODARD <[email protected]>
  • Loading branch information
sysstat committed Feb 9, 2022
2 parents 09b22ac + 583285d commit c2242b6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 43 deletions.
36 changes: 22 additions & 14 deletions pcp_def_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,36 @@
*
* IN:
* @a Activity structure with statistics.
* @indom PCP domain for interrupts metrics.
* @cpu CPU number (0 is cpu0, 1 is cpu1, etc.)
***************************************************************************
*/
void pcp_def_percpu_int_metrics(struct activity *a, pmInDom indom)
void pcp_def_percpu_int_metrics(struct activity *a, int cpu)
{
int inst = 1;
char name[64];
#ifdef HAVE_PCP
char buf[64];
struct sa_item *list = a->item_list;
static pmInDom indom = PM_INDOM_NULL;
static int inst = 0;

/* Create per-CPU metrics for A_IRQ */
while (list != NULL) {
snprintf(name, sizeof(name), "kernel.percpu.interrupts.%s", list->item_name);
name[sizeof(name) - 1] = '\0';

/* Metric name cannot contain digits :-( Translate them to characters instead */
replace_digits(name);
if (indom == PM_INDOM_NULL) {
/* Create domain */
indom = pmInDom_build(60, 40);

pmiAddMetric(name,
pmiID(60, 4, inst++), PM_TYPE_U64, indom, PM_SEM_COUNTER,
/* Create metric */
pmiAddMetric("kernel.percpu.interrupts",
pmiID(60, 4, 1), PM_TYPE_U32, indom, PM_SEM_COUNTER,
pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
}

/* Create instance for each interrupt for the current CPU */
while (list != NULL) {
snprintf(buf, sizeof(buf), "%s::cpu%d", list->item_name, cpu);
buf[sizeof(buf) - 1] = '\0';

pmiAddInstance(indom, buf, inst++);
list = list->next;
}
#endif /* HAVE_PCP */
}

/*
Expand Down Expand Up @@ -247,7 +255,7 @@ void pcp_def_cpu_metrics(struct activity *a)

else if (a->id == A_IRQ) {
/* Create per-CPU interrupts metrics */
pcp_def_percpu_int_metrics(a, indom);
pcp_def_percpu_int_metrics(a, i - 1);
}
first = FALSE;
}
Expand Down
17 changes: 6 additions & 11 deletions pcp_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ __print_funct_t pcp_print_irq_stats(struct activity *a, int curr)
{
#ifdef HAVE_PCP
int i, c;
char buf[64], cpuno[64], name[64];
char buf[64], name[64];
struct stats_irq *stc_cpu_irq, *stc_cpuall_irq;
unsigned char masked_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};

Expand All @@ -219,9 +219,9 @@ __print_funct_t pcp_print_irq_stats(struct activity *a, int curr)
stc_cpuall_irq = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);

if (a->item_list != NULL) {
/* A list of devices has been entered on the command line */
/* A list of interrupts has been entered on the command line */
if (!search_list_item(a->item_list, stc_cpuall_irq->irq_name))
/* Device not found */
/* Interrupt not found in list */
continue;
}

Expand Down Expand Up @@ -250,16 +250,11 @@ __print_funct_t pcp_print_irq_stats(struct activity *a, int curr)
}
else {
/* This is a particular CPU */
sprintf(cpuno, "cpu%d", c - 1);

snprintf(name, sizeof(name), "kernel.percpu.interrupts.%s",
stc_cpuall_irq->irq_name);
snprintf(name, sizeof(name), "%s::cpu%d",
stc_cpuall_irq->irq_name, c - 1);
name[sizeof(name) - 1] = '\0';

/* Metric name cannot contain digits */
replace_digits(name);

pmiPutValue(name, cpuno, buf);
pmiPutValue("kernel.percpu.interrupts", name, buf);
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions sa.h
Original file line number Diff line number Diff line change
Expand Up @@ -1576,8 +1576,6 @@ int read_record_hdr
int, size_t, uint64_t, struct report_format *);
void reallocate_all_buffers
(struct activity *, __nr_t);
void replace_digits
(char []);
void replace_nonprintable_char
(int, char *);
int sa_fread
Expand Down
16 changes: 0 additions & 16 deletions sadf_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1728,19 +1728,3 @@ void init_custom_color_palette()
}
}
}

/*
***************************************************************************
* Replace digits in a string with letters ('0' -> 'a', etc.
***************************************************************************
*/
void replace_digits(char name[])
{
int i;

for (i = 0; i < strlen(name); i++) {
if ((name[i] >= '0') && (name[i] <= '9')) {
name[i] += 'a' - '0';
}
}
}

0 comments on commit c2242b6

Please sign in to comment.