2005-01-16 04:34:04

by Adrian Bunk

[permalink] [raw]
Subject: ppc64 xics.c: what is smp_threads_ready exactly used for?

Hi Anton,

during a cleanup, I stumbled upon the following:


arch/ppc64/kernel/smp.c (in 2.6.11-rc1-mm1) says:

/* XXX fix this, xics currently relies on it - Anton */
smp_threads_ready = 1;


arch/ppc64/kernel/xics.c is the _only_ place in the whole kernel where
smp_threads_ready is actually used, and this is the _only_ place where
smp_threads_ready ever changes it's value on ppc64.

I have to admit I'm a bit lost in the sequence of function calls on
ppc64. Is it possible to make any assumptions about the ordering of the
assignment and the usage of smp_threads_ready?


TIA
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed


2005-01-16 05:21:59

by Anton Blanchard

[permalink] [raw]
Subject: Re: ppc64 xics.c: what is smp_threads_ready exactly used for?


Hi,

> during a cleanup, I stumbled upon the following:
>
>
> arch/ppc64/kernel/smp.c (in 2.6.11-rc1-mm1) says:
>
> /* XXX fix this, xics currently relies on it - Anton */
> smp_threads_ready = 1;
>
>
> arch/ppc64/kernel/xics.c is the _only_ place in the whole kernel where
> smp_threads_ready is actually used, and this is the _only_ place where
> smp_threads_ready ever changes it's value on ppc64.

It turns out I was about to submit a patch to remove the ppc64 use of
smp_threads_ready. With that patch it makes sense to kill
smp_threads_ready completely.

Anton

2005-01-16 05:27:09

by Adrian Bunk

[permalink] [raw]
Subject: Re: ppc64 xics.c: what is smp_threads_ready exactly used for?

On Sun, Jan 16, 2005 at 04:19:04PM +1100, Anton Blanchard wrote:
>
> Hi,

Hi Anton,

> > during a cleanup, I stumbled upon the following:
> >
> >
> > arch/ppc64/kernel/smp.c (in 2.6.11-rc1-mm1) says:
> >
> > /* XXX fix this, xics currently relies on it - Anton */
> > smp_threads_ready = 1;
> >
> >
> > arch/ppc64/kernel/xics.c is the _only_ place in the whole kernel where
> > smp_threads_ready is actually used, and this is the _only_ place where
> > smp_threads_ready ever changes it's value on ppc64.
>
> It turns out I was about to submit a patch to remove the ppc64 use of
> smp_threads_ready. With that patch it makes sense to kill
> smp_threads_ready completely.

I've got a patch ready to remove smp_threads_ready on all architectures.

The only part I still need ids how to replace it in xics.c, since this
is the only read access to this variable on all architectures.

Could you send me this part for inclusion into my patch?

> Anton

TIA
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2005-01-16 05:59:15

by Anton Blanchard

[permalink] [raw]
Subject: [PATCH] ppc64: Remove CONFIG_IRQ_ALL_CPUS


Replace CONFIG_IRQ_ALL_CPUS with a boot option (noirqdistrib). Compile
options arent much use on a distro kernel. This also removes the ppc64
use of smp_threads_ready.

I considered removing the option completely but we have had problems in
the past with firmware bugs. In those cases the boot option would have
helped.

Signed-off-by: Anton Blanchard <[email protected]>

===== arch/ppc64/Kconfig 1.76 vs edited =====
--- 1.76/arch/ppc64/Kconfig 2005-01-16 09:31:06 +11:00
+++ edited/arch/ppc64/Kconfig 2005-01-16 16:48:43 +11:00
@@ -186,14 +186,6 @@

If you don't know what to do here, say Y.

-config IRQ_ALL_CPUS
- bool "Distribute interrupts on all CPUs by default"
- depends on SMP && PPC_MULTIPLATFORM
- help
- This option gives the kernel permission to distribute IRQs across
- multiple CPUs. Saying N here will route all IRQs to the first
- CPU.
-
config NR_CPUS
int "Maximum number of CPUs (2-128)"
range 2 128
===== arch/ppc64/kernel/irq.c 1.74 vs edited =====
--- 1.74/arch/ppc64/kernel/irq.c 2005-01-05 13:48:02 +11:00
+++ edited/arch/ppc64/kernel/irq.c 2005-01-16 16:48:47 +11:00
@@ -62,6 +62,7 @@

extern irq_desc_t irq_desc[NR_IRQS];

+int distribute_irqs = 1;
int __irq_offset_value;
int ppc_spurious_interrupts;
unsigned long lpevent_count;
@@ -479,3 +480,10 @@

#endif /* CONFIG_IRQSTACKS */

+static int __init setup_noirqdistrib(char *str)
+{
+ distribute_irqs = 0;
+ return 1;
+}
+
+__setup("noirqdistrib", setup_noirqdistrib);
===== arch/ppc64/kernel/mpic.c 1.3 vs edited =====
--- 1.3/arch/ppc64/kernel/mpic.c 2004-11-16 14:29:10 +11:00
+++ edited/arch/ppc64/kernel/mpic.c 2005-01-16 16:48:44 +11:00
@@ -765,10 +765,8 @@
#ifdef CONFIG_SMP
struct mpic *mpic = mpic_primary;
unsigned long flags;
-#ifdef CONFIG_IRQ_ALL_CPUS
u32 msk = 1 << hard_smp_processor_id();
unsigned int i;
-#endif

