Browse Source

Parse local_cpus

Serj Kalichev 10 years ago
parent
commit
eb21dda81b
4 changed files with 19 additions and 9 deletions
  1. 5 3
      birq.c
  2. 1 2
      cpu_parse.c
  3. 1 1
      irq.h
  4. 12 3
      irq_parse.c

+ 5 - 3
birq.c

@@ -140,12 +140,14 @@ int main(int argc, char **argv)
 	sig_act.sa_handler = &rescan_sighandler;
 	sigaction(SIGUSR1, &sig_act, NULL);
 
+	/* Scan CPUs */
+	cpus = lub_list_new(cpu_list_compare);
+	scan_cpus(cpus);
+	show_cpus(cpus);
+
 	/* Prepare data structures */
 	irqs = lub_list_new(irq_list_compare);
 
-cpus = lub_list_new(cpu_list_compare);
-scan_cpus(cpus);
-show_cpus(cpus);
 
 	/* Main loop */
 	while (!sigterm) {

+ 1 - 2
cpu_parse.c

@@ -99,8 +99,7 @@ int cpu_list_free(lub_list_t *cpus)
 /* Show CPU information */
 static void show_cpu_info(cpu_t *cpu)
 {
-	char buf[NR_CPUS / 4 + 1];
-
+	char buf[NR_CPUS + 1];
 	cpumask_scnprintf(buf, sizeof(buf), cpu->cpumask);
 	printf("CPU %d package %d core %d mask %s\n", cpu->id, cpu->package_id, cpu->core_id, buf);
 }

+ 1 - 1
irq.h

@@ -8,7 +8,7 @@ struct irq_s {
 	char *type; /* IRQ type from /proc/interrupts like PCI-MSI-edge */
 	char *desc; /* IRQ text description - device list */
 	int refresh; /* Refresh flag. It !=0 if irq was found while populate */
-	
+	cpumask_t local_cpus;
 };
 typedef struct irq_s irq_t;
 

+ 12 - 3
irq_parse.c

@@ -88,7 +88,12 @@ int irq_list_free(lub_list_t *irqs)
 /* Show IRQ information */
 static void irq_show(irq_t *irq)
 {
-	printf("IRQ %3d [%s] %s\n", irq->irq, STR(irq->type), STR(irq->desc));
+	char buf[NR_CPUS + 1];
+	if (cpus_full(irq->local_cpus))
+		snprintf(buf, sizeof(buf), "*");
+	else
+		cpumask_scnprintf(buf, sizeof(buf), irq->local_cpus);
+	printf("IRQ %3d %s [%s] %s\n", irq->irq, buf, STR(irq->type), STR(irq->desc));
 }
 
 /* Show IRQ list */
@@ -125,8 +130,9 @@ static int parse_local_cpus(lub_list_t *irqs, const char *sysfs_path,
 		return -1;
 	}
 	fclose(fd);
-/*	printf("%d %s %s\n", num, str, sysfs_path);
-*/	free(str);
+	cpumask_parse_user(str, strlen(str), irq->local_cpus);
+//	printf("%d %s %s\n", num, str, sysfs_path);
+	free(str);
 
 	return 0;
 }
@@ -230,6 +236,9 @@ int irq_list_populate(lub_list_t *irqs)
 		/* Set refresh flag because IRQ was found */
 		irq->refresh = 1;
 
+		/* By default all CPUs are local for IRQ */
+		cpus_setall(irq->local_cpus);
+
 		if (new) {
 			printf("Add new ");
 			irq_show(irq);