* [PATCH for -tip] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c
@ 2008-12-25 10:46 KOSAKI Motohiro
2008-12-25 10:59 ` Ingo Molnar
0 siblings, 1 reply; 14+ messages in thread
From: KOSAKI Motohiro @ 2008-12-25 10:46 UTC (permalink / raw)
To: Yinghai Lu, Ingo Molnar, LKML; +Cc: kosaki.motohiro
I confirmed by alpha cross compiler.
==
Subject: [PATCH] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c
Impact: cleanup
commit 240d367b4e6c6e3c5075e034db14dba60a6f5fa7 has a bit strange analysis.
The fact is, irq_desc() can be used old architecuture too.
but old code don't include <linux/irq.h>.
right fixing is here.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Yinghai Lu <yinghai@kernel.org>
CC: Ingo Molnar <mingo@elte.hu>
---
fs/proc/stat.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
Index: b/fs/proc/stat.c
===================================================================
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -9,6 +9,7 @@
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/time.h>
+#include <linux/irq.h>
#include <asm/cputime.h>
#ifndef arch_irq_stat_cpu
@@ -27,6 +28,7 @@ static int show_stat(struct seq_file *p,
u64 sum = 0;
struct timespec boottime;
unsigned int per_irq_sum;
+ struct irq_desc *desc;
user = nice = system = idle = iowait =
irq = softirq = steal = cputime64_zero;
@@ -44,11 +46,10 @@ 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_each_irq_nr(j) {
-#ifdef CONFIG_SPARSE_IRQ
- if (!irq_to_desc(j))
+ for_each_irq_desc(j, desc) {
+ if (!desc)
continue;
-#endif
+
sum += kstat_irqs_cpu(j, i);
}
sum += arch_irq_stat_cpu(i);
@@ -95,12 +96,10 @@ static int show_stat(struct seq_file *p,
/* sum again ? it could be updated? */
for_each_irq_nr(j) {
per_irq_sum = 0;
-#ifdef CONFIG_SPARSE_IRQ
if (!irq_to_desc(j)) {
seq_printf(p, " %u", per_irq_sum);
continue;
}
-#endif
for_each_possible_cpu(i)
per_irq_sum += kstat_irqs_cpu(j, i);
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH for -tip] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c
2008-12-25 10:46 [PATCH for -tip] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c KOSAKI Motohiro
@ 2008-12-25 10:59 ` Ingo Molnar
2008-12-25 11:00 ` KOSAKI Motohiro
0 siblings, 1 reply; 14+ messages in thread
From: Ingo Molnar @ 2008-12-25 10:59 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: Yinghai Lu, LKML
* KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
>
> I confirmed by alpha cross compiler.
>
> ==
> Subject: [PATCH] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c
> Impact: cleanup
>
> commit 240d367b4e6c6e3c5075e034db14dba60a6f5fa7 has a bit strange analysis.
> The fact is, irq_desc() can be used old architecuture too.
> but old code don't include <linux/irq.h>.
>
> right fixing is here.
> +#include <linux/irq.h>
looks good, but linux/irq.h cannot be included on all architectures. (for
example s390 has no notion of 'hardirqs'). But we created linux/irqnr.h
for this purpose - so including that should work better.
Ingo
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH for -tip] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c
2008-12-25 10:59 ` Ingo Molnar
@ 2008-12-25 11:00 ` KOSAKI Motohiro
2008-12-25 12:40 ` KOSAKI Motohiro
0 siblings, 1 reply; 14+ messages in thread
From: KOSAKI Motohiro @ 2008-12-25 11:00 UTC (permalink / raw)
To: Ingo Molnar; +Cc: kosaki.motohiro, Yinghai Lu, LKML
>
> * KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
>
> >
> > I confirmed by alpha cross compiler.
> >
> > ==
> > Subject: [PATCH] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c
> > Impact: cleanup
> >
> > commit 240d367b4e6c6e3c5075e034db14dba60a6f5fa7 has a bit strange analysis.
> > The fact is, irq_desc() can be used old architecuture too.
> > but old code don't include <linux/irq.h>.
> >
> > right fixing is here.
>
> > +#include <linux/irq.h>
>
> looks good, but linux/irq.h cannot be included on all architectures. (for
> example s390 has no notion of 'hardirqs'). But we created linux/irqnr.h
> for this purpose - so including that should work better.
Oh, thanks good explain.
I'll fix soon.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH for -tip] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c
2008-12-25 11:00 ` KOSAKI Motohiro
@ 2008-12-25 12:40 ` KOSAKI Motohiro
2008-12-25 12:41 ` [PATCH for -tip] irq: for_each_irq_desc() makes simplify KOSAKI Motohiro
2008-12-25 14:46 ` [PATCH for -tip] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c KOSAKI Motohiro
0 siblings, 2 replies; 14+ messages in thread
From: KOSAKI Motohiro @ 2008-12-25 12:40 UTC (permalink / raw)
To: Ingo Molnar, Yinghai Lu, LKML; +Cc: kosaki.motohiro
> > > +#include <linux/irq.h>
> >
> > looks good, but linux/irq.h cannot be included on all architectures. (for
> > example s390 has no notion of 'hardirqs'). But we created linux/irqnr.h
> > for this purpose - so including that should work better.
>
> Oh, thanks good explain.
> I'll fix soon.
next spin is here.
I confirmed three architecture.
1. alpha (without SPARSE_IRQ, build test by cross compiler only)
2. ia64 (without SPARSE_IRQ)
3. x86_64 (with SPARSE_IRQ)
==
Subject: [PATCH] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c
Impact: cleanup
commit 240d367b4e6c6e3c5075e034db14dba60a6f5fa7 has a bit strange analysis.
irq_desc() can be used old architecuture.
but in old code, for_each_irq_desc() sit in <linux/irq.h> and its header
can't be included from architecture independend code.
Right solusion is
- move for_each_irq_desc() to <linux/irqnr.h>
- stat.c include <linux/irqnr.h>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Yinghai Lu <yinghai@kernel.org>
CC: Ingo Molnar <mingo@elte.hu>
---
fs/proc/stat.c | 11 +++++------
include/linux/irq.h | 14 ++------------
include/linux/irqnr.h | 26 ++++++++++++++------------
kernel/irq/handle.c | 9 +++++++--
4 files changed, 28 insertions(+), 32 deletions(-)
Index: b/fs/proc/stat.c
===================================================================
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -9,6 +9,7 @@
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/time.h>
+#include <linux/irqnr.h>
#include <asm/cputime.h>
#ifndef arch_irq_stat_cpu
@@ -27,6 +28,7 @@ static int show_stat(struct seq_file *p,
u64 sum = 0;
struct timespec boottime;
unsigned int per_irq_sum;
+ struct irq_desc *desc;
user = nice = system = idle = iowait =
irq = softirq = steal = cputime64_zero;
@@ -44,11 +46,10 @@ 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_each_irq_nr(j) {
-#ifdef CONFIG_SPARSE_IRQ
- if (!irq_to_desc(j))
+ for_each_irq_desc(j, desc) {
+ if (!desc)
continue;
-#endif
+
sum += kstat_irqs_cpu(j, i);
}
sum += arch_irq_stat_cpu(i);
@@ -95,12 +96,10 @@ static int show_stat(struct seq_file *p,
/* sum again ? it could be updated? */
for_each_irq_nr(j) {
per_irq_sum = 0;
-#ifdef CONFIG_SPARSE_IRQ
if (!irq_to_desc(j)) {
seq_printf(p, " %u", per_irq_sum);
continue;
}
-#endif
for_each_possible_cpu(i)
per_irq_sum += kstat_irqs_cpu(j, i);
Index: b/include/linux/irq.h
===================================================================
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -204,32 +204,22 @@ extern void arch_free_chip_data(struct i
#ifndef CONFIG_SPARSE_IRQ
extern struct irq_desc irq_desc[NR_IRQS];
-static inline struct irq_desc *irq_to_desc(unsigned int irq)
-{
- return (irq < NR_IRQS) ? irq_desc + irq : NULL;
-}
static inline struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
{
return irq_to_desc(irq);
}
-#else
+#else /* CONFIG_SPARSE_IRQ */
-extern struct irq_desc *irq_to_desc(unsigned int irq);
extern struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu);
extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int cpu);
-# define for_each_irq_desc(irq, desc) \
- for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; irq++, desc = irq_to_desc(irq))
-# define for_each_irq_desc_reverse(irq, desc) \
- for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; irq--, desc = irq_to_desc(irq))
-
#define kstat_irqs_this_cpu(DESC) \
((DESC)->kstat_irqs[smp_processor_id()])
#define kstat_incr_irqs_this_cpu(irqno, DESC) \
((DESC)->kstat_irqs[smp_processor_id()]++)
-#endif
+#endif /* CONFIG_SPARSE_IRQ */
static inline struct irq_desc *
irq_remap_to_desc(unsigned int irq, struct irq_desc *desc)
Index: b/include/linux/irqnr.h
===================================================================
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -11,24 +11,26 @@
# define nr_irqs NR_IRQS
# define for_each_irq_desc(irq, desc) \
- for (irq = 0; irq < nr_irqs; irq++)
+ for (irq = 0, desc = NULL; irq < nr_irqs; irq++)
# define for_each_irq_desc_reverse(irq, desc) \
- for (irq = nr_irqs - 1; irq >= 0; irq--)
-#else
+ for (irq = nr_irqs - 1, desc = NULL; irq >= 0; irq--)
+#else /* CONFIG_GENERIC_HARDIRQS */
extern int nr_irqs;
+struct irq_desc;
-#ifndef CONFIG_SPARSE_IRQ
+# define for_each_irq_desc(irq, desc) \
+ for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
+ irq++, desc = irq_to_desc(irq))
-struct irq_desc;
-# define for_each_irq_desc(irq, desc) \
- for (irq = 0, desc = irq_desc; irq < nr_irqs; irq++, desc++)
-# define for_each_irq_desc_reverse(irq, desc) \
- for (irq = nr_irqs - 1, desc = irq_desc + (nr_irqs - 1); \
- irq >= 0; irq--, desc--)
-#endif
-#endif
+# define for_each_irq_desc_reverse(irq, desc) \
+ for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \
+ irq--, desc = irq_to_desc(irq))
+
+extern struct irq_desc *irq_to_desc(unsigned int irq);
+
+#endif /* CONFIG_GENERIC_HARDIRQS */
#define for_each_irq_nr(irq) \
for (irq = 0; irq < nr_irqs; irq++)
Index: b/kernel/irq/handle.c
===================================================================
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -203,7 +203,7 @@ out_unlock:
return desc;
}
-#else
+#else /* !CONFIG_SPARSE_IRQ */
struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
[0 ... NR_IRQS-1] = {
@@ -218,7 +218,12 @@ struct irq_desc irq_desc[NR_IRQS] __cach
}
};
-#endif
+struct irq_desc *irq_to_desc(unsigned int irq)
+{
+ return (irq < nr_irqs) ? irq_desc + irq : NULL;
+}
+
+#endif /* !CONFIG_SPARSE_IRQ */
/*
* What should we do if we get a hw irq event on an illegal vector?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH for -tip] irq: for_each_irq_desc() makes simplify
2008-12-25 12:40 ` KOSAKI Motohiro
@ 2008-12-25 12:41 ` KOSAKI Motohiro
2008-12-25 13:10 ` Cyrill Gorcunov
2008-12-25 16:49 ` Ingo Molnar
2008-12-25 14:46 ` [PATCH for -tip] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c KOSAKI Motohiro
1 sibling, 2 replies; 14+ messages in thread
From: KOSAKI Motohiro @ 2008-12-25 12:41 UTC (permalink / raw)
To: Ingo Molnar, Yinghai Lu, LKML; +Cc: kosaki.motohiro
> > > > +#include <linux/irq.h>
> > >
> > > looks good, but linux/irq.h cannot be included on all architectures. (for
> > > example s390 has no notion of 'hardirqs'). But we created linux/irqnr.h
> > > for this purpose - so including that should work better.
> >
> > Oh, thanks good explain.
> > I'll fix soon.
>
> next spin is here.
> I confirmed three architecture.
>
> 1. alpha (without SPARSE_IRQ, build test by cross compiler only)
> 2. ia64 (without SPARSE_IRQ)
> 3. x86_64 (with SPARSE_IRQ)
Is this good idea?
this patch also tested on above three architecture.
===
Subject: [PATCH] irq: for_each_irq_desc() makes simplify
Impact: cleanup
all for_each_irq_desc() usage point have !desc check.
then its check can move into for_each_irq_desc() macro.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Yinghai Lu <yinghai@kernel.org>
CC: Ingo Molnar <mingo@elte.hu>
---
arch/x86/kernel/io_apic.c | 10 ----------
drivers/xen/events.c | 3 ---
fs/proc/stat.c | 3 ---
include/linux/irqnr.h | 6 ++++--
kernel/irq/autoprobe.c | 15 ---------------
kernel/irq/handle.c | 3 ---
kernel/irq/spurious.c | 5 -----
7 files changed, 4 insertions(+), 41 deletions(-)
Index: b/arch/x86/kernel/io_apic.c
===================================================================
--- a/arch/x86/kernel/io_apic.c
+++ b/arch/x86/kernel/io_apic.c
@@ -1400,8 +1400,6 @@ void __setup_vector_irq(int cpu)
/* Mark the inuse vectors */
for_each_irq_desc(irq, desc) {
- if (!desc)
- continue;
cfg = desc->chip_data;
if (!cpumask_test_cpu(cpu, cfg->domain))
continue;
@@ -1783,8 +1781,6 @@ __apicdebuginit(void) print_IO_APIC(void
for_each_irq_desc(irq, desc) {
struct irq_pin_list *entry;
- if (!desc)
- continue;
cfg = desc->chip_data;
entry = cfg->irq_2_pin;
if (!entry)
@@ -2425,9 +2421,6 @@ static void ir_irq_migration(struct work
struct irq_desc *desc;
for_each_irq_desc(irq, desc) {
- if (!desc)
- continue;
-
if (desc->status & IRQ_MOVE_PENDING) {
unsigned long flags;
@@ -2713,9 +2706,6 @@ static inline void init_IO_APIC_traps(vo
* 0x80, because int 0x80 is hm, kind of importantish. ;)
*/
for_each_irq_desc(irq, desc) {
- if (!desc)
- continue;
-
cfg = desc->chip_data;
if (IO_APIC_IRQ(irq) && cfg && !cfg->vector) {
/*
Index: b/drivers/xen/events.c
===================================================================
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -142,9 +142,6 @@ static void init_evtchn_cpu_bindings(voi
/* By default all event channels notify CPU#0. */
for_each_irq_desc(i, desc) {
- if (!desc)
- continue;
-
desc->affinity = cpumask_of_cpu(0);
}
#endif
Index: b/fs/proc/stat.c
===================================================================
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -47,9 +47,6 @@ static int show_stat(struct seq_file *p,
steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal);
guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest);
for_each_irq_desc(j, desc) {
- if (!desc)
- continue;
-
sum += kstat_irqs_cpu(j, i);
}
sum += arch_irq_stat_cpu(i);
Index: b/kernel/irq/autoprobe.c
===================================================================
--- a/kernel/irq/autoprobe.c
+++ b/kernel/irq/autoprobe.c
@@ -40,9 +40,6 @@ unsigned long probe_irq_on(void)
* flush such a longstanding irq before considering it as spurious.
*/
for_each_irq_desc_reverse(i, desc) {
- if (!desc)
- continue;
-
spin_lock_irq(&desc->lock);
if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
/*
@@ -71,9 +68,6 @@ unsigned long probe_irq_on(void)
* happened in the previous stage, it may have masked itself)
*/
for_each_irq_desc_reverse(i, desc) {
- if (!desc)
- continue;
-
spin_lock_irq(&desc->lock);
if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
@@ -92,9 +86,6 @@ unsigned long probe_irq_on(void)
* Now filter out any obviously spurious interrupts
*/
for_each_irq_desc(i, desc) {
- if (!desc)
- continue;
-
spin_lock_irq(&desc->lock);
status = desc->status;
@@ -133,9 +124,6 @@ unsigned int probe_irq_mask(unsigned lon
int i;
for_each_irq_desc(i, desc) {
- if (!desc)
- continue;
-
spin_lock_irq(&desc->lock);
status = desc->status;
@@ -178,9 +166,6 @@ int probe_irq_off(unsigned long val)
unsigned int status;
for_each_irq_desc(i, desc) {
- if (!desc)
- continue;
-
spin_lock_irq(&desc->lock);
status = desc->status;
Index: b/kernel/irq/handle.c
===================================================================
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -433,9 +433,6 @@ void early_init_irq_lock_class(void)
int i;
for_each_irq_desc(i, desc) {
- if (!desc)
- continue;
-
lockdep_set_class(&desc->lock, &irq_desc_lock_class);
}
}
Index: b/kernel/irq/spurious.c
===================================================================
--- a/kernel/irq/spurious.c
+++ b/kernel/irq/spurious.c
@@ -91,9 +91,6 @@ static int misrouted_irq(int irq)
int i, ok = 0;
for_each_irq_desc(i, desc) {
- if (!desc)
- continue;
-
if (!i)
continue;
@@ -115,8 +112,6 @@ static void poll_spurious_irqs(unsigned
for_each_irq_desc(i, desc) {
unsigned int status;
- if (!desc)
- continue;
if (!i)
continue;
Index: b/include/linux/irqnr.h
===================================================================
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -22,11 +22,13 @@ struct irq_desc;
# define for_each_irq_desc(irq, desc) \
for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs; \
- irq++, desc = irq_to_desc(irq))
+ irq++, desc = irq_to_desc(irq)) \
+ if (desc)
# define for_each_irq_desc_reverse(irq, desc) \
for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0; \
- irq--, desc = irq_to_desc(irq))
+ irq--, desc = irq_to_desc(irq)) \
+ if (desc)
extern struct irq_desc *irq_to_desc(unsigned int irq);
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify
2008-12-25 12:41 ` [PATCH for -tip] irq: for_each_irq_desc() makes simplify KOSAKI Motohiro
@ 2008-12-25 13:10 ` Cyrill Gorcunov
2008-12-25 13:45 ` KOSAKI Motohiro
2008-12-25 16:49 ` Ingo Molnar
1 sibling, 1 reply; 14+ messages in thread
From: Cyrill Gorcunov @ 2008-12-25 13:10 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: Ingo Molnar, Yinghai Lu, LKML
[KOSAKI Motohiro - Thu, Dec 25, 2008 at 09:41:54PM +0900]
...
| Is this good idea?
| this patch also tested on above three architecture.
|
|
| ===
| Subject: [PATCH] irq: for_each_irq_desc() makes simplify
| Impact: cleanup
|
| all for_each_irq_desc() usage point have !desc check.
| then its check can move into for_each_irq_desc() macro.
|
|
| Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
| CC: Yinghai Lu <yinghai@kernel.org>
| CC: Ingo Molnar <mingo@elte.hu>
| ---
| arch/x86/kernel/io_apic.c | 10 ----------
| drivers/xen/events.c | 3 ---
| fs/proc/stat.c | 3 ---
| include/linux/irqnr.h | 6 ++++--
| kernel/irq/autoprobe.c | 15 ---------------
| kernel/irq/handle.c | 3 ---
| kernel/irq/spurious.c | 5 -----
| 7 files changed, 4 insertions(+), 41 deletions(-)
...
Hi Kosaki,
the idea is that good indeed but I wonder if it possible
to explain that we skip empty 'desk' in for_each_... name
itself. Maybe for_each_irq_desc_defined :) Or something
more convenient word instead of "defined"?
- Cyrill -
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify
2008-12-25 13:10 ` Cyrill Gorcunov
@ 2008-12-25 13:45 ` KOSAKI Motohiro
2008-12-25 14:31 ` Cyrill Gorcunov
0 siblings, 1 reply; 14+ messages in thread
From: KOSAKI Motohiro @ 2008-12-25 13:45 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: Ingo Molnar, Yinghai Lu, LKML
> [KOSAKI Motohiro - Thu, Dec 25, 2008 at 09:41:54PM +0900]
> ...
> | Is this good idea?
> | this patch also tested on above three architecture.
> |
> |
> | ===
> | Subject: [PATCH] irq: for_each_irq_desc() makes simplify
> | Impact: cleanup
> |
> | all for_each_irq_desc() usage point have !desc check.
> | then its check can move into for_each_irq_desc() macro.
> |
> |
> | Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> | CC: Yinghai Lu <yinghai@kernel.org>
> | CC: Ingo Molnar <mingo@elte.hu>
> | ---
> | arch/x86/kernel/io_apic.c | 10 ----------
> | drivers/xen/events.c | 3 ---
> | fs/proc/stat.c | 3 ---
> | include/linux/irqnr.h | 6 ++++--
> | kernel/irq/autoprobe.c | 15 ---------------
> | kernel/irq/handle.c | 3 ---
> | kernel/irq/spurious.c | 5 -----
> | 7 files changed, 4 insertions(+), 41 deletions(-)
> ...
>
> Hi Kosaki,
>
> the idea is that good indeed but I wonder if it possible
> to explain that we skip empty 'desk' in for_each_... name
> itself. Maybe for_each_irq_desc_defined :) Or something
> more convenient word instead of "defined"?
"if (!desc) " mean this irqno don't have irq description.
so I think this name imply mean skipping no irq desctiption element.
Actually, on CONFIG_SPARSEIRQ, desc is filled in dynamically after booting.
then "defined" is a bit misleading word.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify
2008-12-25 13:45 ` KOSAKI Motohiro
@ 2008-12-25 14:31 ` Cyrill Gorcunov
2008-12-25 14:43 ` KOSAKI Motohiro
0 siblings, 1 reply; 14+ messages in thread
From: Cyrill Gorcunov @ 2008-12-25 14:31 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: Ingo Molnar, Yinghai Lu, LKML
[KOSAKI Motohiro - Thu, Dec 25, 2008 at 10:45:20PM +0900]
| > [KOSAKI Motohiro - Thu, Dec 25, 2008 at 09:41:54PM +0900]
| > ...
| > | Is this good idea?
| > | this patch also tested on above three architecture.
| > |
| > |
| > | ===
| > | Subject: [PATCH] irq: for_each_irq_desc() makes simplify
| > | Impact: cleanup
| > |
| > | all for_each_irq_desc() usage point have !desc check.
| > | then its check can move into for_each_irq_desc() macro.
| > |
| > |
| > | Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
| > | CC: Yinghai Lu <yinghai@kernel.org>
| > | CC: Ingo Molnar <mingo@elte.hu>
| > | ---
| > | arch/x86/kernel/io_apic.c | 10 ----------
| > | drivers/xen/events.c | 3 ---
| > | fs/proc/stat.c | 3 ---
| > | include/linux/irqnr.h | 6 ++++--
| > | kernel/irq/autoprobe.c | 15 ---------------
| > | kernel/irq/handle.c | 3 ---
| > | kernel/irq/spurious.c | 5 -----
| > | 7 files changed, 4 insertions(+), 41 deletions(-)
| > ...
| >
| > Hi Kosaki,
| >
| > the idea is that good indeed but I wonder if it possible
| > to explain that we skip empty 'desk' in for_each_... name
| > itself. Maybe for_each_irq_desc_defined :) Or something
| > more convenient word instead of "defined"?
|
| "if (!desc) " mean this irqno don't have irq description.
| so I think this name imply mean skipping no irq desctiption element.
|
| Actually, on CONFIG_SPARSEIRQ, desc is filled in dynamically after booting.
| then "defined" is a bit misleading word.
|
So if I would need to iterate over all descriptors including empty
I need to type all this long for(;;) form again? For me for_each_irq_desc
implies to iterate over each irq_desc allocated regardles of internal
descriptor data. For example in list_struct we have a special test if
entry is empty or not. So I think hiding details is not that good (and
that is why I was asking for more descriptive macro name). BUT if it
really supposed to behave like that then I don't object :)
- Cyrill -
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify
2008-12-25 14:31 ` Cyrill Gorcunov
@ 2008-12-25 14:43 ` KOSAKI Motohiro
2008-12-25 16:01 ` Cyrill Gorcunov
0 siblings, 1 reply; 14+ messages in thread
From: KOSAKI Motohiro @ 2008-12-25 14:43 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: Ingo Molnar, Yinghai Lu, LKML
> | "if (!desc) " mean this irqno don't have irq description.
> | so I think this name imply mean skipping no irq desctiption element.
> |
> | Actually, on CONFIG_SPARSEIRQ, desc is filled in dynamically after booting.
> | then "defined" is a bit misleading word.
> |
>
> So if I would need to iterate over all descriptors including empty
> I need to type all this long for(;;) form again?
We already have for_each_irq_nr() for this purpose ;-)
> For me for_each_irq_desc
> implies to iterate over each irq_desc allocated regardles of internal
> descriptor data. For example in list_struct we have a special test if
> entry is empty or not. So I think hiding details is not that good (and
> that is why I was asking for more descriptive macro name). BUT if it
> really supposed to behave like that then I don't object :)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH for -tip] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c
2008-12-25 12:40 ` KOSAKI Motohiro
2008-12-25 12:41 ` [PATCH for -tip] irq: for_each_irq_desc() makes simplify KOSAKI Motohiro
@ 2008-12-25 14:46 ` KOSAKI Motohiro
1 sibling, 0 replies; 14+ messages in thread
From: KOSAKI Motohiro @ 2008-12-25 14:46 UTC (permalink / raw)
To: Ingo Molnar, Yinghai Lu, LKML; +Cc: kosaki.motohiro
2008/12/25 KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>:
>> > > +#include <linux/irq.h>
>> >
>> > looks good, but linux/irq.h cannot be included on all architectures. (for
>> > example s390 has no notion of 'hardirqs'). But we created linux/irqnr.h
>> > for this purpose - so including that should work better.
>>
>> Oh, thanks good explain.
>> I'll fix soon.
>
> next spin is here.
> I confirmed three architecture.
>
> 1. alpha (without SPARSE_IRQ, build test by cross compiler only)
> 2. ia64 (without SPARSE_IRQ)
> 3. x86_64 (with SPARSE_IRQ)
sorry.
this patch still don't work on !CONFIG_GENERIC_HARDIRQS arch. maybe.
I'll fix again.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify
2008-12-25 14:43 ` KOSAKI Motohiro
@ 2008-12-25 16:01 ` Cyrill Gorcunov
2008-12-26 1:22 ` KOSAKI Motohiro
0 siblings, 1 reply; 14+ messages in thread
From: Cyrill Gorcunov @ 2008-12-25 16:01 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: Ingo Molnar, Yinghai Lu, LKML
[KOSAKI Motohiro - Thu, Dec 25, 2008 at 11:43:45PM +0900]
| > | "if (!desc) " mean this irqno don't have irq description.
| > | so I think this name imply mean skipping no irq desctiption element.
| > |
| > | Actually, on CONFIG_SPARSEIRQ, desc is filled in dynamically after booting.
| > | then "defined" is a bit misleading word.
| > |
| >
| > So if I would need to iterate over all descriptors including empty
| > I need to type all this long for(;;) form again?
|
| We already have for_each_irq_nr() for this purpose ;-)
Which is not shorter form of desc iterator in turn :-)
Since the original for_each_irq_desc didn't check for NULL
desc's I think the better would to name it like for_each_irq_desc_safe
or for_each_irq_desc_inuse then.
Nevermind, Kosaki, since it's only me who is confused I should
just shut up :-)
|
| > For me for_each_irq_desc
| > implies to iterate over each irq_desc allocated regardles of internal
| > descriptor data. For example in list_struct we have a special test if
| > entry is empty or not. So I think hiding details is not that good (and
| > that is why I was asking for more descriptive macro name). BUT if it
| > really supposed to behave like that then I don't object :)
|
- Cyrill -
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify
2008-12-25 12:41 ` [PATCH for -tip] irq: for_each_irq_desc() makes simplify KOSAKI Motohiro
2008-12-25 13:10 ` Cyrill Gorcunov
@ 2008-12-25 16:49 ` Ingo Molnar
1 sibling, 0 replies; 14+ messages in thread
From: Ingo Molnar @ 2008-12-25 16:49 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: Yinghai Lu, LKML
* KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> > > > > +#include <linux/irq.h>
> > > >
> > > > looks good, but linux/irq.h cannot be included on all architectures. (for
> > > > example s390 has no notion of 'hardirqs'). But we created linux/irqnr.h
> > > > for this purpose - so including that should work better.
> > >
> > > Oh, thanks good explain.
> > > I'll fix soon.
> >
> > next spin is here.
> > I confirmed three architecture.
> >
> > 1. alpha (without SPARSE_IRQ, build test by cross compiler only)
> > 2. ia64 (without SPARSE_IRQ)
> > 3. x86_64 (with SPARSE_IRQ)
>
>
> Is this good idea?
> this patch also tested on above three architecture.
yes, this is a nice cleanup too!
Ingo
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify
2008-12-25 16:01 ` Cyrill Gorcunov
@ 2008-12-26 1:22 ` KOSAKI Motohiro
2008-12-26 9:37 ` Cyrill Gorcunov
0 siblings, 1 reply; 14+ messages in thread
From: KOSAKI Motohiro @ 2008-12-26 1:22 UTC (permalink / raw)
To: Cyrill Gorcunov; +Cc: kosaki.motohiro, Ingo Molnar, Yinghai Lu, LKML
> [KOSAKI Motohiro - Thu, Dec 25, 2008 at 11:43:45PM +0900]
> | > | "if (!desc) " mean this irqno don't have irq description.
> | > | so I think this name imply mean skipping no irq desctiption element.
> | > |
> | > | Actually, on CONFIG_SPARSEIRQ, desc is filled in dynamically after booting.
> | > | then "defined" is a bit misleading word.
> | > |
> | >
> | > So if I would need to iterate over all descriptors including empty
> | > I need to type all this long for(;;) form again?
> |
> | We already have for_each_irq_nr() for this purpose ;-)
>
> Which is not shorter form of desc iterator in turn :-)
>
> Since the original for_each_irq_desc didn't check for NULL
> desc's I think the better would to name it like for_each_irq_desc_safe
> or for_each_irq_desc_inuse then.
but before CONFIG_SPARSEIRQ feature age, for_each_irq_desc() guaranteed
to return !NULL value.
recently CONFIG_SPARSEIRQ break this assumption. I hope to restore it.
In addition, if we make both for_each_irq_desc() and for_each_irq_desc().
for_each_irq_desc() become unused macro.
from cleanup view, unused function/macro is not preferred.
>
> Nevermind, Kosaki, since it's only me who is confused I should
> just shut up :-)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify
2008-12-26 1:22 ` KOSAKI Motohiro
@ 2008-12-26 9:37 ` Cyrill Gorcunov
0 siblings, 0 replies; 14+ messages in thread
From: Cyrill Gorcunov @ 2008-12-26 9:37 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: Ingo Molnar, Yinghai Lu, LKML
On Fri, Dec 26, 2008 at 4:22 AM, KOSAKI Motohiro
<kosaki.motohiro@jp.fujitsu.com> wrote:
>> [KOSAKI Motohiro - Thu, Dec 25, 2008 at 11:43:45PM +0900]
>> | > | "if (!desc) " mean this irqno don't have irq description.
>> | > | so I think this name imply mean skipping no irq desctiption element.
>> | > |
>> | > | Actually, on CONFIG_SPARSEIRQ, desc is filled in dynamically after booting.
>> | > | then "defined" is a bit misleading word.
>> | > |
>> | >
>> | > So if I would need to iterate over all descriptors including empty
>> | > I need to type all this long for(;;) form again?
>> |
>> | We already have for_each_irq_nr() for this purpose ;-)
>>
>> Which is not shorter form of desc iterator in turn :-)
>>
>> Since the original for_each_irq_desc didn't check for NULL
>> desc's I think the better would to name it like for_each_irq_desc_safe
>> or for_each_irq_desc_inuse then.
>
> but before CONFIG_SPARSEIRQ feature age, for_each_irq_desc() guaranteed
> to return !NULL value.
> recently CONFIG_SPARSEIRQ break this assumption. I hope to restore it.
indeed
>
> In addition, if we make both for_each_irq_desc() and for_each_irq_desc().
> for_each_irq_desc() become unused macro.
> from cleanup view, unused function/macro is not preferred.
>
yeah!
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2008-12-26 9:38 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-25 10:46 [PATCH for -tip] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c KOSAKI Motohiro
2008-12-25 10:59 ` Ingo Molnar
2008-12-25 11:00 ` KOSAKI Motohiro
2008-12-25 12:40 ` KOSAKI Motohiro
2008-12-25 12:41 ` [PATCH for -tip] irq: for_each_irq_desc() makes simplify KOSAKI Motohiro
2008-12-25 13:10 ` Cyrill Gorcunov
2008-12-25 13:45 ` KOSAKI Motohiro
2008-12-25 14:31 ` Cyrill Gorcunov
2008-12-25 14:43 ` KOSAKI Motohiro
2008-12-25 16:01 ` Cyrill Gorcunov
2008-12-26 1:22 ` KOSAKI Motohiro
2008-12-26 9:37 ` Cyrill Gorcunov
2008-12-25 16:49 ` Ingo Molnar
2008-12-25 14:46 ` [PATCH for -tip] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c KOSAKI Motohiro
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.