Browse files

fix empty interrupt statistic when CPU1 is offline

File "/proc/interrupts" contains statistics for CPUs that are not
only available, but also online. That is, when reading the
information from this file should use the number of CPUs that are
online.
In this patch, in all functions where the information is read from
the file "/proc/interrupts", function "cpu_cores_count_get"
is replaced by the function "cpu_online_cores_count_get".

Signed-off-by: Oleksandr_Tyshchenko <oleksandr.tyshchenko@ti.com>
  • Loading branch information...
1 parent 904ea26 commit 3bff5605f2bf25fd4bce18fae8081a981bfb4e50 Oleksandr_Tyshchenko committed with Patrick Titiano Sep 25, 2012
Showing with 24 additions and 3 deletions.
  1. +20 −0 common/cpuinfo.c
  2. +1 −0 common/cpuinfo.h
  3. +3 −3 linux/interrupts.c
View
20 common/cpuinfo.c
@@ -1116,6 +1116,26 @@ double cpu_load_get(unsigned int delta_idle,
return load;
}
+/* ------------------------------------------------------------------------*//**
+ * @FUNCTION cpu_online_cores_count_get
+ * @BRIEF return the number of CPU cores online
+ * @RETURNS number of CPU cores online
+ * @param[in] none
+ * @DESCRIPTION return the number of CPU cores online
+ *//*------------------------------------------------------------------------ */
+unsigned int cpu_online_cores_count_get(void)
+{
+ unsigned int i, cpu_total_count, cpu_online_count;
+
+ cpu_total_count = cpu_cores_count_get();
+ cpu_online_count = 0;
+ for (i = 0; i < cpu_total_count; i ++) {
+ if (cpu_is_online(i) == 1)
+ cpu_online_count ++;
+ }
+
+ return cpu_online_count;
+}
/* ------------------------------------------------------------------------*//**
* @FUNCTION cpu_cores_count_get
View
1 common/cpuinfo.h
@@ -135,6 +135,7 @@ char *cpu_gets(char s[CPU_NAME_MAX_LENGTH]);
char *cpu_full_name_get(char s[CPU_FULL_NAME_MAX_LENGTH]);
unsigned int cpu_cores_count_get(void);
+unsigned int cpu_online_cores_count_get(void);
unsigned int cpu_is_online(unsigned short cpu);
int cpu_proc_stats_get(unsigned int cpu,
View
6 linux/interrupts.c
@@ -146,7 +146,7 @@ int irq_total_count_get(FILE *fp)
char irq_ctrl_name[256], dev_name[256];
int ret;
- cpu_count = cpu_cores_count_get();
+ cpu_count = cpu_online_cores_count_get();
if (cpu_count == 0) {
fprintf(stderr, "%s(): cpu_count == 0!\n", __func__);
return IRQ_ERR_CPU;
@@ -244,7 +244,7 @@ int irq_count_get(unsigned int n, FILE *fp)
char irq_ctrl_name[256], dev_name[256];
int ret;
- cpu_count = cpu_cores_count_get();
+ cpu_count = cpu_online_cores_count_get();
if (cpu_count == 0) {
fprintf(stderr, "%s(): cpu_count == 0!\n", __func__);
return IRQ_ERR_CPU;
@@ -360,7 +360,7 @@ char *irq_dev_name_get(unsigned int n, FILE *fp, char name[256])
int ret;
dprintf("%s(): looking for irq #%u name ...\n", __func__, n);
- cpu_count = cpu_cores_count_get();
+ cpu_count = cpu_online_cores_count_get();
if (cpu_count == 0) {
fprintf(stderr, "%s(): cpu_count == 0!\n", __func__);
return NULL;

0 comments on commit 3bff560

Please sign in to comment.