Skip to contentSkip to conversation

irq: enclose irq_desc_lock_class in CONFIG_LOCKDEP

PATCH Applied KOSAKI Motohiro 3 participants 11 messages Dec 16, 2008 – Dec 18, 2008

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

PATCH 1/1 irq: enclose irq_desc_lock_class in CONFIG_LOCKDEP

Applied after: linux-next.patch

==
Subject: [mmotm][PATCH] irq: enclose irq_desc_lock_class in CONFIG_LOCKDEP

commit 08678b0841267c1d00d771fe01548d86043d065e introduced irq_desc_lock_class variable.
But it is used only if CONFIG_LOCKDEP=Y. otherwise, following warnings happend.

CC kernel/irq/handle.o
kernel/irq/handle.c:26: warning: 'irq_desc_lock_class' defined but not used

---
 kernel/irq/handle.c |    2 ++
 1 file changed, 2 insertions(+)
kernel/irq/handle.c +2 -0
Index: b/kernel/irq/handle.c
===================================================================
@@ -20,10 +20,12 @@
 
 #include "internals.h"
 
+#ifdef CONFIG_LOCKDEP
 /*
  * lockdep: we want to handle all irq_desc locks as a single lock-class:
  */
 static struct lock_class_key irq_desc_lock_class;
+#endif
 
 /**
  * handle_bad_irq - handle spurious and unhandled irqs
#1 lore raw
Quoted 31 lines · On Tue, 16 Dec 2008 17:08:43 +0900 (JST) KOSAKI Motohiro…

Applied after: linux-next.patch

==
Subject: [mmotm][PATCH] irq: enclose irq_desc_lock_class in CONFIG_LOCKDEP

commit 08678b0841267c1d00d771fe01548d86043d065e introduced irq_desc_lock_class variable.
But it is used only if CONFIG_LOCKDEP=Y. otherwise, following warnings happend.

CC kernel/irq/handle.o
kernel/irq/handle.c:26: warning: 'irq_desc_lock_class' defined but not used

---
 kernel/irq/handle.c |    2 ++
 1 file changed, 2 insertions(+)

Index: b/kernel/irq/handle.c
===================================================================

kernel/irq/handle.c +0 -0
@@ -20,10 +20,12 @@
 
 #include "internals.h"

kernel/irq/handle.c line 31

Quoted 10 lines
kernel/irq/handle.c +2 -0
 
+#ifdef CONFIG_LOCKDEP
 /*
  * lockdep: we want to handle all irq_desc locks as a single lock-class:
  */
 static struct lock_class_key irq_desc_lock_class;
