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 '->' (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 <linux/profile.h> #include <linux/sched.h> #include <linux/tick.h> +#include <asm/irq_regs.h> #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->cpumask, cpumask)) irq_set_affinity(newdev->irq, cpumask); - +#endif /* * When global broadcasting is active, check if the ...
Generic code must never use linux/irq.h - it's more like asm-generic file predating asm-generic. --
agreed. Heiko, if you remove all these: ./time/tick-broadcast.c:#include <linux/irq.h> ./time/tick-oneshot.c:#include <linux/irq.h> ./time/tick-common.c:#include <linux/irq.h> ./hrtimer.c:#include <linux/irq.h> 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 --
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 <linux/interrupt.h>. 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 <heiko.carstens@de.ibm.com> Generic code is not supposed to include linux/irq.h. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> --- 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 <linux/cpu.h> -#include <linux/irq.h> #include <linux/module.h> #include <linux/percpu.h> #include <linux/hrtimer.h> 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 <linux/cpu.h> #include <linux/err.h> #include <linux/hrtimer.h> -#include <linux/irq.h> #include <linux/percpu.h> #include <linux/profile.h> #include <linux/sched.h> 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 <linux/cpu.h> #include <linux/err.h> #include <linux/hrtimer.h> -#include <linux/irq.h> ...
And here comes the second part...
Subject: [PATCH] time: remove include/irq.h from tick-common.c
From: Heiko Carstens <heiko.carstens@de.ibm.com>
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 <heiko.carstens@de.ibm.com>
---
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 <linux/cache.h>
#include <linux/threads.h>
-#include <asm/irq.h>
+#include <linux/irq.h>
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 <asm/irq.h>
+#include <linux/irq.h>
#include <asm/bug.h>
/* 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-sparc64/hardirq.h
+++ ...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 ...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.
--
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, --
Okay. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> -- Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: --
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. --
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 <><
--
| Jesse Barnes | Re: [stable] [BUG][PATCH] cpqphp: fix kernel NULL pointer dereference |
| Greg KH | [003/136] p54usb: add Zcomax XG-705A usbid |
| Magnus Damm | [PATCH 03/07] ARM: Use shared GIC entry macros on Realview |
| Oliver Neukum | Re: [Bug #13682] The webcam stopped working when upgrading from 2.6.29 to 2.6.30 |
| Martin Schwidefsky | Re: [PATCH] optimized ktime_get[_ts] for GENERIC_TIME=y |
git: | |
| Junio C Hamano | Re: Some advanced index playing |
| Jeff King | Re: confusion over the new branch and merge config |
| Robin Rosenberg | Re: cvs2svn conversion directly |
