All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpumask fallout: Initialize irq_default_affinity earlier.
@ 2009-01-08 20:21 David Daney
  2009-01-08 20:33 ` Linus Torvalds
  0 siblings, 1 reply; 6+ messages in thread
From: David Daney @ 2009-01-08 20:21 UTC (permalink / raw)
  To: rusty, torvalds; +Cc: linux-kernel, linux-mips, David Daney

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 <ddaney@caviumnetworks.com>
---

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpumask fallout: Initialize irq_default_affinity earlier.
  2009-01-08 20:21 [PATCH] cpumask fallout: Initialize irq_default_affinity earlier David Daney
@ 2009-01-08 20:33 ` Linus Torvalds
  2009-01-08 20:49   ` David Daney
  0 siblings, 1 reply; 6+ messages in thread
From: Linus Torvalds @ 2009-01-08 20:33 UTC (permalink / raw)
  To: David Daney; +Cc: rusty, linux-kernel, linux-mips



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpumask fallout: Initialize irq_default_affinity earlier.
  2009-01-08 20:33 ` Linus Torvalds
@ 2009-01-08 20:49   ` David Daney
  2009-01-08 20:56     ` Linus Torvalds
  2009-01-08 21:25     ` Mike Travis
  0 siblings, 2 replies; 6+ messages in thread
From: David Daney @ 2009-01-08 20:49 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: rusty, linux-kernel, linux-mips

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpumask fallout: Initialize irq_default_affinity earlier.
  2009-01-08 20:49   ` David Daney
@ 2009-01-08 20:56     ` Linus Torvalds
  2009-01-10  5:11       ` Rusty Russell
  2009-01-08 21:25     ` Mike Travis
  1 sibling, 1 reply; 6+ messages in thread
From: Linus Torvalds @ 2009-01-08 20:56 UTC (permalink / raw)
  To: David Daney; +Cc: rusty, linux-kernel, linux-mips



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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpumask fallout: Initialize irq_default_affinity earlier.
  2009-01-08 20:49   ` David Daney
  2009-01-08 20:56     ` Linus Torvalds
@ 2009-01-08 21:25     ` Mike Travis
  1 sibling, 0 replies; 6+ messages in thread
From: Mike Travis @ 2009-01-08 21:25 UTC (permalink / raw)
  To: David Daney; +Cc: Linus Torvalds, rusty, linux-kernel, linux-mips

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cpumask fallout: Initialize irq_default_affinity earlier.
  2009-01-08 20:56     ` Linus Torvalds
@ 2009-01-10  5:11       ` Rusty Russell
  0 siblings, 0 replies; 6+ messages in thread
From: Rusty Russell @ 2009-01-10  5:11 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: David Daney, linux-kernel, linux-mips

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-01-10  5:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-08 20:21 [PATCH] cpumask fallout: Initialize irq_default_affinity earlier David Daney
2009-01-08 20:33 ` Linus Torvalds
2009-01-08 20:49   ` David Daney
2009-01-08 20:56     ` Linus Torvalds
2009-01-10  5:11       ` Rusty Russell
2009-01-08 21:25     ` Mike Travis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.