[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <86802c440808091535g394f0567x675dbb93d1a8f91@mail.gmail.com>
Date: Sat, 9 Aug 2008 15:35:46 -0700
From: "Yinghai Lu" <yhlu.kernel@...il.com>
To: "Eric W. Biederman" <ebiederm@...ssion.com>
Cc: "H. Peter Anvin" <hpa@...or.com>, "Ingo Molnar" <mingo@...e.hu>,
"Thomas Gleixner" <tglx@...utronix.de>,
"Dhaval Giani" <dhaval@...ux.vnet.ibm.com>,
"Mike Travis" <travis@....com>,
"Andrew Morton" <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 08/42] introduce nr_irqs
On Sat, Aug 9, 2008 at 2:38 PM, Eric W. Biederman <ebiederm@...ssion.com> wrote:
> "Yinghai Lu" <yhlu.kernel@...il.com> writes:
>
>> On Sat, Aug 9, 2008 at 9:02 AM, Eric W. Biederman <ebiederm@...ssion.com> wrote:
>>> "Yinghai Lu" <yhlu.kernel@...il.com> writes:
>>>
>>>>> Also, what's the point, if it's just a renaming?
>>>>
>>>> that is the start point.
>>>> nr_irqs is variable, and will be probed later. and use that number to
>>>> init dyn_alloc.
>>>
>>> YH.
>>>
>>> In my conception the code in kernel/irq.c that today does:
>>>
>>> struct irq_desc *desc;
>>> if (irq >= NR_IRQS)
>>> return -EINVAL;
>>> desc = irq_desc + irq;
>>>
>>> Should become:
>>>
>>> struct irq_desc *desc;
>>> desc = irq_desc(irq);
>>> if (!desc)
>>> return -EINVAL;
>>>
>>
>> OK.
>>
>> also want to introduce dummy
>> struct irq_desc
>> {
>> unsigned int irq;
>> };
>>
>> in linux/interrupt.h if GENERIC_HARDIRQS is not defined.
>> so could have same interface
>> irq_desc()
>> and
>> for_each_irq_desc(irq, desc)
>
> What would use it? irq_desc doesn't even exist if GENERIC_HARDIRQS are
> not defined.
>
> Far far in the future we may want to introduce an opaque type
> struct irq. For use with linux/interrupt.h Allowing things
> like irq_request(struct irq *irq, ...); For now those kinds
> of interfaces should be internal to the genirq code.
From: Yinghai Lu <yhlu.kernel@...il.com>
Date: Fri, 8 Aug 2008 13:56:15 -0700
Subject: [PATCH 31/42] replace loop with nr_irqs for proc/stat
so don't all irq_desc at begining to allocate all.
and only call that when needed
v2: make sure arch without GENERIC_HARDIRQS works too
Signed-off-by: Yinghai Lu <yhlu.kernel@...il.com>
---
fs/proc/proc_misc.c | 50 ++++++++++++++++++++++++++++++++++++--------------
1 file changed, 36 insertions(+), 14 deletions(-)
Index: linux-2.6/fs/proc/proc_misc.c
===================================================================
--- linux-2.6.orig/fs/proc/proc_misc.c
+++ linux-2.6/fs/proc/proc_misc.c
@@ -495,17 +495,16 @@ static const struct file_operations proc
static int show_stat(struct seq_file *p, void *v)
{
- int i;
+ int i, j;
unsigned long jif;
cputime64_t user, nice, system, idle, iowait, irq, softirq, steal;
cputime64_t guest;
u64 sum = 0;
struct timespec boottime;
- unsigned int *per_irq_sum;
-
- per_irq_sum = kzalloc(sizeof(unsigned int)*nr_irqs, GFP_KERNEL);
- if (!per_irq_sum)
- return -ENOMEM;
+ unsigned int per_irq_sum;
+#ifdef CONFIG_GENERIC_HARDIRQS
+ struct irq_desc *desc;
+#endif
user = nice = system = idle = iowait =
irq = softirq = steal = cputime64_zero;
@@ -514,8 +513,6 @@ static int show_stat(struct seq_file *p,
jif = boottime.tv_sec;
for_each_possible_cpu(i) {
- int j;
-
user = cputime64_add(user, kstat_cpu(i).cpustat.user);
nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice);
system = cputime64_add(system, kstat_cpu(i).cpustat.system);
@@ -525,10 +522,12 @@ static int show_stat(struct seq_file *p,
softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq);
steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal);
guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest);
- for (j = 0; j < nr_irqs; j++) {
- unsigned int temp = kstat_irqs_cpu(j, i);
+ for_each_irq_desc(j, desc)
+ {
+ unsigned int temp;
+
+ temp = kstat_irqs_cpu(j, i);
sum += temp;
- per_irq_sum[j] += temp;
}
sum += arch_irq_stat_cpu(i);
}
@@ -571,8 +570,23 @@ static int show_stat(struct seq_file *p,
}
seq_printf(p, "intr %llu", (unsigned long long)sum);
- for (i = 0; i < nr_irqs; i++)
- seq_printf(p, " %u", per_irq_sum[i]);
+ /* sum again ? it could be updated? */
+ 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,
"\nctxt %llu\n"
@@ -586,7 +600,6 @@ static int show_stat(struct seq_file *p,
nr_running(),
nr_iowait());
- kfree(per_irq_sum);
return 0;
}
Index: linux-2.6/include/linux/interrupt.h
===================================================================
--- linux-2.6.orig/include/linux/interrupt.h
+++ linux-2.6/include/linux/interrupt.h
@@ -17,6 +17,11 @@
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
* linux/ioport.h to select the interrupt line behaviour. When
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists