login
Header Space

 
 

Re: tick-common.c hack for s390 needed

Previous thread: [PATCH] Audit: netlink socket can be auto-bound to pid other than current->pid by Pavel Emelyanov on Tuesday, March 18, 2008 - 5:24 am. (5 messages)

Next thread: ide_cd modifies hard_* members of request by Nikanth Karthikesan on Tuesday, March 18, 2008 - 4:54 am. (4 messages)
To: Thomas Gleixner <tglx@...>, Ingo Molnar <mingo@...>
Cc: <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>
Date: Tuesday, March 18, 2008 - 5:31 am

Hi Thomas, Ingo,

I'm converting s390 from s390's NO_IDLE_HZ to GENERIC_CLOCKEVENTS and
therefore to the generic NO_HZ implementation.
One of the problems that need a patch for this is kernel/time/tick-common.c
which relies on the irq stuff present in include/linux/irq.h.
In particular s390 doesn't have something like irq_set_affinity which
causes this build error:

  CC      kernel/time/tick-common.o
kernel/time/tick-common.c: In function 'tick_periodic':
kernel/time/tick-common.c:70: error: implicit declaration of function 'get_irq_regs'
kernel/time/tick-common.c:70: error: invalid type argument of '-&gt;' (have 'int')
kernel/time/tick-common.c: In function 'tick_setup_device':
kernel/time/tick-common.c:171: error: implicit declaration of function 'irq_set_affinity'
kernel/time/tick-common.c: In function 'tick_check_new_device':
kernel/time/tick-common.c:216: error: implicit declaration of function 'irq_can_set_affinity'

Actually there's a huge #ifndef CONFIG_S390 in linux/irq.h ;)

To make the code work the patch below is necessary. It's ok since all
clock event devices on s390 are per cpu. However I think this patch is
ugly at best. Any ideas how to fix this in a better and more generic way?

---
 kernel/time/tick-common.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Index: linux-2.6/kernel/time/tick-common.c
===================================================================
--- linux-2.6.orig/kernel/time/tick-common.c
+++ linux-2.6/kernel/time/tick-common.c
@@ -19,6 +19,7 @@
 #include &lt;linux/profile.h&gt;
 #include &lt;linux/sched.h&gt;
 #include &lt;linux/tick.h&gt;
+#include &lt;asm/irq_regs.h&gt;
 
 #include "tick-internal.h"
 
