2009-07-22 20:30:54

by Bruno Prémont

[permalink] [raw]
Subject: [Patch] Fix compile failure after genirq: Delegate irq affinity setting to the irq thread

Since genirq: Delegate irq affinity setting to the irq thread
(591d2fb02ea80472d846c0b8507007806bdd69cc) compilation with
CONFIG_SMP=n fails with following error:

/usr/src/linux-2.6/kernel/irq/manage.c:
In function 'irq_thread_check_affinity':
/usr/src/linux-2.6/kernel/irq/manage.c:475:
error: 'struct irq_desc' has no member named 'affinity'
make[4]: *** [kernel/irq/manage.o] Error 1

That commit adds a new function irq_thread_check_affinity() which
uses struct irq_desc.affinity which is only available for CONFIG_SMP=y.
Move that function under #ifdef CONFIG_SMP.

Signed-off-by: Bruno Prémont <[email protected]>
---
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index f0de36f..576638d 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -451,6 +451,7 @@ static int irq_wait_for_interrupt(struct irqaction *action)
return -1;
}

+#ifdef CONFIG_SMP
/*
* Check whether we need to change the affinity of the interrupt thread.
*/
@@ -478,6 +479,12 @@ irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
set_cpus_allowed_ptr(current, mask);
free_cpumask_var(mask);
}
+#else
+static inline void
+irq_thread_check_affinity(struct irq_desc *desc, struct irqaction
*action) +{
+}
+#endif

/*
* Interrupt handler thread


---
Alternative patch which moves the new function irq_thread_check_affinity()
around so it is covered by already existing #ifdef CONFIG_SMP.
---
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index f0de36f..acf7922 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -190,11 +190,44 @@ int irq_select_affinity_usr(unsigned int irq)
return ret;
}

+/*
+ * Check whether we need to change the affinity of the interrupt thread.
+ */
+static void
+irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
+{
+ cpumask_var_t mask;
+
+ if (!test_and_clear_bit(IRQTF_AFFINITY, &action->thread_flags))
+ return;
+
+ /*
+ * In case we are out of memory we set IRQTF_AFFINITY again and
+ * try again next time
+ */
+ if (!alloc_cpumask_var(&mask, GFP_KERNEL)) {
+ set_bit(IRQTF_AFFINITY, &action->thread_flags);
+ return;
+ }
+
+ spin_lock_irq(&desc->lock);
+ cpumask_copy(mask, desc->affinity);
+ spin_unlock_irq(&desc->lock);
+
+ set_cpus_allowed_ptr(current, mask);
+ free_cpumask_var(mask);
+}
+
#else
static inline int setup_affinity(unsigned int irq, struct irq_desc *desc)
{
return 0;
}
+
+static inline void
+irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
+{
+}
#endif

void __disable_irq(struct irq_desc *desc, unsigned int irq, bool suspend)
@@ -452,34 +485,6 @@ static int irq_wait_for_interrupt(struct irqaction *action)
}

/*
- * Check whether we need to change the affinity of the interrupt thread.
- */
-static void
-irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
-{
- cpumask_var_t mask;
-
- if (!test_and_clear_bit(IRQTF_AFFINITY, &action->thread_flags))
- return;
-
- /*
- * In case we are out of memory we set IRQTF_AFFINITY again and
- * try again next time
- */
- if (!alloc_cpumask_var(&mask, GFP_KERNEL)) {
- set_bit(IRQTF_AFFINITY, &action->thread_flags);
- return;
- }
-
- spin_lock_irq(&desc->lock);
- cpumask_copy(mask, desc->affinity);
- spin_unlock_irq(&desc->lock);
-
- set_cpus_allowed_ptr(current, mask);
- free_cpumask_var(mask);
-}
-
-/*
* Interrupt handler thread
*/
static int irq_thread(void *data)


2009-07-22 21:07:14

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [Patch] Fix compile failure after genirq: Delegate irq affinity setting to the irq thread

On Wed, 22 Jul 2009, Bruno Prémont wrote:

> Since genirq: Delegate irq affinity setting to the irq thread
> (591d2fb02ea80472d846c0b8507007806bdd69cc) compilation with
> CONFIG_SMP=n fails with following error:
>
> /usr/src/linux-2.6/kernel/irq/manage.c:
> In function 'irq_thread_check_affinity':
> /usr/src/linux-2.6/kernel/irq/manage.c:475:
> error: 'struct irq_desc' has no member named 'affinity'
> make[4]: *** [kernel/irq/manage.o] Error 1
>
> That commit adds a new function irq_thread_check_affinity() which
> uses struct irq_desc.affinity which is only available for CONFIG_SMP=y.
> Move that function under #ifdef CONFIG_SMP.
>
> Signed-off-by: Bruno Prémont <[email protected]>

Darn. My bad. I was too focussed to get that problem solved :(

Thanks,

tglx

2009-07-22 21:22:27

by Bruno Prémont

[permalink] [raw]
Subject: [tip:irq/urgent] genirq: Fix UP compile failure caused by irq_thread_check_affinity

Commit-ID: 61f3826133dc07142935fb5712fc738e19eb5575
Gitweb: http://git.kernel.org/tip/61f3826133dc07142935fb5712fc738e19eb5575
Author: Bruno Premont <[email protected]>
AuthorDate: Wed, 22 Jul 2009 22:22:32 +0200
Committer: Thomas Gleixner <[email protected]>
CommitDate: Wed, 22 Jul 2009 23:18:46 +0200

genirq: Fix UP compile failure caused by irq_thread_check_affinity

Since genirq: Delegate irq affinity setting to the irq thread
(591d2fb02ea80472d846c0b8507007806bdd69cc) compilation with
CONFIG_SMP=n fails with following error:

/usr/src/linux-2.6/kernel/irq/manage.c:
In function 'irq_thread_check_affinity':
/usr/src/linux-2.6/kernel/irq/manage.c:475:
error: 'struct irq_desc' has no member named 'affinity'
make[4]: *** [kernel/irq/manage.o] Error 1

That commit adds a new function irq_thread_check_affinity() which
uses struct irq_desc.affinity which is only available for CONFIG_SMP=y.
Move that function under #ifdef CONFIG_SMP.

[ tglx@brownpaperbag: compile and boot tested on UP and SMP ]

Signed-off-by: Bruno Premont <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>


---
kernel/irq/manage.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index f0de36f..61c679d 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -451,6 +451,7 @@ static int irq_wait_for_interrupt(struct irqaction *action)
return -1;
}

+#ifdef CONFIG_SMP
/*
* Check whether we need to change the affinity of the interrupt thread.
*/
@@ -478,6 +479,10 @@ irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
set_cpus_allowed_ptr(current, mask);
free_cpumask_var(mask);
}
+#else
+static inline void
+irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action) { }
+#endif

/*
* Interrupt handler thread