Skip to contentSkip to conversation

proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c

PATCH In review KOSAKI Motohiro 3 participants 14 messages Dec 25, 2008 – Dec 26, 2008

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c

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.

---
 fs/proc/stat.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
fs/proc/stat.c +5 -6
Index: 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);
 
#1 lore raw
Quoted 7 lines · KOSAKI Motohiro

I confirmed by alpha cross compiler.

==
Subject: [PATCH] proc: remove ifdef CONFIG_SPARSE_IRQ from stat.c
Impact: cleanup

Quoted 7 lines

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

#2 lore raw
Quoted 14 lines · KOSAKI Motohiro
Quoted 12 lines

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>.

Quoted 7 lines
Quoted 3 lines

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.

#3 lore raw
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

+#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>

---
 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(-)
fs/proc/stat.c +5 -6
Index: 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);
 
include/linux/irq.h +2 -12
Index: 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)
include/linux/irqnr.h +14 -12
Index: 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++)
kernel/irq/handle.c +7 -2
Index: 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?
#4 lore raw

PATCH 1/1 irq: for_each_irq_desc() makes simplify

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

+#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.

Quoted 6 lines

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.

---
 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(-)
arch/x86/kernel/io_apic.c +0 -10
Index: 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) {
 			/*
drivers/xen/events.c +0 -3
Index: 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
fs/proc/stat.c +0 -3
Index: 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);
kernel/irq/autoprobe.c +0 -15
Index: 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;
 
kernel/irq/handle.c +0 -3
Index: 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);
 	}
 }
kernel/irq/spurious.c +0 -5
Index: 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;
 
include/linux/irqnr.h +4 -2
Index: 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);
 
#5 lore raw

Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify

[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 <[email protected]>
| CC: Yinghai Lu <[email protected]>
| CC: Ingo Molnar <[email protected]>
| ---
|  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 -

#6 lore raw

Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify

Quoted 26 lines

[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 <[email protected]>
| CC: Yinghai Lu <[email protected]>
| CC: Ingo Molnar <[email protected]>
| ---
|  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(-)
Quoted 8 lines

...

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.

#7 lore raw

Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify

[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 <[email protected]>
| > | CC: Yinghai Lu <[email protected]>
| > | CC: Ingo Molnar <[email protected]>
| > | ---
| > |  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 -

#8 lore raw

Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify

Quoted 9 lines
| "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 ;-)

Quoted 6 lines

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 :)

#9 lore raw

Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify

[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 -

#10 lore raw

Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify

Quoted 13 lines

[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 ;-)
Quoted 5 lines

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.

Quoted 3 lines

Nevermind, Kosaki, since it's only me who is confused I should just shut up :-)

#11 lore raw

Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify

Quoted 15 lines · KOSAKI Motohiro
Quoted 15 lines

[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 :-)

Quoted 7 lines
Quoted 3 lines

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

Quoted 5 lines

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!

#12 lore raw

Re: [PATCH for -tip] irq: for_each_irq_desc() makes simplify

In reply to KOSAKI Motohiro
Quoted 12 lines · KOSAKI Motohiro
Quoted 12 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

+#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.

Quoted 7 lines
Quoted 3 lines

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

#13 lore raw
In reply to KOSAKI Motohiro

2008/12/25 KOSAKI Motohiro <[email protected]>:

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

+#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.

Quoted 6 lines

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.