Move the initialization of irq_default_affinity to early_irq_init as
core_initcall is too late.
irq_default_affinity can be used in init_IRQ and potentially timer and
SMP init as well. All of these happen before core_initcall. Moving
the initialization to early_irq_init ensures that it is initialized
before it is used.
Signed-off-by: David Daney <[email protected]>
---
Only tested on my mips/cavium_octeon port that (if the benevolent
spirits are willing) will be pushed up from Ralf's linux-mips.org tree
in the very near future. Also the tested configuration is without
CONFIG_SPARSE_IRQ, so that was not tested, but it should be safe as it
is the same code.
kernel/irq/handle.c | 8 ++++++++
kernel/irq/internals.h | 4 ++++
kernel/irq/manage.c | 4 +---
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index c20db0b..54802ca 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -134,6 +134,10 @@ int __init early_irq_init(void)
int legacy_count;
int i;
+#ifdef CONFIG_SMP
+ init_irq_default_affinity();
+#endif
+
desc = irq_desc_legacy;
legacy_count = ARRAY_SIZE(irq_desc_legacy);
@@ -219,6 +223,10 @@ int __init early_irq_init(void)
int count;
int i;
+#ifdef CONFIG_SMP
+ init_irq_default_affinity();
+#endif
+
desc = irq_desc;
count = ARRAY_SIZE(irq_desc);
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index e6d0a43..066ff94 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -32,6 +32,10 @@ static inline void unregister_handler_proc(unsigned int irq,
extern int irq_select_affinity_usr(unsigned int irq);
+#ifdef CONFIG_SMP
+extern void init_irq_default_affinity(void);
+#endif
+
/*
* Debugging printout:
*/
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index cd0cd8d..2f87aae 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -18,13 +18,11 @@
#ifdef CONFIG_SMP
cpumask_var_t irq_default_affinity;
-static int init_irq_default_affinity(void)
+void __init init_irq_default_affinity(void)
{
alloc_cpumask_var(&irq_default_affinity, GFP_KERNEL);
cpumask_setall(irq_default_affinity);
- return 0;
}
-core_initcall(init_irq_default_affinity);
/**
* synchronize_irq - wait for pending IRQ handlers (on other CPUs)
--
1.5.6.6
On Thu, 8 Jan 2009, David Daney wrote:
>
> +#ifdef CONFIG_SMP
> + init_irq_default_affinity();
> +#endif
Don't do this. It's horrible. It makes the code much harder to read.
What's so wrong with initializing affinity on UP? It's still conceptually
a fine thing to do, although it's obviously trivially a no-op.
Also, since it's only used in "handle.c", why not just move it there?
Then, just make it static, and make it a no-op for the non-SMP case. Ok?
In fact, I think it already is a no-op in the UP case, and you can
literally just do
static inline void __init init_irq_default_affinity(void)
{
alloc_cpumask_var(&irq_default_affinity, GFP_KERNEL);
cpumask_setall(irq_default_affinity);
}
and be done with it. I think it should all compile away to nothing if
CONFIG_SMP isn't set.
Linus
Linus Torvalds wrote:
[...]
> In fact, I think it already is a no-op in the UP case, and you can
> literally just do
>
> static inline void __init init_irq_default_affinity(void)
> {
> alloc_cpumask_var(&irq_default_affinity, GFP_KERNEL);
> cpumask_setall(irq_default_affinity);
> }
>
> and be done with it. I think it should all compile away to nothing if
> CONFIG_SMP isn't set.
The 'inline' seems gratuitous to me. Since it is static GCC should do
the Right Thing. However since you suggested it, I am testing it that way.
David Daney
On Thu, 8 Jan 2009, David Daney wrote:
>
> The 'inline' seems gratuitous to me. Since it is static GCC should do
> the Right Thing. However since you suggested it, I am testing it that
> way.
Trust me, gcc very seldom does the Right Thing(tm) when it comes to
inlining.
Linus
David Daney wrote:
> Linus Torvalds wrote:
> [...]
>> In fact, I think it already is a no-op in the UP case, and you can
>> literally just do
>>
>> static inline void __init init_irq_default_affinity(void)
>> {
>> alloc_cpumask_var(&irq_default_affinity, GFP_KERNEL);
>> cpumask_setall(irq_default_affinity);
>> }
>>
>> and be done with it. I think it should all compile away to nothing if
>> CONFIG_SMP isn't set.
>
> The 'inline' seems gratuitous to me. Since it is static GCC should do
> the Right Thing. However since you suggested it, I am testing it that way.
>
> David Daney
It will probably need to be:
alloc_bootmem_cpumask_var(&irq_default_affinity);
I am testing it on x86_64 as well.
Thanks,
Mike
On Friday 09 January 2009 07:26:59 Linus Torvalds wrote:
>
> On Thu, 8 Jan 2009, David Daney wrote:
> >
> > The 'inline' seems gratuitous to me. Since it is static GCC should do
> > the Right Thing. However since you suggested it, I am testing it that
> > way.
>
> Trust me, gcc very seldom does the Right Thing(tm) when it comes to
> inlining.
>
> Linus
Note that there's a downside: with inline funcs in .c files you don't get
a warning should they become unused in future cleanups.
Cheers,
Rusty.