Skip to contentSkip to conversation

sparseirq: make some func to be used with genirq

PATCH Applied Yinghai Lu 4 participants 12 messages Jan 7, 2009 – Jan 11, 2009

Subsystems (3)
lore
Share & tools
lore

Yinghai Lu

author
#0 lore raw

PATCH 1/1 sparseirq: make some func to be used with genirq

Impact: clean up

Ingo suggested to change some ifdef from SPARSE_IRQ to GENERIC_HARDIRQS so we could some #ifdef later if all arch support genirq

---
 drivers/char/random.c        |    2 +-
 drivers/pci/intr_remapping.c |    2 +-
 include/linux/irq.h          |    6 ++----
 include/linux/kernel_stat.h  |    6 +++---
 kernel/irq/handle.c          |    7 ++++---
 5 files changed, 11 insertions(+), 12 deletions(-)
drivers/char/random.c +1 -1
Index: linux-2.6/drivers/char/random.c
===================================================================
@@ -558,7 +558,7 @@ struct timer_rand_state {
 	unsigned dont_count_entropy:1;
 };
 
-#ifndef CONFIG_SPARSE_IRQ
+#ifndef CONFIG_GENERIC_HARDIRQS
 
 static struct timer_rand_state *irq_timer_state[NR_IRQS];
 
drivers/pci/intr_remapping.c +1 -1
Index: linux-2.6/drivers/pci/intr_remapping.c
===================================================================
@@ -20,7 +20,7 @@ struct irq_2_iommu {
 	u8  irte_mask;
 };
 
-#ifdef CONFIG_SPARSE_IRQ
+#ifdef CONFIG_GENERIC_HARDIRQS
 static struct irq_2_iommu *get_one_free_irq_2_iommu(int cpu)
 {
 	struct irq_2_iommu *iommu;
include/linux/irq.h +2 -4
Index: linux-2.6/include/linux/irq.h
===================================================================
@@ -160,12 +160,10 @@ struct irq_2_iommu;
  */
 struct irq_desc {
 	unsigned int		irq;
-#ifdef CONFIG_SPARSE_IRQ
 	struct timer_rand_state *timer_rand_state;
 	unsigned int            *kstat_irqs;
-# ifdef CONFIG_INTR_REMAP
+#ifdef CONFIG_INTR_REMAP
 	struct irq_2_iommu      *irq_2_iommu;
-# endif
 #endif
 	irq_flow_handler_t	handle_irq;
 	struct irq_chip		*chip;
@@ -202,13 +200,13 @@ extern void arch_free_chip_data(struct i
 extern struct irq_desc irq_desc[NR_IRQS];
 #else /* CONFIG_SPARSE_IRQ */
 extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int cpu);
+#endif /* CONFIG_SPARSE_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 /* CONFIG_SPARSE_IRQ */
 
 extern struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu);
 
include/linux/kernel_stat.h +3 -3
Index: linux-2.6/include/linux/kernel_stat.h
===================================================================
@@ -28,7 +28,7 @@ struct cpu_usage_stat {
 
 struct kernel_stat {
 	struct cpu_usage_stat	cpustat;
-#ifndef CONFIG_SPARSE_IRQ
+#ifndef CONFIG_GENERIC_HARDIRQS
        unsigned int irqs[NR_IRQS];
 #endif
 };
@@ -41,7 +41,7 @@ DECLARE_PER_CPU(struct kernel_stat, ksta
 
 extern unsigned long long nr_context_switches(void);
 
-#ifndef CONFIG_SPARSE_IRQ
+#ifndef CONFIG_GENERIC_HARDIRQS
 #define kstat_irqs_this_cpu(irq) \
 	(kstat_this_cpu.irqs[irq])
 
@@ -55,7 +55,7 @@ static inline void kstat_incr_irqs_this_
 #endif
 
 
-#ifndef CONFIG_SPARSE_IRQ
+#ifndef CONFIG_GENERIC_HARDIRQS
 static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
 {
        return kstat_cpu(cpu).irqs[irq];
kernel/irq/handle.c +4 -3
Index: linux-2.6/kernel/irq/handle.c
===================================================================
@@ -213,6 +213,7 @@ struct irq_desc irq_desc[NR_IRQS] __cach
 	}
 };
 
+static unsigned int kstat_irqs_all[NR_IRQS][NR_CPUS];
 int __init early_irq_init(void)
 {
 	struct irq_desc *desc;
@@ -222,8 +223,10 @@ int __init early_irq_init(void)
 	desc = irq_desc;
 	count = ARRAY_SIZE(irq_desc);
 
-	for (i = 0; i < count; i++)
+	for (i = 0; i < count; i++) {
 		desc[i].irq = i;
+		desc[i].kstat_irqs = kstat_irqs_all[i];
+	}
 
 	return arch_early_irq_init();
 }
@@ -451,12 +454,10 @@ void early_init_irq_lock_class(void)
 	}
 }
 