@@ -167,9 +168,10 @@ static void tick_setup_device(struct tic
 	 * When the device is not per cpu, pin the interrupt to the
 	 * current cpu:
 	 */
+#ifndef CONFIG_S390
 	if (!cpus_equal(newdev-&gt;cpumask, cpumask))
 		irq_set_affinity(newdev-&gt;irq, cpumask);
-
+#endif
 	/*
 	 * When global broadcasting i...
To: Heiko Carstens <heiko.carstens@...>
Cc: Thomas Gleixner <tglx@...>, Ingo Molnar <mingo@...>, <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>
Date: Wednesday, March 19, 2008 - 12:12 am

You could have an #else path in linux/irq.h to just define these
functions as s390, maybe like

static inline int irq_set_affinity(unsigned int irq, cpumask_t cpumask)
{
	BUG();
	return 0;
}
static inline int irq_can_set_affinity(unsigned int irq)
{
	return 0;
}

	Arnd &lt;&gt;&lt;
--
To: Heiko Carstens <heiko.carstens@...>
Cc: Thomas Gleixner <tglx@...>, Ingo Molnar <mingo@...>, <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>
Date: Wednesday, March 19, 2008 - 1:45 am

Generic code must never use linux/irq.h - it's more like asm-generic
file predating asm-generic.

--
To: Christoph Hellwig <hch@...>
Cc: Heiko Carstens <heiko.carstens@...>, Thomas Gleixner <tglx@...>, <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>
Date: Friday, March 21, 2008 - 6:15 am

agreed.

Heiko, if you remove all these:

 ./time/tick-broadcast.c:#include &lt;linux/irq.h&gt;
 ./time/tick-oneshot.c:#include &lt;linux/irq.h&gt;
 ./time/tick-common.c:#include &lt;linux/irq.h&gt;
 ./hrtimer.c:#include &lt;linux/irq.h&gt;

from kernel/*, do things improve on s390? If yes then please send a 
patch for it and i'll check whether there's any include file dependency 
fallout on x86.

	Ingo
--
To: Ingo Molnar <mingo@...>
Cc: Christoph Hellwig <hch@...>, Thomas Gleixner <tglx@...>, <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>
Date: Friday, March 21, 2008 - 9:25 am

No, tick-common.c has calls to irq_set_affinity and irq_can_set_affinity, for
which the prototypes are in linux/irq.h.
Each and every architecture seems to include linux/irq.h from a different file
in asm-[your-favourite-arch]/*.h. I was able to fix the build breakage on x86
by adding an include &lt;linux/interrupt.h&gt;. But that won't work on other
architectures.
From a logical point of view I would expect that asm/irq.h is supposed to
include linux/irq.h, no?

The patch below removes at least three of the includes for a beginning.
Still compiles on s390 and x86_64.

Subject: [PATCH] time: remove include/irq.h.

From: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;

Generic code is not supposed to include linux/irq.h.

Signed-off-by: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
---

 kernel/hrtimer.c             |    1 -
 kernel/time/tick-broadcast.c |    1 -
 kernel/time/tick-oneshot.c   |    1 -
 3 files changed, 3 deletions(-)

Index: linux-2.6/kernel/hrtimer.c
===================================================================
--- linux-2.6.orig/kernel/hrtimer.c
+++ linux-2.6/kernel/hrtimer.c
@@ -32,7 +32,6 @@
  */
 
 #include &lt;linux/cpu.h&gt;
-#include &lt;linux/irq.h&gt;
 #include &lt;linux/module.h&gt;
 #include &lt;linux/percpu.h&gt;
 #include &lt;linux/hrtimer.h&gt;
Index: linux-2.6/kernel/time/tick-broadcast.c
===================================================================
--- linux-2.6.orig/kernel/time/tick-broadcast.c
+++ linux-2.6/kernel/time/tick-broadcast.c
@@ -14,7 +14,6 @@
 #include &lt;linux/cpu.h&gt;
 #include &lt;linux/err.h&gt;
 #include &lt;linux/hrtimer.h&gt;
-#include &lt;linux/irq.h&gt;
 #include &lt;linux/percpu.h&gt;
 #include &lt;linux/profile.h&gt;
 #include &lt;linux/sched.h&gt;
Index: linux-2.6/kernel/time/tick-oneshot.c
===================================================================
--- linux-2.6.orig/kernel/time/tick-oneshot.c
+++ linux-2.6/kernel/time/tick-oneshot.c
@@ -14,7 +14,6 @@
 #include &lt;linux/cp...
To: Heiko Carstens <heiko.carstens@...>
Cc: Ingo Molnar <mingo@...>, Christoph Hellwig <hch@...>, <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>
Date: Friday, March 21, 2008 - 10:45 am

Applied, thanks,

	 tglx

--
To: Thomas Gleixner <tglx@...>
Cc: Ingo Molnar <mingo@...>, Christoph Hellwig <hch@...>, <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>, <paulus@...>, <ralf@...>, <rmk@...>, <davem@...>, <lethal@...>, <jdike@...>
Date: Saturday, March 22, 2008 - 4:32 pm

And here comes the second part...

Subject: [PATCH] time: remove include/irq.h from tick-common.c

From: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;

Generic code is not supposed to include irq.h. Replace this include
by linux/hardirq.h instead and add/replace an include of linux/irq.h
in asm header files where necessary.
This change should only matter for architectures that make use of
GENERIC_CLOCKEVENTS.
Architectures in question are mips, x86, arm, sh, powerpc, uml and sparc64.

I did some cross compile tests for mips, x86_64, arm, powerpc and sparc64.
This patch fixes also build breakages caused by the include replacement in
tick-common.h.

I didn't test uml and sh.

Signed-off-by: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
---
 include/asm-arm/hardirq.h     |    2 +-
 include/asm-powerpc/hardirq.h |    2 +-
 include/asm-sparc64/hardirq.h |    1 +
 include/asm-sparc64/irq.h     |    1 -
 kernel/time/tick-common.c     |    2 +-
 5 files changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6/include/asm-arm/hardirq.h
===================================================================
--- linux-2.6.orig/include/asm-arm/hardirq.h
+++ linux-2.6/include/asm-arm/hardirq.h
@@ -3,7 +3,7 @@
 
 #include &lt;linux/cache.h&gt;
 #include &lt;linux/threads.h&gt;
-#include &lt;asm/irq.h&gt;
+#include &lt;linux/irq.h&gt;
 
 typedef struct {
 	unsigned int __softirq_pending;
Index: linux-2.6/include/asm-powerpc/hardirq.h
===================================================================
--- linux-2.6.orig/include/asm-powerpc/hardirq.h
+++ linux-2.6/include/asm-powerpc/hardirq.h
@@ -2,7 +2,7 @@
 #define _ASM_POWERPC_HARDIRQ_H
 #ifdef __KERNEL__
 
-#include &lt;asm/irq.h&gt;
+#include &lt;linux/irq.h&gt;
 #include &lt;asm/bug.h&gt;
 
 /* The __last_jiffy_stamp field is needed to ensure that no decrementer
Index: linux-2.6/include/asm-sparc64/hardirq.h
===================================================================
--- linux-2.6.orig/include/asm-sparc6...
To: Heiko Carstens <heiko.carstens@...>
Cc: Thomas Gleixner <tglx@...>, Ingo Molnar <mingo@...>, Christoph Hellwig <hch@...>, <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>, <paulus@...>, <ralf@...>, <davem@...>, <lethal@...>, <jdike@...>
Date: Sunday, March 23, 2008 - 6:34 pm

I generally dislike adding optional linux/* includes in asm/* includes -
I'm nervous about this causing include loops.

However, there's a separate point to be discussed here.

That is, what interfaces are expected of every architecture in the kernel.
If generic code wants to be able to set the affinity of interrupts, then
that needs to become part of the interfaces listed in linux/interrupt.h
rather than linux/irq.h.

So what I suggest is this approach instead (against Linus' tree of a
couple of days ago) - we move irq_set_affinity() and irq_can_set_affinity()
to linux/interrupt.h, change the linux/irq.h includes to linux/interrupt.h
and include asm/irq_regs.h where needed (asm/irq_regs.h is supposed to be
rarely used include since not much touches the stacked parent context
registers.)

Build tested on ARM PXA family kernels and ARM's Realview platform
kernels which both use genirq.

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index f8ab4ce..355e3b0 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -102,6 +102,25 @@ extern void disable_irq_nosync(unsigned int irq);
 extern void disable_irq(unsigned int irq);
 extern void enable_irq(unsigned int irq);
 
+#ifdef CONFIG_SMP
+
+extern int irq_set_affinity(unsigned int irq, cpumask_t cpumask);
+extern int irq_can_set_affinity(unsigned int irq);
+
+#else /* CONFIG_SMP */
+
+static inline int irq_set_affinity(unsigned int irq, cpumask_t cpumask)
+{
+	return -EINVAL;
+}
+
+static inline int irq_can_set_affinity(unsigned int irq)
+{
+	return 0;
+}
+
+#endif /* CONFIG_SMP */
+
 #ifdef CONFIG_GENERIC_HARDIRQS
 /*
  * Special lockdep variants of irq disabling/enabling.
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 176e5e7..1883a85 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -228,21 +228,11 @@ static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
 
 #endif /* CONFIG_GENERIC_PENDING_IRQ */
 
-extern int irq_set_affinity(un...
To: Russell King <rmk+lkml@...>
Cc: Heiko Carstens <heiko.carstens@...>, Ingo Molnar <mingo@...>, Christoph Hellwig <hch@...>, <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>, <paulus@...>, <ralf@...>, <davem@...>, <lethal@...>, <jdike@...>
Date: Tuesday, March 25, 2008 - 3:09 pm

That patch makes a lot of sense and resolves all the issues. 

I push it through hrt.git and add the GENERIC_HARDIRQS dependency
which was requested by Heiko.

Thanks,

--
To: Thomas Gleixner <tglx@...>
Cc: Russell King <rmk+lkml@...>, Ingo Molnar <mingo@...>, Christoph Hellwig <hch@...>, <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>, <paulus@...>, <ralf@...>, <davem@...>, <lethal@...>, <jdike@...>
Date: Tuesday, April 1, 2008 - 7:02 am

Thomas, would you mind if we push this patch via git-s390?
As far as I can see s390 is the only architecture which has a dependency on
this patch. This would make merging our NO_IDLE_HZ to GENERIC_CLOCKEVENTS
conversion easier.
I'd take the version you have in your mm branch in your hrt tree, if you're
ok with this.
--
To: Heiko Carstens <heiko.carstens@...>
Cc: Russell King <rmk+lkml@...>, Ingo Molnar <mingo@...>, Christoph Hellwig <hch@...>, <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>, <paulus@...>, <ralf@...>, <davem@...>, <lethal@...>, <jdike@...>
Date: Tuesday, April 1, 2008 - 7:24 am

Ok, I drop it.

Thanks,
	tglx
 
--
To: Thomas Gleixner <tglx@...>
Cc: Heiko Carstens <heiko.carstens@...>, Ingo Molnar <mingo@...>, Christoph Hellwig <hch@...>, <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>, <paulus@...>, <ralf@...>, <davem@...>, <lethal@...>, <jdike@...>
Date: Tuesday, March 25, 2008 - 3:30 pm

Okay.  Signed-off-by: Russell King &lt;rmk+kernel@arm.linux.org.uk&gt;

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:
--
To: Russell King <rmk+lkml@...>
Cc: Thomas Gleixner <tglx@...>, Ingo Molnar <mingo@...>, Christoph Hellwig <hch@...>, <linux-kernel@...>, Martin Schwidefsky <schwidefsky@...>, <paulus@...>, <ralf@...>, <davem@...>, <lethal@...>, <jdike@...>
Date: Monday, March 24, 2008 - 6:14 am

Could you add something like

#ifdef CONFIG_GENERIC_HARDIRQS

/* added stuff from above */

#else /* CONFIG_GENERIC_HARDIRQS */

static inline int irq_set_affinity(unsigned int irq, cpumask_t cpumask)
{
	WARN_ON(1);
	return -EINVAL;
}

static inline int irq_can_set_affinity(unsigned int irq)
{
	return 0;
}
#endif /* CONFIG_GENERIC_HARDIRQS */

Then it should do the right thing on s390 as well.
--
Previous thread: [PATCH] Audit: netlink socket can be auto-bound to pid other than current->pid by Pavel Emelyanov on Tuesday, March 18, 2008 - 5:24 am. (5 messages)

Next thread: ide_cd modifies hard_* members of request by Nikanth Karthikesan on Tuesday, March 18, 2008 - 4:54 am. (4 messages)
speck-geostationary