+#endif
 
 /**
  * handle_bad_irq - handle spurious and unhandled irqs

No, lockdep.h (which we forgot to include) already handles that:

# define lockdep_set_class(lock, key)		do { (void)(key); } while (0)

the problem is that the code which references irq_desc_lock_class is inside #ifdef CONFIG_SPARSE_IRQ, so this is a better fix:

kernel/irq/handle.c renamed from kernel/irq/handle.c~irq-enclose-irq_desc_lock_class-in-config_lockdep +7 -5
@@ -13,6 +13,7 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/random.h>
+#include <linux/lockdep.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
 #include <linux/rculist.h>
@@ -20,11 +21,6 @@
 
 #include "internals.h"
 
-/*
- * lockdep: we want to handle all irq_desc locks as a single lock-class:
- */
-static struct lock_class_key irq_desc_lock_class;
-
 /**
  * handle_bad_irq - handle spurious and unhandled irqs
  * @irq:       the interrupt number
@@ -61,6 +57,12 @@ void __init __attribute__((weak)) arch_e
 }
 
 #ifdef CONFIG_SPARSE_IRQ
+
+/*
+ * lockdep: we want to handle all irq_desc locks as a single lock-class:
+ */
+static struct lock_class_key irq_desc_lock_class;
+
 static struct irq_desc irq_desc_init = {
 	.irq	    = -1,
 	.status	    = IRQ_DISABLED,

_

#2 lore raw
Quoted 46 lines · Andrew Morton
Quoted 31 lines · On Tue, 16 Dec 2008 17:08:43 +0900 (JST) KOSAKI Motohiro…

Applied after: linux-next.patch

==
Subject: [mmotm][PATCH] irq: enclose irq_desc_lock_class in CONFIG_LOCKDEP

commit 08678b0841267c1d00d771fe01548d86043d065e introduced irq_desc_lock_class variable.
But it is used only if CONFIG_LOCKDEP=Y. otherwise, following warnings happend.

CC kernel/irq/handle.o
kernel/irq/handle.c:26: warning: 'irq_desc_lock_class' defined but not used

---
 kernel/irq/handle.c |    2 ++
 1 file changed, 2 insertions(+)

Index: b/kernel/irq/handle.c
===================================================================

kernel/irq/handle.c +0 -0
@@ -20,10 +20,12 @@
 
 #include "internals.h"

kernel/irq/handle.c line 31

Quoted 10 lines
kernel/irq/handle.c +2 -0
 
+#ifdef CONFIG_LOCKDEP
 /*
  * lockdep: we want to handle all irq_desc locks as a single lock-class:
  */
 static struct lock_class_key irq_desc_lock_class;
+#endif
 
 /**
  * handle_bad_irq - handle spurious and unhandled irqs

No, lockdep.h (which we forgot to include) already handles that:

Quoted 4 lines
# define lockdep_set_class(lock, key)		do { (void)(key); } while (0)

the problem is that the code which references irq_desc_lock_class is inside #ifdef CONFIG_SPARSE_IRQ, so this is a better fix:

agreed that this is the better fix - applied to tip/irq/sparseirq, thanks!

Ingo

#3 lore raw
Quoted 15 lines · Ingo Molnar
Quoted 15 lines

Review

Quoted 12 lines

#include "internals.h"

(quoted diff) +2 -0
+#ifdef CONFIG_LOCKDEP
 /*
  * lockdep: we want to handle all irq_desc locks as a single lock-class:
  */
 static struct lock_class_key irq_desc_lock_class;
+#endif
 
 /**
  * handle_bad_irq - handle spurious and unhandled irqs

No, lockdep.h (which we forgot to include) already handles that:

Quoted 7 lines
Quoted 4 lines
# define lockdep_set_class(lock, key)		do { (void)(key); } while (0)

the problem is that the code which references irq_desc_lock_class is inside #ifdef CONFIG_SPARSE_IRQ, so this is a better fix:

agreed that this is the better fix - applied to tip/irq/sparseirq, thanks!

actually, this breaks the build on !SPARSEIRQ because we will use that class in the non-sparseirq case. So we've converted a build warning to a build failure ;-)

Ingo

#4 lore raw

Hi!

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

No, lockdep.h (which we forgot to include) already handles that:

# define lockdep_set_class(lock, key)               do { (void)(key); } while (0)

the problem is that the code which references irq_desc_lock_class is inside #ifdef CONFIG_SPARSE_IRQ, so this is a better fix:

Quoted 6 lines
Quoted 2 lines

agreed that this is the better fix - applied to tip/irq/sparseirq, thanks!

actually, this breaks the build on !SPARSEIRQ because we will use that class in the non-sparseirq case. So we've converted a build warning to a build failure ;-)

Please give me your .config and tell me your arch. my ia64 box (ia64 is !SPARSEIRQ) can build the akpm patch.

#5 lore raw
Quoted 12 lines · KOSAKI Motohiro

Hi!

Quoted 10 lines
Quoted 9 lines
Quoted 6 lines

No, lockdep.h (which we forgot to include) already handles that:

# define lockdep_set_class(lock, key)               do { (void)(key); } while (0)

the problem is that the code which references irq_desc_lock_class is inside #ifdef CONFIG_SPARSE_IRQ, so this is a better fix:

agreed that this is the better fix - applied to tip/irq/sparseirq, thanks!

Quoted 6 lines
Quoted 3 lines

actually, this breaks the build on !SPARSEIRQ because we will use that class in the non-sparseirq case. So we've converted a build warning to a build failure ;-)

Please give me your .config and tell me your arch. my ia64 box (ia64 is !SPARSEIRQ) can build the akpm patch.

The expected build failure is obvious from reading the code:

#ifdef CONFIG_TRACE_IRQFLAGS
void early_init_irq_lock_class(void)
{

 #ifndef CONFIG_SPARSE_IRQ
         struct irq_desc *desc;
         int i;

         for_each_irq_desc(i, desc) {
                 if (!desc)
                         continue;

                 lockdep_set_class(&desc->lock, &irq_desc_lock_class);

Note that it's an #ifndef sparseirq, not an #ifdef sparseirq condition.

Ingo

#6 lore raw
Quoted 22 lines
Quoted 6 lines
Quoted 3 lines

actually, this breaks the build on !SPARSEIRQ because we will use that class in the non-sparseirq case. So we've converted a build warning to a build failure ;-)

Please give me your .config and tell me your arch. my ia64 box (ia64 is !SPARSEIRQ) can build the akpm patch.

The expected build failure is obvious from reading the code:

#ifdef CONFIG_TRACE_IRQFLAGS
void early_init_irq_lock_class(void)
{

 #ifndef CONFIG_SPARSE_IRQ
        struct irq_desc *desc;
        int i;

        for_each_irq_desc(i, desc) {
                if (!desc)
                        continue;

                lockdep_set_class(&desc->lock, &irq_desc_lock_class);
Quoted 1 line

Note that it's an #ifndef sparseirq, not an #ifdef sparseirq condition.

I see. thanks.
It seems my first proposal is better.

or, following #ifdef ?

#if defined(CONFIG_SPARSE_IRQ) || defined(CONFIG_TRACE_IRQFLAGS)

/*
* lockdep: we want to handle all irq_desc locks as a single lock-class:
*/
static struct lock_class_key irq_desc_lock_class;

#endif

#7 lore raw
Quoted 27 lines · KOSAKI Motohiro
Quoted 22 lines
Quoted 6 lines
Quoted 3 lines

actually, this breaks the build on !SPARSEIRQ because we will use that class in the non-sparseirq case. So we've converted a build warning to a build failure ;-)

Please give me your .config and tell me your arch. my ia64 box (ia64 is !SPARSEIRQ) can build the akpm patch.

The expected build failure is obvious from reading the code:

#ifdef CONFIG_TRACE_IRQFLAGS
void early_init_irq_lock_class(void)
{

 #ifndef CONFIG_SPARSE_IRQ
        struct irq_desc *desc;
        int i;

        for_each_irq_desc(i, desc) {
                if (!desc)
                        continue;

                lockdep_set_class(&desc->lock, &irq_desc_lock_class);
Quoted 1 line

Note that it's an #ifndef sparseirq, not an #ifdef sparseirq condition.

I see. thanks.
It seems my first proposal is better.

Quoted 8 lines

or, following #ifdef ?

#if defined(CONFIG_SPARSE_IRQ) || defined(CONFIG_TRACE_IRQFLAGS)

/*
* lockdep: we want to handle all irq_desc locks as a single lock-class:
*/
static struct lock_class_key irq_desc_lock_class;

instead of increasing the #ifdef jungle, how about removing some? For example is this distinction:

Quoted 1 line
Quoted 1 line

#ifndef CONFIG_SPARSE_IRQ

really needed? We should use symmetric lock class annotations, regardless of how irq_desc[] is laid out.

Ingo

#8 lore raw
Quoted 9 lines
Quoted 8 lines

or, following #ifdef ?

#if defined(CONFIG_SPARSE_IRQ) || defined(CONFIG_TRACE_IRQFLAGS)

/*
* lockdep: we want to handle all irq_desc locks as a single lock-class:
*/
static struct lock_class_key irq_desc_lock_class;

Quoted 7 lines

instead of increasing the #ifdef jungle, how about removing some? For example is this distinction:

Quoted 1 line
Quoted 1 line

#ifndef CONFIG_SPARSE_IRQ

really needed? We should use symmetric lock class annotations, regardless of how irq_desc[] is laid out.

it seems make much sense. I'll test your idea tommorow.

thanks.

#9 lore raw
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines

or, following #ifdef ?

#if defined(CONFIG_SPARSE_IRQ) || defined(CONFIG_TRACE_IRQFLAGS)

/*
* lockdep: we want to handle all irq_desc locks as a single lock-class:
*/
static struct lock_class_key irq_desc_lock_class;

instead of increasing the #ifdef jungle, how about removing some? For example is this distinction:

Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

#ifndef CONFIG_SPARSE_IRQ

really needed? We should use symmetric lock class annotations, regardless of how irq_desc[] is laid out.

it seems make much sense. I'll test your idea tommorow.

Ingo, you are right. I confirmed your idea works well.

I tested following ten pattern.

o handle.c can compile without any warnings?

SPARSE_IRQ TRACE_IRQ LOCKDEP
------------------------------------------
n n n
Y n n
n Y n
n n Y
Y Y n
N Y Y
Y n Y
Y Y Y

o builded kernel works well? (tested on x86_64)

SPARSE_IRQ TRACE_IRQ LOCKDEP
------------------------------------------
n n n
Y Y Y

==
Subject: [PATCH] irq: remove unnecessary ifdef

commit 08678b0841267c1d00d771fe01548d86043d065e introduced irq_desc_lock_class variable.

But it is used only if CONFIG_SPARSE_IRQ=Y or CONFIG_TRACE_IRQFLAGS=Y. otherwise, following warnings happend.

CC kernel/irq/handle.o
kernel/irq/handle.c:26: warning: 'irq_desc_lock_class' defined but not used

Actually, current early_init_irq_lock_class has a bit strange and messy ifdef. In addition, it is not valueable.

1. this function protected by !CONFIG_SPARSE_IRQ. but it is not necessary. if CONFIG_SPARSE_IRQ=Y, desc of all irq number are initialized by NULL at first. then this function calling is safe.

2. this function protected by CONFIG_TRACE_IRQFLAGS too. but it is not necessary too. because lockdep_set_class() doesn't have bad side effect even if CONFIG_TRACE_IRQFLAGS=n,

This patch bloat kernel size a bit on CONFIG_TRACE_IRQFLAGS=n and CONFIG_SPARSE_IRQ=Y. that's ok. early_init_irq_lock_class() is not fastpatch at all.

To avoid ifdef messy is important than few byte diet.

---
 include/linux/lockdep.h |    2 +-
 kernel/irq/handle.c     |    5 -----
 2 files changed, 1 insertion(+), 6 deletions(-)
kernel/irq/handle.c +0 -5
Index: b/kernel/irq/handle.c
===================================================================
@@ -417,11 +417,8 @@ out:
 }
 #endif
 
-
-#ifdef CONFIG_TRACE_IRQFLAGS
 void early_init_irq_lock_class(void)
 {
-#ifndef CONFIG_SPARSE_IRQ
 	struct irq_desc *desc;
 	int i;
 
@@ -431,9 +428,7 @@ void early_init_irq_lock_class(void)
 
 		lockdep_set_class(&desc->lock, &irq_desc_lock_class);
 	}
-#endif
 }
-#endif
 
 #ifdef CONFIG_SPARSE_IRQ
 unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
include/linux/lockdep.h +1 -1
Index: b/include/linux/lockdep.h
===================================================================
@@ -407,7 +407,7 @@ do {								\
 
 #endif /* CONFIG_LOCKDEP */
 
-#if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_GENERIC_HARDIRQS)
+#ifdef CONFIG_GENERIC_HARDIRQS
 extern void early_init_irq_lock_class(void);
 #else
 static inline void early_init_irq_lock_class(void)
Applied
#10 lore raw
Quoted 40 lines · KOSAKI Motohiro
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines

or, following #ifdef ?

#if defined(CONFIG_SPARSE_IRQ) || defined(CONFIG_TRACE_IRQFLAGS)

/*
* lockdep: we want to handle all irq_desc locks as a single lock-class:
*/
static struct lock_class_key irq_desc_lock_class;

instead of increasing the #ifdef jungle, how about removing some? For example is this distinction:

Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

#ifndef CONFIG_SPARSE_IRQ

really needed? We should use symmetric lock class annotations, regardless of how irq_desc[] is laid out.

it seems make much sense. I'll test your idea tommorow.

Ingo, you are right. I confirmed your idea works well.

I tested following ten pattern.

o handle.c can compile without any warnings?

SPARSE_IRQ TRACE_IRQ LOCKDEP
------------------------------------------
n n n
Y n n
n Y n
n n Y
Y Y n
N Y Y
Y n Y
Y Y Y

o builded kernel works well? (tested on x86_64)

Quoted 8 lines

SPARSE_IRQ TRACE_IRQ LOCKDEP
------------------------------------------
n n n
Y Y Y

==
Subject: [PATCH] irq: remove unnecessary ifdef

Applied to tip/irq/sparseirq, thanks!

Ingo