Subject: Re: [mmotm and linux-next][PATCH] irq: enclose irq_desc_lock_class in CONFIG_LOCKDEP

From: Andrew Morton <[email-masked]>
Date: Tue, 16 Dec 2008 00:34:28 -0800

On Tue, 16 Dec 2008 17:08:43 +0900 (JST) KOSAKI Motohiro <[email-masked]> wrote:

> 
> 
> 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
> 
> 
> Signed-off-by: KOSAKI Motohiro <[email-masked]>
> CC: Yinghai Lu <[email-masked]>
> CC: Ingo Molnar <[email-masked]>
> ---
>  kernel/irq/handle.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> Index: b/kernel/irq/handle.c
> ===================================================================
> --- a/kernel/irq/handle.c
> +++ 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
> 

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:

--- a/kernel/irq/handle.c~irq-enclose-irq_desc_lock_class-in-config_lockdep
+++ a/kernel/irq/handle.c
@@ -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,
_