-#ifdef CONFIG_SPARSE_IRQ
 unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
 {
 	struct irq_desc *desc = irq_to_desc(irq);
 	return desc ? desc->kstat_irqs[cpu] : 0;
 }
-#endif
 EXPORT_SYMBOL(kstat_irqs_cpu);
 
#1 lore raw

(Matt Cc:-ed)

Matt, does this look good to you? The point of this cleanup would be to make desc->timer_rand_state depend on hardirq (the presence of irq_desc[])
- not sparseirq (which does not make much sense).

Ingo

Quoted 143 lines · Yinghai Lu

Impact: clean up

Ingo suggested to change some ifdef from SPARSE_IRQ to GENERIC_HARDIRQS so we could some #ifdef later if all arch support genirq

---
 drivers/char/random.c        |    2 +-
 drivers/pci/intr_remapping.c |    2 +-
 include/linux/irq.h          |    6 ++----
 include/linux/kernel_stat.h  |    6 +++---
 kernel/irq/handle.c          |    7 ++++---
 5 files changed, 11 insertions(+), 12 deletions(-)

Index: linux-2.6/drivers/char/random.c
===================================================================

drivers/char/random.c +1 -1
@@ -558,7 +558,7 @@ struct timer_rand_state {
 	unsigned dont_count_entropy:1;
 };
 
-#ifndef CONFIG_SPARSE_IRQ
+#ifndef CONFIG_GENERIC_HARDIRQS
 
 static struct timer_rand_state *irq_timer_state[NR_IRQS];
 

Index: linux-2.6/drivers/pci/intr_remapping.c
===================================================================

drivers/pci/intr_remapping.c +1 -1
@@ -20,7 +20,7 @@ struct irq_2_iommu {
 	u8  irte_mask;
 };
 
