irq, fs/proc: replace loop with nr_irqs for proc/stat
Replace another nr_irqs loop to avoid the allocation of all sparse irq entries - use for_each_irq_desc instead. v2: make sure arch without GENERIC_HARDIRQS works too Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
@ -30,6 +30,7 @@
|
|||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
#include <linux/mmzone.h>
|
#include <linux/mmzone.h>
|
||||||
#include <linux/pagemap.h>
|
#include <linux/pagemap.h>
|
||||||
|
#include <linux/irq.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/swap.h>
|
#include <linux/swap.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
@ -501,17 +502,16 @@ static const struct file_operations proc_vmalloc_operations = {
|
|||||||
|
|
||||||
static int show_stat(struct seq_file *p, void *v)
|
static int show_stat(struct seq_file *p, void *v)
|
||||||
{
|
{
|
||||||
int i;
|
int i, j;
|
||||||
unsigned long jif;
|
unsigned long jif;
|
||||||
cputime64_t user, nice, system, idle, iowait, irq, softirq, steal;
|
cputime64_t user, nice, system, idle, iowait, irq, softirq, steal;
|
||||||
cputime64_t guest;
|
cputime64_t guest;
|
||||||
u64 sum = 0;
|
u64 sum = 0;
|
||||||
struct timespec boottime;
|
struct timespec boottime;
|
||||||
unsigned int *per_irq_sum;
|
unsigned int per_irq_sum;
|
||||||
|
#ifdef CONFIG_GENERIC_HARDIRQS
|
||||||
per_irq_sum = kzalloc(sizeof(unsigned int)*nr_irqs, GFP_KERNEL);
|
struct irq_desc *desc;
|
||||||
if (!per_irq_sum)
|
#endif
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
user = nice = system = idle = iowait =
|
user = nice = system = idle = iowait =
|
||||||
irq = softirq = steal = cputime64_zero;
|
irq = softirq = steal = cputime64_zero;
|
||||||
@ -520,8 +520,6 @@ static int show_stat(struct seq_file *p, void *v)
|
|||||||
jif = boottime.tv_sec;
|
jif = boottime.tv_sec;
|
||||||
|
|
||||||
for_each_possible_cpu(i) {
|
for_each_possible_cpu(i) {
|
||||||
int j;
|
|
||||||
|
|
||||||
user = cputime64_add(user, kstat_cpu(i).cpustat.user);
|
user = cputime64_add(user, kstat_cpu(i).cpustat.user);
|
||||||
nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice);
|
nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice);
|
||||||
system = cputime64_add(system, kstat_cpu(i).cpustat.system);
|
system = cputime64_add(system, kstat_cpu(i).cpustat.system);
|
||||||
@ -531,10 +529,12 @@ static int show_stat(struct seq_file *p, void *v)
|
|||||||
softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq);
|
softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq);
|
||||||
steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal);
|
steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal);
|
||||||
guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest);
|
guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest);
|
||||||
for (j = 0; j < nr_irqs; j++) {
|
for_each_irq_desc(j, desc)
|
||||||
unsigned int temp = kstat_irqs_cpu(j, i);
|
{
|
||||||
|
unsigned int temp;
|
||||||
|
|
||||||
|
temp = kstat_irqs_cpu(j, i);
|
||||||
sum += temp;
|
sum += temp;
|
||||||
per_irq_sum[j] += temp;
|
|
||||||
}
|
}
|
||||||
sum += arch_irq_stat_cpu(i);
|
sum += arch_irq_stat_cpu(i);
|
||||||
}
|
}
|
||||||
@ -577,8 +577,23 @@ static int show_stat(struct seq_file *p, void *v)
|
|||||||
}
|
}
|
||||||
seq_printf(p, "intr %llu", (unsigned long long)sum);
|
seq_printf(p, "intr %llu", (unsigned long long)sum);
|
||||||
|
|
||||||
for (i = 0; i < nr_irqs; i++)
|
/* sum again ? it could be updated? */
|
||||||
seq_printf(p, " %u", per_irq_sum[i]);
|
for_each_irq_desc(j, desc)
|
||||||
|
{
|
||||||
|
per_irq_sum = 0;
|
||||||
|
for_each_possible_cpu(i) {
|
||||||
|
unsigned int temp;
|
||||||
|
|
||||||
|
temp = kstat_irqs_cpu(j, i);
|
||||||
|
per_irq_sum += temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_HAVE_SPARSE_IRQ
|
||||||
|
seq_printf(p, " %u:%u", j, per_irq_sum);
|
||||||
|
#else
|
||||||
|
seq_printf(p, " %u", per_irq_sum);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
seq_printf(p,
|
seq_printf(p,
|
||||||
"\nctxt %llu\n"
|
"\nctxt %llu\n"
|
||||||
@ -592,7 +607,6 @@ static int show_stat(struct seq_file *p, void *v)
|
|||||||
nr_running(),
|
nr_running(),
|
||||||
nr_iowait());
|
nr_iowait());
|
||||||
|
|
||||||
kfree(per_irq_sum);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
|
|
||||||
extern int nr_irqs;
|
extern int nr_irqs;
|
||||||
|
|
||||||
|
#ifndef CONFIG_GENERIC_HARDIRQS
|
||||||
|
#define for_each_irq_desc(irq, desc) \
|
||||||
|
for (irq = 0; irq < nr_irqs; irq++)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These correspond to the IORESOURCE_IRQ_* defines in
|
* These correspond to the IORESOURCE_IRQ_* defines in
|
||||||
* linux/ioport.h to select the interrupt line behaviour. When
|
* linux/ioport.h to select the interrupt line behaviour. When
|
||||||
|
Reference in New Issue
Block a user