#include "version.h"
#include "mpstat.h"
-#include "rd_stats.h"
#include "count.h"
#include <locale.h> /* For setlocale() */
* Structure used to save total number of interrupts received
* among all CPU and for each CPU.
*/
-struct stats_irq *st_irq[3];
+struct stats_global_irq *st_irq[3];
/*
* Structures used to save, for each interrupt, the number
}
memset(st_node[i], 0, STATS_CPU_SIZE * nr_cpus);
- if ((st_irq[i] = (struct stats_irq *) malloc(STATS_IRQ_SIZE * nr_cpus))
+ if ((st_irq[i] = (struct stats_global_irq *) malloc(STATS_GLOBAL_IRQ_SIZE * nr_cpus))
== NULL) {
perror("malloc");
exit(4);
}
- memset(st_irq[i], 0, STATS_IRQ_SIZE * nr_cpus);
+ memset(st_irq[i], 0, STATS_GLOBAL_IRQ_SIZE * nr_cpus);
if ((st_irqcpu[i] = (struct stats_irqcpu *) malloc(STATS_IRQCPU_SIZE * nr_cpus * irqcpu_nr))
== NULL) {
void fwd_irq_values(struct stats_irqcpu *st_ic[], unsigned int c,
unsigned int last, int ic_nr, int curr)
{
- struct stats_irq *st_irq_i, *st_irq_j;
+ struct stats_global_irq *st_irq_i, *st_irq_j;
struct stats_irqcpu *p, *q;
int j;
char *prev_string, char *curr_string, unsigned char offline_cpu_bitmap[])
{
struct stats_cpu *scc, *scp;
- struct stats_irq *sic, *sip;
+ struct stats_global_irq *sic, *sip;
unsigned long long pc_itv;
int cpu;
unsigned char offline_cpu_bitmap[])
{
struct stats_cpu *scc, *scp;
- struct stats_irq *sic, *sip;
+ struct stats_global_irq *sic, *sip;
unsigned long long pc_itv;
int cpu, next = FALSE;
write_stats_core(!curr, curr, dis, cur_time[!curr], cur_time[curr]);
}
+/*
+ ***************************************************************************
+ * Read total number of interrupts from /proc/stat.
+ *
+ * IN:
+ * @st_irq Structure where total number of interrupts will be saved.
+ *
+ * OUT:
+ * @st_irq Structure with total number of interrupts.
+ ***************************************************************************
+ */
+void read_stat_total_irq(struct stats_global_irq *st_irq)
+{
+ FILE *fp;
+ char line[1024];
+ unsigned long long irq_nr;
+
+ if ((fp = fopen(STAT, "r")) == NULL)
+ return;
+
+ while (fgets(line, sizeof(line), fp) != NULL) {
+
+ if (!strncmp(line, "intr ", 5)) {
+ /* Read total number of interrupts received since system boot */
+ sscanf(line + 5, "%llu", &irq_nr);
+ st_irq->irq_nr = (unsigned int) irq_nr;
+
+ break;
+ }
+ }
+
+ fclose(fp);
+}
/*
***************************************************************************
* Read stats from /proc/interrupts or /proc/softirqs.
void read_interrupts_stat(char *file, struct stats_irqcpu *st_ic[], int ic_nr, int curr)
{
FILE *fp;
- struct stats_irq *st_irq_i;
+ struct stats_global_irq *st_irq_i;
struct stats_irqcpu *p;
char *line = NULL, *li;
unsigned long irq = 0;
/*
* No need to set (st_irqcpu + cpu * irqcpu_nr)->irq_name:
* This is the same as st_irqcpu->irq_name.
- * Now save current interrupt value for current CPU (in stats_irqcpu structure)
- * and total number of interrupts received by current CPU (in stats_irq structure).
+ * Now save current interrupt value for current CPU (in
+ * stats_irqcpu structure) and total number of interrupts
+ * received by current CPU (in stats_global_irq structure).
*/
p->interrupt = strtoul(cp, &next, 10);
st_irq_i->irq_nr += p->interrupt;
* (this is the first value on the line "intr:" in the /proc/stat file).
*/
if (DISPLAY_IRQ_SUM(actflags)) {
- read_stat_irq(st_irq[0], 1);
+ read_stat_total_irq(st_irq[0]);
}
/*
mp_tstamp[1] = mp_tstamp[0];
memset(st_cpu[1], 0, STATS_CPU_SIZE * (cpu_nr + 1));
memset(st_node[1], 0, STATS_CPU_SIZE * (cpu_nr + 1));
- memset(st_irq[1], 0, STATS_IRQ_SIZE * (cpu_nr + 1));
+ memset(st_irq[1], 0, STATS_GLOBAL_IRQ_SIZE * (cpu_nr + 1));
memset(st_irqcpu[1], 0, STATS_IRQCPU_SIZE * (cpu_nr + 1) * irqcpu_nr);
if (DISPLAY_SOFTIRQS(actflags)) {
memset(st_softirqcpu[1], 0, STATS_IRQCPU_SIZE * (cpu_nr + 1) * softirqcpu_nr);
uptime_cs[2] = uptime_cs[0];
memcpy(st_cpu[2], st_cpu[0], STATS_CPU_SIZE * (cpu_nr + 1));
memcpy(st_node[2], st_node[0], STATS_CPU_SIZE * (cpu_nr + 1));
- memcpy(st_irq[2], st_irq[0], STATS_IRQ_SIZE * (cpu_nr + 1));
+ memcpy(st_irq[2], st_irq[0], STATS_GLOBAL_IRQ_SIZE * (cpu_nr + 1));
memcpy(st_irqcpu[2], st_irqcpu[0], STATS_IRQCPU_SIZE * (cpu_nr + 1) * irqcpu_nr);
if (DISPLAY_SOFTIRQS(actflags)) {
memcpy(st_softirqcpu[2], st_softirqcpu[0],
/* Read total number of interrupts received among all CPU */
if (DISPLAY_IRQ_SUM(actflags)) {
- read_stat_irq(st_irq[curr], 1);
+ read_stat_total_irq(st_irq[curr]);
}
/*