-#ifdef CONFIG_SPARSE_IRQ
+#ifdef CONFIG_GENERIC_HARDIRQS
 static struct irq_2_iommu *get_one_free_irq_2_iommu(int cpu)
 {
 	struct irq_2_iommu *iommu;

Index: linux-2.6/include/linux/irq.h
===================================================================

include/linux/irq.h +2 -4
@@ -160,12 +160,10 @@ struct irq_2_iommu;
  */
 struct irq_desc {
 	unsigned int		irq;
-#ifdef CONFIG_SPARSE_IRQ
 	struct timer_rand_state *timer_rand_state;
 	unsigned int            *kstat_irqs;
-# ifdef CONFIG_INTR_REMAP
+#ifdef CONFIG_INTR_REMAP
 	struct irq_2_iommu      *irq_2_iommu;
-# endif
 #endif
 	irq_flow_handler_t	handle_irq;
 	struct irq_chip		*chip;
@@ -202,13 +200,13 @@ extern void arch_free_chip_data(struct i
 extern struct irq_desc irq_desc[NR_IRQS];
 #else /* CONFIG_SPARSE_IRQ */
 extern struct irq_desc *move_irq_desc(struct irq_desc *old_desc, int cpu);
+#endif /* CONFIG_SPARSE_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 /* CONFIG_SPARSE_IRQ */
 
 extern struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu);
 

Index: linux-2.6/include/linux/kernel_stat.h
===================================================================

include/linux/kernel_stat.h +3 -3
@@ -28,7 +28,7 @@ struct cpu_usage_stat {
 
 struct kernel_stat {
 	struct cpu_usage_stat	cpustat;
-#ifndef CONFIG_SPARSE_IRQ
+#ifndef CONFIG_GENERIC_HARDIRQS
        unsigned int irqs[NR_IRQS];
 #endif
 };
@@ -41,7 +41,7 @@ DECLARE_PER_CPU(struct kernel_stat, ksta
 
 extern unsigned long long nr_context_switches(void);
 
-#ifndef CONFIG_SPARSE_IRQ
+#ifndef CONFIG_GENERIC_HARDIRQS
 #define kstat_irqs_this_cpu(irq) \
 	(kstat_this_cpu.irqs[irq])
 
@@ -55,7 +55,7 @@ static inline void kstat_incr_irqs_this_
 #endif
 
 
-#ifndef CONFIG_SPARSE_IRQ
+#ifndef CONFIG_GENERIC_HARDIRQS
 static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
 {
        return kstat_cpu(cpu).irqs[irq];

Index: linux-2.6/kernel/irq/handle.c
===================================================================

kernel/irq/handle.c +4 -3
@@ -213,6 +213,7 @@ struct irq_desc irq_desc[NR_IRQS] __cach
 	}
 };
 
+static unsigned int kstat_irqs_all[NR_IRQS][NR_CPUS];
 int __init early_irq_init(void)
 {
 	struct irq_desc *desc;
@@ -222,8 +223,10 @@ int __init early_irq_init(void)
 	desc = irq_desc;
 	count = ARRAY_SIZE(irq_desc);
 
-	for (i = 0; i < count; i++)
+	for (i = 0; i < count; i++) {
 		desc[i].irq = i;
+		desc[i].kstat_irqs = kstat_irqs_all[i];
+	}
 
 	return arch_early_irq_init();
 }
@@ -451,12 +454,10 @@ void early_init_irq_lock_class(void)
 	}
 }
 
-#ifdef CONFIG_SPARSE_IRQ
 unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
 {
 	struct irq_desc *desc = irq_to_desc(irq);
 	return desc ? desc->kstat_irqs[cpu] : 0;
 }
-#endif
 EXPORT_SYMBOL(kstat_irqs_cpu);
 
#2 lore raw
Quoted 5 lines · Ingo Molnar

(Matt Cc:-ed)

Matt, does this look good to you? The point of this cleanup would be to make desc->timer_rand_state depend on hardirq (the presence of irq_desc[])
- not sparseirq (which does not make much sense).

Seems fine.

Signature · 1 line
Mathematics is the supreme nostalgia of our time.
Applied
#3 lore raw
Quoted 10 lines · Matt Mackall
Quoted 5 lines · Ingo Molnar

(Matt Cc:-ed)

Matt, does this look good to you? The point of this cleanup would be to make desc->timer_rand_state depend on hardirq (the presence of irq_desc[])
- not sparseirq (which does not make much sense).

Seems fine.

applied it to tip/irq/urgent, thanks guys!

Ingo

#4 lore raw
Quoted 12 lines · Ingo Molnar
Quoted 9 lines · Matt Mackall
Quoted 5 lines · Ingo Molnar

(Matt Cc:-ed)

Matt, does this look good to you? The point of this cleanup would be to make desc->timer_rand_state depend on hardirq (the presence of irq_desc[])
- not sparseirq (which does not make much sense).

Seems fine.

Quoted 8 lines

applied it to tip/irq/urgent, thanks guys!

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

This will conflict with the change of kstat_irqs from unsigned int to unsigned long.

If you do your magic on tip/cpus4096, I will git-remote update my tree and make the conflict go away...

Thanks,
Mike

#5 lore raw
Quoted 22 lines · Mike Travis
Quoted 12 lines · Ingo Molnar
Quoted 9 lines · Matt Mackall
Quoted 5 lines · Ingo Molnar

(Matt Cc:-ed)

Matt, does this look good to you? The point of this cleanup would be to make desc->timer_rand_state depend on hardirq (the presence of irq_desc[])
- not sparseirq (which does not make much sense).

Seems fine.

Quoted 8 lines

applied it to tip/irq/urgent, thanks guys!

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Quoted 5 lines

This will conflict with the change of kstat_irqs from unsigned int to unsigned long.

If you do your magic on tip/cpus4096, I will git-remote update my tree and make the conflict go away...

you can defer the change to unsigned long to a later stage, when these have hit upstream. (in a few days)

Ingo

#6 lore raw
Quoted 25 lines · Ingo Molnar
Quoted 23 lines · Mike Travis
Quoted 11 lines · Ingo Molnar
Quoted 9 lines · Matt Mackall
Quoted 5 lines · Ingo Molnar

(Matt Cc:-ed)

Matt, does this look good to you? The point of this cleanup would be to make desc->timer_rand_state depend on hardirq (the presence of irq_desc[])
- not sparseirq (which does not make much sense).

Seems fine.

Quoted 8 lines

applied it to tip/irq/urgent, thanks guys!

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

This will conflict with the change of kstat_irqs from unsigned int to unsigned long.

Quoted 7 lines
Quoted 2 lines

If you do your magic on tip/cpus4096, I will git-remote update my tree and make the conflict go away...

you can defer the change to unsigned long to a later stage, when these have hit upstream. (in a few days)

Ingo

Good idea since the change to long tripped a panic in the CPUMASK_OFFSTACK=n case (which doesn't make a lot of sense at this moment.)

Will push the remainder soon.

Thanks,
Mike

#7 lore raw
In reply to Ingo Molnar

Yinghai, the crossbuild to Alpha fails with:

/home/mingo/tip/kernel/fork.c: In function 'copy_signal':
/home/mingo/tip/kernel/fork.c:825: warning: unused variable 'ret' /home/mingo/tip/drivers/char/random.c: In function 'get_timer_rand_state':
/home/mingo/tip/drivers/char/random.c:584: error: dereferencing pointer to incomplete type /home/mingo/tip/drivers/char/random.c: In function 'set_timer_rand_state':
/home/mingo/tip/drivers/char/random.c:594: error: dereferencing pointer to incomplete type make[3]: *** [drivers/char/random.o] Error 1

Ingo

author
#8 lore raw
Quoted 10 lines · Ingo Molnar

Yinghai, the crossbuild to Alpha fails with:

/home/mingo/tip/kernel/fork.c: In function 'copy_signal':
/home/mingo/tip/kernel/fork.c:825: warning: unused variable 'ret' /home/mingo/tip/drivers/char/random.c: In function 'get_timer_rand_state':
/home/mingo/tip/drivers/char/random.c:584: error: dereferencing pointer to incomplete type /home/mingo/tip/drivers/char/random.c: In function 'set_timer_rand_state':
/home/mingo/tip/drivers/char/random.c:594: error: dereferencing pointer to incomplete type make[3]: *** [drivers/char/random.o] Error 1

please check

[PATCH] sparseirq: fix compiling with unknown irq_desc struct

Impact: fix compiling

irq_desc is defined in linux/irq.h

include/linux/random.h +4 -0
index 407ea36..a27bf17 100644
@@ -10,6 +10,10 @@
 #include <linux/ioctl.h>
 #include <linux/irqnr.h>
 
+#ifdef CONFIG_GENERIC_HARDIRQS
+#include <linux/irq.h>
+#endif
+
 /* ioctl()'s for the random number generator */
 
 /* Get the entropy count. */
Applied
#9 lore raw
Quoted 27 lines · Yinghai Lu
Quoted 10 lines · Ingo Molnar

Yinghai, the crossbuild to Alpha fails with:

/home/mingo/tip/kernel/fork.c: In function 'copy_signal':
/home/mingo/tip/kernel/fork.c:825: warning: unused variable 'ret' /home/mingo/tip/drivers/char/random.c: In function 'get_timer_rand_state':
/home/mingo/tip/drivers/char/random.c:584: error: dereferencing pointer to incomplete type /home/mingo/tip/drivers/char/random.c: In function 'set_timer_rand_state':
/home/mingo/tip/drivers/char/random.c:594: error: dereferencing pointer to incomplete type make[3]: *** [drivers/char/random.o] Error 1

please check

[PATCH] sparseirq: fix compiling with unknown irq_desc struct

Impact: fix compiling

irq_desc is defined in linux/irq.h

include/linux/random.h +0 -0
index 407ea36..a27bf17 100644

include/linux/random.h line 15

Quoted 6 lines
include/linux/random.h +3 -0
@@ -10,6 +10,10 @@
 #include <linux/ioctl.h>
 #include <linux/irqnr.h>
 
+#ifdef CONFIG_GENERIC_HARDIRQS
+#include <linux/irq.h>
+#endif

applied to tip/irq/sparseirq, thanks Yinghai!

Ingo

#10 lore raw
Quoted 9 lines

include/linux/random.h line 15

Quoted 9 lines

+++ b/include/linux/random.h

include/linux/random.h +3 -0
@@ -10,6 +10,10 @@
 #include <linux/ioctl.h>
 #include <linux/irqnr.h>
 
+#ifdef CONFIG_GENERIC_HARDIRQS
+#include <linux/irq.h>
+#endif

fails CONFIG_HEADERS_CHECK=y:

/home/mingo/linux/linux/usr/include/linux/random.h:14:
included file 'linux/irq.h' is not exported

Ingo

#11 lore raw
Quoted 6 lines · Ingo Molnar
Quoted 6 lines
Quoted 6 lines

+++ b/include/linux/random.h

(quoted diff) +0 -0
@@ -10,6 +10,10 @@
 #include <linux/ioctl.h>
 #include <linux/irqnr.h>
 
Quoted 8 lines
Quoted 3 lines

Review line 15

Quoted 3 lines
(quoted diff) +3 -0
+#ifdef CONFIG_GENERIC_HARDIRQS
+#include <linux/irq.h>
+#endif

fails CONFIG_HEADERS_CHECK=y:

/home/mingo/linux/linux/usr/include/linux/random.h:14:
included file 'linux/irq.h' is not exported

replaced it with the patch below instead. Hopefully that's enough.

Ingo

--------------------->

Quoted 1 line

From d178a1eb5c034df1f74a2b67bf311afa5d6b8e95 Mon Sep 17 00:00:00 2001

From: Yinghai Lu <[email protected]>
Date: Sun, 11 Jan 2009 00:35:42 -0800
Subject: [PATCH] sparseirq: fix build with unknown irq_desc struct

Quoted 8 lines · Ingo Molnar

tip/kernel/fork.c: In function 'copy_signal':
tip/kernel/fork.c:825: warning: unused variable 'ret' tip/drivers/char/random.c: In function 'get_timer_rand_state':
tip/drivers/char/random.c:584: error: dereferencing pointer to incomplete type tip/drivers/char/random.c: In function 'set_timer_rand_state':
tip/drivers/char/random.c:594: error: dereferencing pointer to incomplete type make[3]: *** [drivers/char/random.o] Error 1

irq_desc is defined in linux/irq.h, so include it in the genirq case.

---
 drivers/char/random.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/char/random.c +4 -0
index a778918..7c43ae7 100644
@@ -241,6 +241,10 @@
 #include <linux/percpu.h>
 #include <linux/cryptohash.h>
 
+#ifdef CONFIG_GENERIC_HARDIRQS
+# include <linux/irq.h>
+#endif
+
 #include <asm/processor.h>
 #include <asm/uaccess.h>
 #include <asm/irq.h>