BUG_ON(mpic == NULL);

@@ -776,16 +774,16 @@

spin_lock_irqsave(&mpic_lock, flags);

-#ifdef CONFIG_IRQ_ALL_CPUS
/* let the mpic know we want intrs. default affinity is 0xffffffff
* until changed via /proc. That's how it's done on x86. If we want
* it differently, then we should make sure we also change the default
* values of irq_affinity in irq.c.
*/
- for (i = 0; i < mpic->num_sources ; i++)
- mpic_irq_write(i, MPIC_IRQ_DESTINATION,
- mpic_irq_read(i, MPIC_IRQ_DESTINATION) | msk);
-#endif /* CONFIG_IRQ_ALL_CPUS */
+ if (distribute_irqs) {
+ for (i = 0; i < mpic->num_sources ; i++)
+ mpic_irq_write(i, MPIC_IRQ_DESTINATION,
+ mpic_irq_read(i, MPIC_IRQ_DESTINATION) | msk);
+ }

/* Set current processor priority to 0 */
mpic_cpu_write(MPIC_CPU_CURRENT_TASK_PRI, 0);
===== arch/ppc64/kernel/pSeries_smp.c 1.9 vs edited =====
--- 1.9/arch/ppc64/kernel/pSeries_smp.c 2005-01-12 11:42:40 +11:00
+++ edited/arch/ppc64/kernel/pSeries_smp.c 2005-01-16 16:48:44 +11:00
@@ -259,7 +259,6 @@
if (cur_cpu_spec->firmware_features & FW_FEATURE_SPLPAR)
vpa_init(cpu);

-#ifdef CONFIG_IRQ_ALL_CPUS
/*
* Put the calling processor into the GIQ. This is really only
* necessary from a secondary thread as the OF start-cpu interface
@@ -267,7 +266,6 @@
*/
rtas_set_indicator(GLOBAL_INTERRUPT_QUEUE,
(1UL << interrupt_server_size) - 1 - default_distrib_server, 1);
-#endif
}

static spinlock_t timebase_lock = SPIN_LOCK_UNLOCKED;
===== arch/ppc64/kernel/smp.c 1.104 vs edited =====
--- 1.104/arch/ppc64/kernel/smp.c 2005-01-12 11:42:39 +11:00
+++ edited/arch/ppc64/kernel/smp.c 2005-01-16 16:48:45 +11:00
@@ -526,9 +526,6 @@

smp_ops->setup_cpu(boot_cpuid);

- /* XXX fix this, xics currently relies on it - Anton */
- smp_threads_ready = 1;
-
set_cpus_allowed(current, old_mask);

/*
===== arch/ppc64/kernel/xics.c 1.57 vs edited =====
--- 1.57/arch/ppc64/kernel/xics.c 2005-01-12 11:42:40 +11:00
+++ edited/arch/ppc64/kernel/xics.c 2005-01-16 16:48:45 +11:00
@@ -242,28 +242,24 @@
static int get_irq_server(unsigned int irq)
{
unsigned int server;
-
-#ifdef CONFIG_IRQ_ALL_CPUS
/* For the moment only implement delivery to all cpus or one cpu */
- if (smp_threads_ready) {
- cpumask_t cpumask = irq_affinity[irq];
- cpumask_t tmp = CPU_MASK_NONE;
- if (cpus_equal(cpumask, CPU_MASK_ALL)) {
- server = default_distrib_server;
- } else {
- cpus_and(tmp, cpu_online_map, cpumask);
+ cpumask_t cpumask = irq_affinity[irq];
+ cpumask_t tmp = CPU_MASK_NONE;
+
+ if (!distribute_irqs)
+ return default_server;

- if (cpus_empty(tmp))
- server = default_distrib_server;
- else
- server = get_hard_smp_processor_id(first_cpu(tmp));
- }
+ if (cpus_equal(cpumask, CPU_MASK_ALL)) {
+ server = default_distrib_server;
} else {
- server = default_server;
+ cpus_and(tmp, cpu_online_map, cpumask);
+
+ if (cpus_empty(tmp))
+ server = default_distrib_server;
+ else
+ server = get_hard_smp_processor_id(first_cpu(tmp));
}
-#else
- server = default_server;
-#endif
+
return server;

}
===== include/asm-ppc64/irq.h 1.11 vs edited =====
--- 1.11/include/asm-ppc64/irq.h 2004-10-23 11:44:19 +10:00
+++ edited/include/asm-ppc64/irq.h 2005-01-16 16:48:47 +11:00
@@ -87,6 +87,8 @@
return irq;
}

+extern int distribute_irqs;
+
struct irqaction;
struct pt_regs;

2005-01-16 07:25:55

by Adrian Bunk

[permalink] [raw]
Subject: Re: [PATCH] ppc64: Remove CONFIG_IRQ_ALL_CPUS

On Sun, Jan 16, 2005 at 04:55:23PM +1100, Anton Blanchard wrote:
>
> Replace CONFIG_IRQ_ALL_CPUS with a boot option (noirqdistrib). Compile
> options arent much use on a distro kernel. This also removes the ppc64
> use of smp_threads_ready.
>...

Seems perfect for me. :-)

I'll simply state that my patch depends on ppc64 on your patch.

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed