powerpc/irq: tidy up inconsistent context in migrate_irqs()
PATCH 1/1 powerpc/irq: tidy up inconsistent context in migrate_irqs()
From: Zhang Zhuoyu <[email protected]>
Remove paradoxical and unnecessary lines before disable local interrupt.
--- arch/powerpc/kernel/irq.c | 2 -- 1 file changed, 2 deletions(-)
arch/powerpc/kernel/irq.c +0 -2
@@ -454,8 +454,6 @@ void migrate_irqs(void)free_cpumask_var (mask); -local_irq_enable (); -mdelay (1 ); local_irq_disable(); }#endif
Signature · 1 line
1.8.3.1
Hi,
A couple of things.
Firstly, your two email addresses don't match:
Quoted 1 line · Zhang Zhuoyu
From: Zhang Zhuoyu <[email protected]>
These lines do seem odd! Are they causing a problem?
I'd be more comfortable removing them if I understood why they were added. But they've been around since the beginning of git history so that could be a bit difficult.
Instead, would it be possible to make sure this doesn't break anything by including some test results?
Thanks,
Daniel
Quoted 29 lines
Remove paradoxical and unnecessary lines before disable local interrupt.
Signed-off-by Zhang Zhuoyu <[email protected]>--- arch/powerpc/kernel/irq.c | 2 -- 1 file changed, 2 deletions(-)arch/powerpc/kernel/irq.c +0
-2@@ -454,8 +454,6 @@ void migrate_irqs(void)free_cpumask_var (mask); -local_irq_enable (); -mdelay (1 ); local_irq_disable(); }#endif Signature · 8 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Michael Ellerman
reviewerQuoted 8 lines · Daniel Axtens
Hi,
A couple of things.
Firstly, your two email addresses don't match:
Zhang Zhuoyu <[email protected]> writes:
Quoted 7 lines
Quoted 1 line
From: Zhang Zhuoyu <[email protected]>
These lines do seem odd! Are they causing a problem?
I'd be more comfortable removing them if I understood why they were added. But they've been around since the beginning of git history so that could be a bit difficult.
It's in the fullhist tree, but that doesn't tell us much (below, named fixup_irqs()).
But I suspect those lines are actually there very deliberately.
The function is migrating interrupts off the recently offlined cpu, because we don't want to take interrupts on an offline cpu.
After it's finished doing the migration, it wants to make sure there are no interrupts that have already been latched by the offline cpu. So it briefly enables interrupts, waits a bit for the interrupts to fire, and the disables them again.
Whether that actually works I couldn't say, it is very old code, and it's used on platforms where I don't ever test cpu hotplug (85xx & powermac).
cheers
commit d58830b9a740ad1c3b089196d4afdaea251dc701
Author: Zwane Mwaikambo <[email protected]> Date: Fri Mar 4 17:34:00 2005 -0800
[PATCH] ppc64: generic hotplug cpu support
Patch provides a generic hotplug cpu implementation, with the only current user being pmac. This doesn't replace real hotplug code as is currently used by LPAR systems. Ben i can add the additional pmac specific code to put the processor into a sleeping state seperately. Thanks to Nathan for testing.
arch/ppc64/Kconfig +1 -1
@@ -313,7 +313,7 @@ source "drivers/pci/Kconfig" config HOTPLUG_CPU bool "Support for hot-pluggable CPUs" - depends on SMP && EXPERIMENTAL && PPC_PSERIES + depends on SMP && EXPERIMENTAL && (PPC_PSERIES || PPC_PMAC) select HOTPLUG ---help--- Say Y here to be able to turn CPUs off and on.
arch/ppc64/kernel/idle.c +4 -0
@@ -293,6 +293,10 @@ static int native_idle(void)power4_idle ();if (need_resched ())schedule (); + +if (cpu_is_offline (smp_processor_id ()) && + system_state ==SYSTEM_RUNNING ) +cpu_die (); }return 0 ; }
arch/ppc64/kernel/irq.c +29 -0
@@ -116,6 +116,35 @@ skip:return 0 ; } +#ifdef CONFIG_HOTPLUG_CPU +void fixup_irqs (cpumask_t map) +{ +unsigned int irq; +static int warned; + +for_each_irq (irq) { +cpumask_t mask; + +if (irq_desc[irq].status &IRQ_PER_CPU ) +continue ; + +cpus_and (mask, irq_affinity[irq], map); +if (any_online_cpu (mask) ==NR_CPUS ) { +printk ("Breaking affinity for irq %i\n" , irq); + mask = map; + } +if (irq_desc[irq].handler->set_affinity) + irq_desc[irq].handler->set_affinity (irq, mask); +else if (irq_desc[irq].action && !(warned++)) +printk ("Cannot set affinity for irq %i\n" , irq); + } + +local_irq_enable (); +mdelay (1 ); +local_irq_disable (); +} +#endif +extern int noirqdebug;/*
arch/ppc64/kernel/pSeries_setup.c +3 -2
@@ -320,8 +320,9 @@ static void __init pSeries_discover_pic(void) } } -static void pSeries_cpu_die (void ) +static void pSeries_mach_cpu_die (void ) { +idle_task_exit ();local_irq_disable ();/* Some hardware requires clearing the CPPR, while other hardware does not * it is safe either way
@@ -599,7 +600,7 @@ struct machdep_calls __initdata pSeries_md = { .power_off = rtas_power_off, .halt = rtas_halt, .panic = rtas_os_term, - .cpu_die = pSeries_cpu_die, + .cpu_die = pSeries_mach_cpu_die, .get_boot_time = pSeries_get_boot_time, .get_rtc_time = pSeries_get_rtc_time, .set_rtc_time = pSeries_set_rtc_time,
arch/ppc64/kernel/pmac_setup.c +3 -0
@@ -439,6 +439,9 @@ static int __init pmac_probe(int platform) }struct machdep_calls __initdata pmac_md = { +#ifdef CONFIG_HOTPLUG_CPU + .cpu_die = generic_mach_cpu_die, +#endif .probe = pmac_probe, .setup_arch = pmac_setup_arch, .init_early = pmac_init_early,
arch/ppc64/kernel/pmac_smp.c +5 -0
@@ -308,4 +308,9 @@ struct smp_ops_t core99_smp_ops __pmacdata = {void __init pmac_setup_smp (void ) { smp_ops = &core99_smp_ops; +#ifdef CONFIG_HOTPLUG_CPU + smp_ops->cpu_enable = generic_cpu_enable; + smp_ops->cpu_disable = generic_cpu_disable; + smp_ops->cpu_die = generic_cpu_die; +#endif }
arch/ppc64/kernel/setup.c +0 -3
@@ -1377,9 +1377,6 @@ early_param("xmon", early_xmon);void cpu_die (void ) { -idle_task_exit ();if (ppc_md.cpu_die) ppc_md.cpu_die (); -local_irq_disable (); -for (;;); }
arch/ppc64/kernel/smp.c +80 -0
96 lines not on this page · raw message
arch/ppc64/kernel/sysfs.c +2 -4
@@ -18,7 +18,7 @@#include <asm/systemcfg.h> #include <asm/paca.h> #include <asm/lppaca.h> - +#include <asm/machdep.h> static DEFINE_PER_CPU(struct cpu, cpu_devices);
@@ -413,9 +413,7 @@ static int __init topology_init(void)* CPU. For instance, the boot cpu might never be valid * for hotplugging. */ -#ifdef CONFIG_HOTPLUG_CPU - if (systemcfg->platform != PLATFORM_PSERIES_LPAR) -#endif +if (!ppc_md.cpu_die) c->no_control =1 ;if (cpu_online (cpu) || (c->no_control ==0 )) {
include/asm-ppc64/machdep.h +1 -0
@@ -30,6 +30,7 @@ struct smp_ops_t {void (*setup_cpu)(int nr);void (*take_timebase)(void );void (*give_timebase)(void ); +int (*cpu_enable)(unsigned int nr);int (*cpu_disable)(void );void (*cpu_die)(unsigned int nr); };
include/asm-ppc64/smp.h +8 -1
@@ -29,7 +29,7 @@extern int boot_cpuid;extern int boot_cpuid_phys; -extern void cpu_die (void ) __attribute__((noreturn)); +extern void cpu_die (void );#ifdef CONFIG_SMP
@@ -37,6 +37,13 @@ extern void smp_send_debugger_break(int cpu);struct pt_regs ;extern void smp_message_recv (int ,struct pt_regs *); +#ifdef CONFIG_HOTPLUG_CPU +extern void fixup_irqs (cpumask_t map); +int generic_cpu_disable (void ); +int generic_cpu_enable (unsigned int cpu); +void generic_cpu_die (unsigned int cpu); +void generic_mach_cpu_die (void ); +#endif #define __smp_processor_id () (get_paca()->paca_index)#define hard_smp_processor_id () (get_paca()->hw_cpu_id)
Quoted 26 lines · Michael Ellerman
Quoted 8 lines · Daniel Axtens
Hi,
A couple of things.
Firstly, your two email addresses don't match:
Zhang Zhuoyu <[email protected]> writes:
Quoted 7 lines
Quoted 1 line
From: Zhang Zhuoyu <[email protected]>
These lines do seem odd! Are they causing a problem?
I'd be more comfortable removing them if I understood why they were added. But they've been around since the beginning of git history so that could be a bit difficult.
It's in the fullhist tree, but that doesn't tell us much (below, named
fixup_irqs()).But I suspect those lines are actually there very deliberately.
The function is migrating interrupts off the recently offlined cpu, because we
don't want to take interrupts on an offline cpu.
Quoted 8 lines
After it's finished doing the migration, it wants to make sure there are no interrupts that have already been latched by the offline cpu. So it briefly enables interrupts, waits a bit for the interrupts to fire, and the disables them again.
Whether that actually works I couldn't say, it is very old code, and it's used
on platforms where I don't ever test cpu hotplug (85xx & powermac).
Yeah, it would be nice to test this change. I'll try it on my quad-core pmac machine
Quoted 328 lines
cheers
commit
d58830b9a740ad1c3b089196d4afdaea251dc701Author: Zwane Mwaikambo <[email protected]> Date: Fri Mar 4 17:34:00 2005 -0800[PATCH] ppc64: generic hotplug cpu support
Patch provides a generic hotplug cpu implementation, with the only
current
user being pmac. This doesn't replace real hotplug code as is currently used by LPAR systems. Ben i can add the additional pmac specific code
to
put the processor into a sleeping state seperately. Thanks to Nathan
for
testing.Signed-off-by Zwane Mwaikambo <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Linus Torvalds <[email protected]>arch/ppc64/Kconfig +1
-1@@ -313,7 +313,7 @@ source "drivers/pci/Kconfig" config HOTPLUG_CPU bool "Support for hot-pluggable CPUs" - depends on SMP && EXPERIMENTAL && PPC_PSERIES + depends on SMP && EXPERIMENTAL && (PPC_PSERIES || PPC_PMAC) select HOTPLUG ---help--- Say Y here to be able to turn CPUs off and on.arch/ppc64/kernel/idle.c +4
-0@@ -293,6 +293,10 @@ static int native_idle(void)power4_idle ();if (need_resched ())schedule (); + +if (cpu_is_offline (smp_processor_id ()) && + system_state ==SYSTEM_RUNNING ) +cpu_die (); }return 0 ; }arch/ppc64/kernel/irq.c +29
-0@@ -116,6 +116,35 @@ skip:return 0 ; } +#ifdef CONFIG_HOTPLUG_CPU +void fixup_irqs (cpumask_t map) +{ +unsigned int irq; +static int warned; + +for_each_irq (irq) { +cpumask_t mask; + +if (irq_desc[irq].status &IRQ_PER_CPU ) +continue ; + +cpus_and (mask, irq_affinity[irq], map); +if (any_online_cpu (mask) ==NR_CPUS ) { +printk ("Breaking affinity for irq %i\n" , irq); + mask = map; + } +if (irq_desc[irq].handler->set_affinity) + irq_desc[irq].handler->set_affinity (irq, mask); +else if (irq_desc[irq].action && !(warned++)) +printk ("Cannot set affinity for irq %i\n" , irq); + } + +local_irq_enable (); +mdelay (1 ); +local_irq_disable (); +} +#endif +extern int noirqdebug;/* arch/ppc64/kernel/pSeries_setup.c +3
-2@@ -320,8 +320,9 @@ static void __init pSeries_discover_pic(void) } } -static void pSeries_cpu_die (void ) +static void pSeries_mach_cpu_die (void ) { +idle_task_exit ();local_irq_disable ();/* Some hardware requires clearing the CPPR, while other hardware does not * it is safe either way @@ -599,7 +600,7 @@ struct machdep_calls __initdata pSeries_md = { .power_off = rtas_power_off, .halt = rtas_halt, .panic = rtas_os_term, - .cpu_die = pSeries_cpu_die, + .cpu_die = pSeries_mach_cpu_die, .get_boot_time = pSeries_get_boot_time, .get_rtc_time = pSeries_get_rtc_time, .set_rtc_time = pSeries_set_rtc_time,arch/ppc64/kernel/pmac_setup.c +3
-0@@ -439,6 +439,9 @@ static int __init pmac_probe(int platform) }struct machdep_calls __initdata pmac_md = { +#ifdef CONFIG_HOTPLUG_CPU + .cpu_die = generic_mach_cpu_die, +#endif .probe = pmac_probe, .setup_arch = pmac_setup_arch, .init_early = pmac_init_early,arch/ppc64/kernel/pmac_smp.c +5
-0@@ -308,4 +308,9 @@ struct smp_ops_t core99_smp_ops __pmacdata = {void __init pmac_setup_smp (void ) { smp_ops = &core99_smp_ops; +#ifdef CONFIG_HOTPLUG_CPU + smp_ops->cpu_enable = generic_cpu_enable; + smp_ops->cpu_disable = generic_cpu_disable; + smp_ops->cpu_die = generic_cpu_die; +#endif }arch/ppc64/kernel/setup.c +0
-3@@ -1377,9 +1377,6 @@ early_param("xmon", early_xmon);void cpu_die (void ) { -idle_task_exit ();if (ppc_md.cpu_die) ppc_md.cpu_die (); -local_irq_disable (); -for (;;); }arch/ppc64/kernel/smp.c +80
-0@@ -30,6 +30,7 @@#include <linux/err.h> #include <linux/sysdev.h> #include <linux/cpu.h> +#include <linux/notifier.h> #include <asm/ptrace.h> #include <asm/atomic.h> @@ -406,10 +407,89 @@ void __devinit smp_prepare_boot_cpu(void) current_set[boot_cpuid] = current->thread_info; } +#ifdef CONFIG_HOTPLUG_CPU +/* State of each CPU during hotplug phases */ +DEFINE_PER_CPU(int, cpu_state) = { 0 }; + +int generic_cpu_disable (void ) +{ +unsigned int cpu =smp_processor_id (); + +if (cpu == boot_cpuid) +return -EBUSY ; + + systemcfg->processorCount--; +cpu_clear (cpu, cpu_online_map); +fixup_irqs (cpu_online_map); +return 0 ; +} + +int generic_cpu_enable (unsigned int cpu) +{ +/* Do the normal bootup if we haven't +* already bootstrapped. */ +if (system_state !=SYSTEM_RUNNING ) +return -ENOSYS ; + +/* get the target out of it's holding state */ +per_cpu (cpu_state, cpu) =CPU_UP_PREPARE ; +wmb (); + +while (!cpu_online (cpu)) +cpu_relax (); + +fixup_irqs (cpu_online_map); +/* counter the irq disable in fixup_irqs */ +local_irq_enable (); +return 0 ; +} + +void generic_cpu_die (unsigned int cpu) +{ +int i; + +for (i =0 ; i <100 ; i++) { +rmb (); +if (per_cpu (cpu_state, cpu) ==CPU_DEAD ) +return ; +msleep (100 ); + } +printk (KERN_ERR "CPU%d didn't die...\n" , cpu); +} + +void generic_mach_cpu_die (void ) +{ +unsigned int cpu; + +local_irq_disable (); + cpu =smp_processor_id (); +printk (KERN_DEBUG "CPU%d offline\n" , cpu); +__get_cpu_var (cpu_state) =CPU_DEAD ; +wmb (); +while (__get_cpu_var (cpu_state) !=CPU_UP_PREPARE ) +cpu_relax (); + +flush_tlb_pending (); +cpu_set (cpu, cpu_online_map); +local_irq_enable (); +} +#endif + +static int __devinit cpu_enable (unsigned int cpu) +{ +if (smp_ops->cpu_enable) +return smp_ops->cpu_enable (cpu); + +return -ENOSYS ; +} +int __devinit __cpu_up (unsigned int cpu) {int c; +if (!cpu_enable (cpu)) +return 0 ; +/* At boot, don't bother with non-present cpus -JSCHOPP */ if (system_state <SYSTEM_RUNNING && !cpu_present (cpu))return -ENOENT ;arch/ppc64/kernel/sysfs.c +2
-4@@ -18,7 +18,7 @@#include <asm/systemcfg.h> #include <asm/paca.h> #include <asm/lppaca.h> - +#include <asm/machdep.h> static DEFINE_PER_CPU(struct cpu, cpu_devices);@@ -413,9 +413,7 @@ static int __init topology_init(void)* CPU. For instance, the boot cpu might never be valid * for hotplugging. */ -#ifdef CONFIG_HOTPLUG_CPU - if (systemcfg->platform != PLATFORM_PSERIES_LPAR) -#endif +if (!ppc_md.cpu_die) c->no_control =1 ;if (cpu_online (cpu) || (c->no_control ==0 )) {include/asm-ppc64/machdep.h +1
-0@@ -30,6 +30,7 @@ struct smp_ops_t {void (*setup_cpu)(int nr);void (*take_timebase)(void );void (*give_timebase)(void ); +int (*cpu_enable)(unsigned int nr);int (*cpu_disable)(void );void (*cpu_die)(unsigned int nr); };include/asm-ppc64/smp.h +8
-1@@ -29,7 +29,7 @@extern int boot_cpuid;extern int boot_cpuid_phys; -extern void cpu_die (void ) __attribute__((noreturn)); +extern void cpu_die (void );#ifdef CONFIG_SMP @@ -37,6 +37,13 @@ extern void smp_send_debugger_break(int cpu);struct pt_regs ;extern void smp_message_recv (int ,struct pt_regs *); +#ifdef CONFIG_HOTPLUG_CPU +extern void fixup_irqs (cpumask_t map); +int generic_cpu_disable (void ); +int generic_cpu_enable (unsigned int cpu); +void generic_cpu_die (unsigned int cpu); +void generic_mach_cpu_die (void ); +#endif #define __smp_processor_id () (get_paca()->paca_index)#define hard_smp_processor_id () (get_paca()->hw_cpu_id)_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Quoted 8 lines
-----Original Message-----
From: Denis Kirjanov [mailto:[email protected]]
Sent: Wednesday, December 16, 2015 7:55 PM
To: Michael Ellerman
Cc: Daniel Axtens; Zhang Zhuoyu; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; =
linux-
Quoted 16 lines
[email protected]
Subject: Re: [PATCH 1/1] powerpc/irq: tidy up inconsistent context inmigrate_irqs()
=20Quoted 11 lines · Michael Ellerman
Quoted 10 lines · Daniel Axtens
Hi,
A couple of things.
Firstly, your two email addresses don't match:
Quoted 1 line · Zhang Zhuoyu
From: Zhang Zhuoyu <[email protected]>
Mmm, My mistake, I will correct it next time.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
These lines do seem odd! Are they causing a problem?
I'd be more comfortable removing them if I understood why they were added. But they've been around since the beginning of git history =
so
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
that could be a bit difficult.
It's in the fullhist tree, but that doesn't tell us much (below, =
named
Quoted 12 lines
Quoted 12 lines
fixup_irqs()).But I suspect those lines are actually there very deliberately.
The function is migrating interrupts off the recently offlined cpu, because we don't want to take interrupts on an offline cpu.
After it's finished doing the migration, it wants to make sure there are no interrupts that have already been latched by the offline cpu. So it briefly enables interrupts, waits a bit for the interrupts to fire, and the disables them again.
Quoted 5 lines
Quoted 3 lines
Whether that actually works I couldn't say, it is very old code, and it's used on platforms where I don't ever test cpu hotplug (85xx & powermac).
=20
Yeah, it would be nice to test this change. I'll try it on my =
quad-core pmac
Quoted 2 lines
machine
=20
Thanks Michael for help explaining the code logic, it also resolved my = doubts.
These snippets are suspected when I did PM benchmark on FSL MPC85xx = series(T1040, T4240),=20
For T4240, which has 24 CPUs, it waits 1ms in migrate_irqs()each time a = CPU is plugged offline,
it seems a waste of time. I also did a test on T1040, after plugging = offline/online CPU hundreds of times,
system works well. If you have any other suggestion on how to test, I'd = like to do more benchmark.
(1)for((i=3D0; i<1000; i++)); do echo 0 > = /sys/devices/system/cpu/cpu1/online;=20
sleep 1; echo 1 > /sys/devices/system/cpu/cpu1/online; done
(2)root@t1040rdb:~# cat /proc/interrupts
CPU0 CPU1 CPU2 CPU3
36: 393 1 223 1 OpenPIC 36 Level =
serial
LOC: 1946 1486 1555 1361 Local timer =
interrupts
DBL: 7371 9707 9390 7568 Doorbell interrupts
(3)root@t1040rdb:~# ps
PID TTY TIME CMD
2751 ttyS0 00:00:00 sh
2757 ttyS0 00:00:00 ps
root@t1040rdb:~# taskset -pc 1 2751
pid 2751's current affinity list: 0-3
pid 2751's new affinity list: 1
root@t1040rdb:~#
root@t1040rdb:~#
root@t1040rdb:~#
root@t1040rdb:~# echo "hello"
hello
root@t1040rdb:~#Quoted 11 lines
Quoted 11 lines
cheers
commit
d58830b9a740ad1c3b089196d4afdaea251dc701Author: Zwane Mwaikambo <[email protected]> Date: Fri Mar 4 17:34:00 2005 -0800[PATCH] ppc64: generic hotplug cpu support
Patch provides a generic hotplug cpu implementation, with the =
only
Quoted 2 lines
Quoted 2 lines
current
user being pmac. This doesn't replace real hotplug code as is =
currently
Quoted 1 line
Quoted 1 line
used by LPAR systems. Ben i can add the additional pmac =
specific
Quoted 20 lines
Quoted 14 lines
code to
put the processor into a sleeping state seperately. Thanks to
Nathan for
testing.Signed-off-by Zwane Mwaikambo <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Linus Torvalds <[email protected]>arch/ppc64/Kconfig index renamed from arch/ppc64/Kconfig +0
-0
a7933ab62e98..861f4460ad02100644arch/ppc64/Kconfig source "drivers/pci/Kconfig" · line 316
Quoted 5 lines
arch/ppc64/Kconfig +1
-1@@ -313,7 +313,7 @@ source "drivers/pci/Kconfig" config HOTPLUG_CPU bool "Support for hot-pluggable CPUs" - depends on SMP && EXPERIMENTAL && PPC_PSERIES + depends on SMP && EXPERIMENTAL && (PPC_PSERIES ||
PPC_PMAC)
Quoted 4 lines
arch/ppc64/kernel/idle.c =
Quoted 4 lines
arch/ppc64/Kconfig +0
-0select HOTPLUG ---help--- Say Y here to be able to turn CPUs off and on.arch/ppc64/kernel/idle.c = renamed from arch/ppc64/kernel/idle.c +0
-0
index
Quoted 262 lines
Quoted 60 lines
398b4682127b..51eb6af14a8f100644arch/ppc64/kernel/idle.c +4
-0@@ -293,6 +293,10 @@ static int native_idle(void)power4_idle ();if (need_resched ())schedule (); + +if (cpu_is_offline (smp_processor_id ()) && + system_state =3D=3D SYSTEM_RUNNING) +cpu_die (); }return 0 ; }arch/ppc64/kernel/irq.c index renamed from arch/ppc64/kernel/irq.c +0
-0
0ea8016146a2..4fd7f203c1e3100644arch/ppc64/kernel/irq.c +29
-0@@ -116,6 +116,35 @@ skip:return 0 ; } +#ifdef CONFIG_HOTPLUG_CPU +void fixup_irqs (cpumask_t map) +{ +unsigned int irq; +static int warned; + +for_each_irq (irq) { +cpumask_t mask; + +if (irq_desc[irq].status &IRQ_PER_CPU ) +continue ; + +cpus_and (mask, irq_affinity[irq], map); + if (any_online_cpu(mask) =3D=3D NR_CPUS) { +printk ("Breaking affinity for irq %i\n" , irq); + mask =3D map; + } +if (irq_desc[irq].handler->set_affinity) + irq_desc[irq].handler->set_affinity (irq, mask); +else if (irq_desc[irq].action && !(warned++)) +printk ("Cannot set affinity for irq %i\n" , irq); + } + +local_irq_enable (); +mdelay (1 ); +local_irq_disable (); +} +#endif +extern int noirqdebug;/* arch/ppc64/kernel/pSeries_setup.c +0
-0arch/ppc64/kernel/pSeries_setup.c static void __init pSeries_discover_pic(void) · line 327
Quoted 9 lines
arch/ppc64/kernel/pSeries_setup.c +2
-1@@ -320,8 +320,9 @@ static void __init pSeries_discover_pic(void) } } -static void pSeries_cpu_die (void ) +static void pSeries_mach_cpu_die (void ) { +idle_task_exit ();local_irq_disable ();/* Some hardware requires clearing the CPPR, while other hardware does not
Quoted 25 lines
arch/ppc64/kernel/pSeries_setup.c +1
-1* it is safe either way @@ -599,7 +600,7 @@ struct machdep_calls __initdata pSeries_md =3D { .power_off =3D rtas_power_off, .halt =3D rtas_halt, .panic =3D rtas_os_term, - .cpu_die =3D pSeries_cpu_die, + .cpu_die =3D pSeries_mach_cpu_die, .get_boot_time =3D pSeries_get_boot_time, .get_rtc_time =3D pSeries_get_rtc_time, .set_rtc_time =3D pSeries_set_rtc_time,(quoted diff) +0
-0
b/arch/ppc64/kernel/pmac_setup.cindex41fa6e95a06f..5c56fc956245100644arch/ppc64/kernel/pmac_setup.c +3
-0@@ -439,6 +439,9 @@ static int __init pmac_probe(int platform) } struct machdep_calls __initdata pmac_md =3D { +#ifdef CONFIG_HOTPLUG_CPU + .cpu_die =3D generic_mach_cpu_die, +#endif .probe =3D pmac_probe, .setup_arch =3D pmac_setup_arch, .init_early =3D pmac_init_early,(quoted diff) +0
-0Quoted 1 line
b/arch/ppc64/kernel/pmac_smp.cindexe0b37079943c..c27588ede2fe100644
Quoted 165 lines
arch/ppc64/kernel/pmac_smp.c +5
-0@@ -308,4 +308,9 @@ struct smp_ops_t core99_smp_ops __pmacdata =3D {void __init pmac_setup_smp (void ) { smp_ops =3D &core99_smp_ops; +#ifdef CONFIG_HOTPLUG_CPU + smp_ops->cpu_enable =3D generic_cpu_enable; + smp_ops->cpu_disable =3D generic_cpu_disable; + smp_ops->cpu_die =3D generic_cpu_die; +#endif }arch/ppc64/kernel/setup.c +0
-3@@ -1377,9 +1377,6 @@ early_param("xmon", early_xmon);void cpu_die (void ) { -idle_task_exit ();if (ppc_md.cpu_die) ppc_md.cpu_die (); -local_irq_disable (); -for (;;); }arch/ppc64/kernel/smp.c index renamed from arch/ppc64/kernel/smp.c +0
-0
a9e43792f8fe..cde1947432a1100644arch/ppc64/kernel/smp.c +76
-0@@ -30,6 +30,7 @@#include <linux/err.h> #include <linux/sysdev.h> #include <linux/cpu.h> +#include <linux/notifier.h> #include <asm/ptrace.h> #include <asm/atomic.h> @@ -406,10 +407,89 @@ void __devinit smp_prepare_boot_cpu(void) current_set[boot_cpuid] =3D current->thread_info; } +#ifdef CONFIG_HOTPLUG_CPU +/* State of each CPU during hotplug phases */ DEFINE_PER_CPU (int, +cpu_state) =3D { 0 }; + +int generic_cpu_disable (void ) +{ + unsigned int cpu =3D smp_processor_id(); + + if (cpu =3D=3D boot_cpuid) +return -EBUSY ; + + systemcfg->processorCount--; +cpu_clear (cpu, cpu_online_map); +fixup_irqs (cpu_online_map); +return 0 ; +} + +int generic_cpu_enable (unsigned int cpu) { +/* Do the normal bootup if we haven't +* already bootstrapped. */ + if (system_state !=3D SYSTEM_RUNNING) +return -ENOSYS ; + +/* get the target out of it's holding state */ + per_cpu(cpu_state, cpu) =3D CPU_UP_PREPARE; +wmb (); + +while (!cpu_online (cpu)) +cpu_relax (); + +fixup_irqs (cpu_online_map); +/* counter the irq disable in fixup_irqs */ +local_irq_enable (); +return 0 ; +} + +void generic_cpu_die (unsigned int cpu) { +int i; + + for (i =3D 0; i < 100; i++) { +rmb (); + if (per_cpu(cpu_state, cpu) =3D=3D CPU_DEAD) +return ; +msleep (100 ); + } +printk (KERN_ERR "CPU%d didn't die...\n" , cpu); } + +void generic_mach_cpu_die (void ) +{ +unsigned int cpu; + +local_irq_disable (); + cpu =3D smp_processor_id(); +printk (KERN_DEBUG "CPU%d offline\n" , cpu); + __get_cpu_var(cpu_state) =3D CPU_DEAD; +wmb (); + while (__get_cpu_var(cpu_state) !=3D CPU_UP_PREPARE) +cpu_relax (); + +flush_tlb_pending (); +cpu_set (cpu, cpu_online_map); +local_irq_enable (); +} +#endif + +static int __devinit cpu_enable (unsigned int cpu) { +if (smp_ops->cpu_enable) +return smp_ops->cpu_enable (cpu); + +return -ENOSYS ; +} +int __devinit __cpu_up (unsigned int cpu) {int c; +if (!cpu_enable (cpu)) +return 0 ; +/* At boot, don't bother with non-present cpus -JSCHOPP */ if (system_state <SYSTEM_RUNNING && !cpu_present (cpu))return -ENOENT ;arch/ppc64/kernel/sysfs.c +2
-4@@ -18,7 +18,7 @@#include <asm/systemcfg.h> #include <asm/paca.h> #include <asm/lppaca.h> - +#include <asm/machdep.h> static DEFINE_PER_CPU(struct cpu, cpu_devices);@@ -413,9 +413,7 @@ static int __init topology_init(void)* CPU. For instance, the boot cpu might never be valid * for hotplugging. */ -#ifdef CONFIG_HOTPLUG_CPU - if (systemcfg->platform !=3D PLATFORM_PSERIES_LPAR) -#endif +if (!ppc_md.cpu_die) c->no_control =3D 1; if (cpu_online(cpu) || (c->no_control =3D=3D 0)) { diff --git
a/include/asm-ppc64/machdep.hb/include/asm-ppc64/machdep.hindex476d2185ffd1..03fe499c7604100644include/asm-ppc64/machdep.h +1
-0@@ -30,6 +30,7 @@ struct smp_ops_t {void (*setup_cpu)(int nr);void (*take_timebase)(void );void (*give_timebase)(void ); +int (*cpu_enable)(unsigned int nr);int (*cpu_disable)(void );void (*cpu_die)(unsigned int nr); };include/asm-ppc64/smp.h index renamed from include/asm-ppc64/smp.h +0
-0
965980bbbb57..c8646fa999c2100644include/asm-ppc64/smp.h +0
-0@@ -29,7 +29,7 @@extern int boot_cpuid;extern int boot_cpuid_phys;
Quoted 7 lines
Quoted 7 lines
include/asm-ppc64/smp.h +1
-1-extern void cpu_die (void ) __attribute__((noreturn)); +extern void cpu_die (void );#ifdef CONFIG_SMP @@ -37,6 +37,13 @@ extern void smp_send_debugger_break(int cpu);struct
pt_regs; extern void smp_message_recv(int, structpt_regs=
*);
Quoted 3 lines
include/asm-ppc64/smp.h
Quoted 3 lines
include/asm-ppc64/smp.h +2
-0+#ifdef CONFIG_HOTPLUG_CPU +extern void fixup_irqs(cpumask_t map); int =
generic_cpu_disable(void);
Quoted 11 lines
Quoted 11 lines
include/asm-ppc64/smp.h +3
-0+int generic_cpu_enable (unsigned int cpu);void +generic_cpu_die (unsigned int cpu);void generic_mach_cpu_die (void ); +#endif #define __smp_processor_id () (get_paca()->paca_index) #define
hard_smp_processor_id()(get_paca()->hw_cpu_id)_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Hi, Denis
Any test result on pmac machine for this patch?=20
Zhuoyu
Quoted 20 lines
-----Original Message-----
From: Zhang Zhuoyu [mailto:[email protected]]
Sent: Wednesday, December 16, 2015 10:46 PM
To: 'Denis Kirjanov'; 'Michael Ellerman'
Cc: 'Daniel Axtens'; 'Zhang Zhuoyu'; '[email protected]'; '[email protected]'; '[email protected]'; '[email protected]'; '[email protected]'; '[email protected]'
Subject: RE: [PATCH 1/1] powerpc/irq: tidy up inconsistent context inmigrate_irqs()
=20
=20Quoted 9 lines
-----Original Message-----
From: Denis Kirjanov [mailto:[email protected]]
Sent: Wednesday, December 16, 2015 7:55 PM
To: Michael Ellerman
Cc: Daniel Axtens; Zhang Zhuoyu; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH 1/1] powerpc/irq: tidy up inconsistent context =
in
Quoted 10 lines
Quoted 10 lines
migrate_irqs()Quoted 7 lines · Michael Ellerman
Quoted 6 lines · Daniel Axtens
Hi,
A couple of things.
Firstly, your two email addresses don't match:
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line · Zhang Zhuoyu
From: Zhang Zhuoyu <[email protected]>
=20
Mmm, My mistake, I will correct it next time.
=20Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
These lines do seem odd! Are they causing a problem?
I'd be more comfortable removing them if I understood why they =
were
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
added. But they've been around since the beginning of git history so that could be a bit difficult.
It's in the fullhist tree, but that doesn't tell us much (below, named
fixup_irqs()).But I suspect those lines are actually there very deliberately.
The function is migrating interrupts off the recently offlined =
cpu,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
because we don't want to take interrupts on an offline cpu.
After it's finished doing the migration, it wants to make sure =
there
Quoted 1 line
Quoted 1 line
Quoted 1 line
are no interrupts that have already been latched by the offline =
cpu.
Quoted 1 line
Quoted 1 line
Quoted 1 line
So it briefly enables interrupts, waits a bit for the interrupts =
to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
fire, and the disables them again.
Whether that actually works I couldn't say, it is very old code, =
and
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
it's used on platforms where I don't ever test cpu hotplug (85xx & powermac).
Yeah, it would be nice to test this change. I'll try it on my quad-core pmac machine
=20
Thanks Michael for help explaining the code logic, it also resolved my =
doubts.
Quoted 3 lines
These snippets are suspected when I did PM benchmark on FSL MPC85xx
series(T1040, T4240), For T4240, which has 24 CPUs, it waits 1ms in migrate_irqs()each time a CPU is plugged offline, it seems a waste of =
time. I
Quoted 1 line
also did a test on T1040, after plugging offline/online CPU hundreds =
of times,
Quoted 1 line
system works well. If you have any other suggestion on how to test, =
I'd like
Quoted 2 lines
to do more benchmark.
(1)for((i=3D0; i<1000; i++)); do echo 0 > =
/sys/devices/system/cpu/cpu1/online;
Quoted 4 lines
sleep 1; echo 1 >
/sys/devices/system/cpu/cpu1/online; done(2)root@t1040rdb:~# cat /proc/interrupts CPU0 CPU1 CPU2 CPU3 36: 393 1 223 1 OpenPIC 36 Level =
serial
Quoted 1 line
LOC: 1946 1486 1555 1361 Local timer =
interrupts
Quoted 28 lines
DBL: 7371 9707 9390 7568 Doorbell interrupts
(3)root@t1040rdb:~# ps PID TTY TIME CMD 2751 ttyS0 00:00:00 sh 2757 ttyS0 00:00:00 ps root@t1040rdb:~# taskset -pc 1 2751 pid 2751's current affinity list: 0-3 pid 2751's new affinity list: 1 root@t1040rdb:~# root@t1040rdb:~# root@t1040rdb:~# root@t1040rdb:~# echo "hello" hello root@t1040rdb:~# =20Quoted 13 lines
Quoted 13 lines
cheers
commit
d58830b9a740ad1c3b089196d4afdaea251dc701Author: Zwane Mwaikambo <[email protected]> Date: Fri Mar 4 17:34:00 2005 -0800[PATCH] ppc64: generic hotplug cpu support
Patch provides a generic hotplug cpu implementation, with the
only current
user being pmac. This doesn't replace real hotplug code as is =
currently
Quoted 32 lines
Quoted 32 lines
Quoted 15 lines
used by LPAR systems. Ben i can add the additional pmac
specific code to
put the processor into a sleeping state seperately. Thanks to
Nathan for
testing.Signed-off-by Zwane Mwaikambo <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Linus Torvalds <[email protected]>arch/ppc64/Kconfig index renamed from arch/ppc64/Kconfig +0
-0
a7933ab62e98..861f4460ad02100644arch/ppc64/Kconfig source "drivers/pci/Kconfig" · line 316
Quoted 5 lines
arch/ppc64/Kconfig +1
-1@@ -313,7 +313,7 @@ source "drivers/pci/Kconfig" config HOTPLUG_CPU bool "Support for hot-pluggable CPUs" - depends on SMP && EXPERIMENTAL && PPC_PSERIES + depends on SMP && EXPERIMENTAL && (PPC_PSERIES ||
PPC_PMAC)Quoted 11 lines
arch/ppc64/Kconfig +0
-0select HOTPLUG ---help--- Say Y here to be able to turn CPUs off and on.arch/ppc64/kernel/idle.c +0
-0@@ -293,6 +293,10 @@ static int native_idle(void)power4_idle ();if (need_resched ())schedule ();
Quoted 8 lines
Quoted 8 lines
arch/ppc64/kernel/irq.c =
Quoted 8 lines
arch/ppc64/kernel/idle.c +4
-0+ +if (cpu_is_offline (smp_processor_id ()) && + system_state =3D=3D SYSTEM_RUNNING) +cpu_die (); }return 0 ; }arch/ppc64/kernel/irq.c = renamed from arch/ppc64/kernel/irq.c +0
-0
index
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
0ea8016146a2..4fd7f203c1e3100644arch/ppc64/kernel/irq.c +29
-0@@ -116,6 +116,35 @@ skip:return 0 ; } +#ifdef CONFIG_HOTPLUG_CPU +void fixup_irqs (cpumask_t map) +{ +unsigned int irq; +static int warned; + +for_each_irq (irq) { +cpumask_t mask; + +if (irq_desc[irq].status &IRQ_PER_CPU ) +continue ; + +cpus_and (mask, irq_affinity[irq], map); + if (any_online_cpu(mask) =3D=3D NR_CPUS) { +printk ("Breaking affinity for irq %i\n" , irq); + mask =3D map; + } +if (irq_desc[irq].handler->set_affinity) + irq_desc[irq].handler->set_affinity (irq, mask); +else if (irq_desc[irq].action && !(warned++)) +printk ("Cannot set affinity for irq %i\n" , irq); + } + +local_irq_enable (); +mdelay (1 ); +local_irq_disable (); +} +#endif +extern int noirqdebug;/* arch/ppc64/kernel/pSeries_setup.c +0
-0@@ -320,8 +320,9 @@ static void __init pSeries_discover_pic(void) } }
Quoted 6 lines
Quoted 6 lines
arch/ppc64/kernel/pSeries_setup.c static void __init pSeries_discover_pic(void)
Quoted 6 lines
arch/ppc64/kernel/pSeries_setup.c +2
-1-static void pSeries_cpu_die (void ) +static void pSeries_mach_cpu_die (void ) { +idle_task_exit ();local_irq_disable ();/* Some hardware requires clearing the CPPR, while other =
hardware
Quoted 3 lines
Quoted 3 lines
does not
arch/ppc64/kernel/pSeries_setup.c struct machdep_calls __initdata pSeries_md =3D =
Quoted 2 lines
arch/ppc64/kernel/pSeries_setup.c +0
-0* it is safe either way @@ -599,7 +600,7 @@ struct machdep_calls __initdata pSeries_md =3D =
{
Quoted 42 lines
Quoted 25 lines
Quoted 23 lines
arch/ppc64/kernel/pSeries_setup.c +1
-1.power_off =3D rtas_power_off, .halt =3D rtas_halt, .panic =3D rtas_os_term, - .cpu_die =3D pSeries_cpu_die, + .cpu_die =3D pSeries_mach_cpu_die, .get_boot_time =3D pSeries_get_boot_time, .get_rtc_time =3D pSeries_get_rtc_time, .set_rtc_time =3D pSeries_set_rtc_time,(quoted diff) +0
-0
b/arch/ppc64/kernel/pmac_setup.cindex41fa6e95a06f..5c56fc956245100644arch/ppc64/kernel/pmac_setup.c +3
-0@@ -439,6 +439,9 @@ static int __init pmac_probe(int platform) } struct machdep_calls __initdata pmac_md =3D { +#ifdef CONFIG_HOTPLUG_CPU + .cpu_die =3D generic_mach_cpu_die, +#endif .probe =3D pmac_probe, .setup_arch =3D pmac_setup_arch, .init_early =3D pmac_init_early,(quoted diff) +0
-0Quoted 1 line
b/arch/ppc64/kernel/pmac_smp.cindexe0b37079943c..c27588ede2fe100644
Quoted 3 lines
arch/ppc64/kernel/pmac_smp.c struct smp_ops_t core99_smp_ops __pmacdata =3D
Quoted 3 lines
arch/ppc64/kernel/pmac_smp.c +0
-0@@ -308,4 +308,9 @@ struct smp_ops_t core99_smp_ops __pmacdata =3D{
Quoted 13 lines
Quoted 13 lines
arch/ppc64/kernel/pmac_smp.c +4
-0void __init pmac_setup_smp (void ) { smp_ops =3D &core99_smp_ops; +#ifdef CONFIG_HOTPLUG_CPU + smp_ops->cpu_enable =3D generic_cpu_enable; + smp_ops->cpu_disable =3D generic_cpu_disable; + smp_ops->cpu_die =3D generic_cpu_die; #endif }arch/ppc64/kernel/setup.c +0
-0@@ -1377,9 +1377,6 @@ early_param("xmon", early_xmon);
Quoted 9 lines
Quoted 9 lines
arch/ppc64/kernel/smp.c =
Quoted 9 lines
arch/ppc64/kernel/setup.c +0
-3void cpu_die (void ) { -idle_task_exit ();if (ppc_md.cpu_die) ppc_md.cpu_die (); -local_irq_disable (); -for (;;); }arch/ppc64/kernel/smp.c = renamed from arch/ppc64/kernel/smp.c +0
-0
index
Quoted 161 lines
Quoted 118 lines
Quoted 118 lines
a9e43792f8fe..cde1947432a1100644arch/ppc64/kernel/smp.c +76
-0@@ -30,6 +30,7 @@#include <linux/err.h> #include <linux/sysdev.h> #include <linux/cpu.h> +#include <linux/notifier.h> #include <asm/ptrace.h> #include <asm/atomic.h> @@ -406,10 +407,89 @@ void __devinit smp_prepare_boot_cpu(void) current_set[boot_cpuid] =3D current->thread_info; } +#ifdef CONFIG_HOTPLUG_CPU +/* State of each CPU during hotplug phases */ DEFINE_PER_CPU (int, +cpu_state) =3D { 0 }; + +int generic_cpu_disable (void ) +{ + unsigned int cpu =3D smp_processor_id(); + + if (cpu =3D=3D boot_cpuid) +return -EBUSY ; + + systemcfg->processorCount--; +cpu_clear (cpu, cpu_online_map); +fixup_irqs (cpu_online_map); +return 0 ; +} + +int generic_cpu_enable (unsigned int cpu) { +/* Do the normal bootup if we haven't +* already bootstrapped. */ + if (system_state !=3D SYSTEM_RUNNING) +return -ENOSYS ; + +/* get the target out of it's holding state */ + per_cpu(cpu_state, cpu) =3D CPU_UP_PREPARE; +wmb (); + +while (!cpu_online (cpu)) +cpu_relax (); + +fixup_irqs (cpu_online_map); +/* counter the irq disable in fixup_irqs */ +local_irq_enable (); +return 0 ; +} + +void generic_cpu_die (unsigned int cpu) { +int i; + + for (i =3D 0; i < 100; i++) { +rmb (); + if (per_cpu(cpu_state, cpu) =3D=3D CPU_DEAD) +return ; +msleep (100 ); + } +printk (KERN_ERR "CPU%d didn't die...\n" , cpu); } + +void generic_mach_cpu_die (void ) +{ +unsigned int cpu; + +local_irq_disable (); + cpu =3D smp_processor_id(); +printk (KERN_DEBUG "CPU%d offline\n" , cpu); + __get_cpu_var(cpu_state) =3D CPU_DEAD; +wmb (); + while (__get_cpu_var(cpu_state) !=3D CPU_UP_PREPARE) +cpu_relax (); + +flush_tlb_pending (); +cpu_set (cpu, cpu_online_map); +local_irq_enable (); +} +#endif + +static int __devinit cpu_enable (unsigned int cpu) { +if (smp_ops->cpu_enable) +return smp_ops->cpu_enable (cpu); + +return -ENOSYS ; +} +int __devinit __cpu_up (unsigned int cpu) {int c; +if (!cpu_enable (cpu)) +return 0 ; +/* At boot, don't bother with non-present cpus -JSCHOPP */ if (system_state <SYSTEM_RUNNING && !cpu_present (cpu))return -ENOENT ;arch/ppc64/kernel/sysfs.c +2
-4@@ -18,7 +18,7 @@#include <asm/systemcfg.h> #include <asm/paca.h> #include <asm/lppaca.h> - +#include <asm/machdep.h> static DEFINE_PER_CPU(struct cpu, cpu_devices);@@ -413,9 +413,7 @@ static int __init topology_init(void)* CPU. For instance, the boot cpu might never be valid * for hotplugging. */ -#ifdef CONFIG_HOTPLUG_CPU - if (systemcfg->platform !=3D PLATFORM_PSERIES_LPAR) -#endif +if (!ppc_md.cpu_die) c->no_control =3D 1;Quoted 2 lines
Quoted 2 lines
arch/ppc64/kernel/sysfs.c +0
-0if (cpu_online(cpu) || (c->no_control =3D=3D 0)) { diff --git
a/include/asm-ppc64/machdep.hb/include/asm-ppc64/machdep.hindex
Quoted 40 lines
Quoted 40 lines
476d2185ffd1..03fe499c7604100644include/asm-ppc64/machdep.h +1
-0@@ -30,6 +30,7 @@ struct smp_ops_t {void (*setup_cpu)(int nr);void (*take_timebase)(void );void (*give_timebase)(void ); +int (*cpu_enable)(unsigned int nr);int (*cpu_disable)(void ); void (*cpu_die)(unsigned int nr); }; diff --git
a/include/asm-ppc64/smp.hb/include/asm-ppc64/smp.hindex965980bbbb57..c8646fa999c2100644include/asm-ppc64/smp.h +1
-1@@ -29,7 +29,7 @@extern int boot_cpuid;extern int boot_cpuid_phys; -extern void cpu_die (void ) __attribute__((noreturn)); +extern void cpu_die (void );#ifdef CONFIG_SMP @@ -37,6 +37,13 @@ extern void smp_send_debugger_break(int cpu);struct
pt_regs; extern voidsmp_message_recv(int, struct pt_regs *);include/asm-ppc64/smp.h +5
-0+#ifdef CONFIG_HOTPLUG_CPU +extern void fixup_irqs (cpumask_t map);int +generic_cpu_disable (void );int generic_cpu_enable (unsigned int +cpu);void generic_cpu_die (unsigned int cpu);void +generic_mach_cpu_die (void );#endif #define __smp_processor_id () (get_paca()->paca_index) #define
hard_smp_processor_id()(get_paca()->hw_cpu_id)_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Quoted 3 lines · Zhang Zhuoyu
Hi, Denis
Any test result on pmac machine for this patch?
Hi,
So I ran the tests by writing to cpuN/online.
with your change I'm observing lines like the following:
[ 713.436922] NOHZ: local_softirq_pending 08
Thanks!
Quoted 431 lines
Zhuoyu
Quoted 414 lines
-----Original Message-----
From: Zhang Zhuoyu [mailto:[email protected]]
Sent: Wednesday, December 16, 2015 10:46 PM
To: 'Denis Kirjanov'; 'Michael Ellerman'
Cc: 'Daniel Axtens'; 'Zhang Zhuoyu'; '[email protected]'; '[email protected]'; '[email protected]'; '[email protected]'; '[email protected]'; '[email protected]'
Subject: RE: [PATCH 1/1] powerpc/irq: tidy up inconsistent context inmigrate_irqs()Quoted 11 lines
-----Original Message-----
From: Denis Kirjanov [mailto:[email protected]]
Sent: Wednesday, December 16, 2015 7:55 PM
To: Michael Ellerman
Cc: Daniel Axtens; Zhang Zhuoyu; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH 1/1] powerpc/irq: tidy up inconsistent context inmigrate_irqs()Quoted 12 lines
Quoted 11 lines · Michael Ellerman
Quoted 10 lines · Daniel Axtens
Hi,
A couple of things.
Firstly, your two email addresses don't match:
Quoted 1 line · Zhang Zhuoyu
From: Zhang Zhuoyu <[email protected]>
Mmm, My mistake, I will correct it next time.
Quoted 19 lines
Quoted 19 lines
Quoted 5 lines
These lines do seem odd! Are they causing a problem?
I'd be more comfortable removing them if I understood why they were added. But they've been around since the beginning of git history so that could be a bit difficult.
It's in the fullhist tree, but that doesn't tell us much (below, named
fixup_irqs()).But I suspect those lines are actually there very deliberately.
The function is migrating interrupts off the recently offlined cpu, because we don't want to take interrupts on an offline cpu.
After it's finished doing the migration, it wants to make sure there are no interrupts that have already been latched by the offline cpu. So it briefly enables interrupts, waits a bit for the interrupts to fire, and the disables them again.
Quoted 7 lines
Quoted 3 lines
Whether that actually works I couldn't say, it is very old code, and it's used on platforms where I don't ever test cpu hotplug (85xx & powermac).
Yeah, it would be nice to test this change. I'll try it on my quad-core pmac machine
Thanks Michael for help explaining the code logic, it also resolved my doubts.
These snippets are suspected when I did PM benchmark on FSL MPC85xxseries(T1040, T4240), For T4240, which has 24 CPUs, it waits 1ms in migrate_irqs()each time a CPU is plugged offline, it seems a waste of time. I
also did a test on T1040, after plugging offline/online CPU hundreds of times,
system works well. If you have any other suggestion on how to test, I'd like
to do more benchmark.
(1)for((i=0; i<1000; i++)); do echo 0 >/sys/devices/system/cpu/cpu1/online;
sleep 1; echo 1 >/sys/devices/system/cpu/cpu1/online; done(2)root@t1040rdb:~# cat /proc/interrupts CPU0 CPU1 CPU2 CPU3 36: 393 1 223 1 OpenPIC 36 Level serial LOC: 1946 1486 1555 1361 Local timer interrupts DBL: 7371 9707 9390 7568 Doorbell interrupts (3)root@t1040rdb:~# ps PID TTY TIME CMD 2751 ttyS0 00:00:00 sh 2757 ttyS0 00:00:00 ps root@t1040rdb:~# taskset -pc 1 2751 pid 2751's current affinity list: 0-3 pid 2751's new affinity list: 1 root@t1040rdb:~# root@t1040rdb:~# root@t1040rdb:~# root@t1040rdb:~# echo "hello" hello root@t1040rdb:~#Quoted 136 lines
Quoted 29 lines
cheers
commit
d58830b9a740ad1c3b089196d4afdaea251dc701Author: Zwane Mwaikambo <[email protected]> Date: Fri Mar 4 17:34:00 2005 -0800[PATCH] ppc64: generic hotplug cpu support
Patch provides a generic hotplug cpu implementation, with the
only current
user being pmac. This doesn't replace real hotplug code as is
currently
used by LPAR systems. Ben i can add the additional pmac
specific code to
put the processor into a sleeping state seperately. Thanks to
Nathan for
testing.Signed-off-by Zwane Mwaikambo <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Linus Torvalds <[email protected]>arch/ppc64/Kconfig index renamed from arch/ppc64/Kconfig +0
-0
a7933ab62e98..861f4460ad02100644arch/ppc64/Kconfig source "drivers/pci/Kconfig" · line 316
Quoted 5 lines
arch/ppc64/Kconfig +1
-1@@ -313,7 +313,7 @@ source "drivers/pci/Kconfig" config HOTPLUG_CPU bool "Support for hot-pluggable CPUs" - depends on SMP && EXPERIMENTAL && PPC_PSERIES + depends on SMP && EXPERIMENTAL && (PPC_PSERIES ||
PPC_PMAC)Quoted 64 lines
arch/ppc64/Kconfig +0
-0select HOTPLUG ---help--- Say Y here to be able to turn CPUs off and on.arch/ppc64/kernel/idle.c +4
-0@@ -293,6 +293,10 @@ static int native_idle(void)power4_idle ();if (need_resched ())schedule (); + +if (cpu_is_offline (smp_processor_id ()) && + system_state ==SYSTEM_RUNNING ) +cpu_die (); }return 0 ; }arch/ppc64/kernel/irq.c index renamed from arch/ppc64/kernel/irq.c +0
-0
0ea8016146a2..4fd7f203c1e3100644arch/ppc64/kernel/irq.c +29
-0@@ -116,6 +116,35 @@ skip:return 0 ; } +#ifdef CONFIG_HOTPLUG_CPU +void fixup_irqs (cpumask_t map) +{ +unsigned int irq; +static int warned; + +for_each_irq (irq) { +cpumask_t mask; + +if (irq_desc[irq].status &IRQ_PER_CPU ) +continue ; + +cpus_and (mask, irq_affinity[irq], map); +if (any_online_cpu (mask) ==NR_CPUS ) { +printk ("Breaking affinity for irq %i\n" , irq); + mask = map; + } +if (irq_desc[irq].handler->set_affinity) + irq_desc[irq].handler->set_affinity (irq, mask); +else if (irq_desc[irq].action && !(warned++)) +printk ("Cannot set affinity for irq %i\n" , irq); + } + +local_irq_enable (); +mdelay (1 ); +local_irq_disable (); +} +#endif +extern int noirqdebug;/* arch/ppc64/kernel/pSeries_setup.c +0
-0arch/ppc64/kernel/pSeries_setup.c static void __init pSeries_discover_pic(void) · line 327
Quoted 9 lines
arch/ppc64/kernel/pSeries_setup.c +2
-1@@ -320,8 +320,9 @@ static void __init pSeries_discover_pic(void) } } -static void pSeries_cpu_die (void ) +static void pSeries_mach_cpu_die (void ) { +idle_task_exit ();local_irq_disable ();/* Some hardware requires clearing the CPPR, while other hardware does not
Quoted 25 lines
arch/ppc64/kernel/pSeries_setup.c +1
-1* it is safe either way @@ -599,7 +600,7 @@ struct machdep_calls __initdata pSeries_md = { .power_off = rtas_power_off, .halt = rtas_halt, .panic = rtas_os_term, - .cpu_die = pSeries_cpu_die, + .cpu_die = pSeries_mach_cpu_die, .get_boot_time = pSeries_get_boot_time, .get_rtc_time = pSeries_get_rtc_time, .set_rtc_time = pSeries_set_rtc_time,(quoted diff) +0
-0
b/arch/ppc64/kernel/pmac_setup.cindex41fa6e95a06f..5c56fc956245100644arch/ppc64/kernel/pmac_setup.c +3
-0@@ -439,6 +439,9 @@ static int __init pmac_probe(int platform) }struct machdep_calls __initdata pmac_md = { +#ifdef CONFIG_HOTPLUG_CPU + .cpu_die = generic_mach_cpu_die, +#endif .probe = pmac_probe, .setup_arch = pmac_setup_arch, .init_early = pmac_init_early,(quoted diff) +0
-0Quoted 1 line
b/arch/ppc64/kernel/pmac_smp.cindexe0b37079943c..c27588ede2fe100644
Quoted 3 lines
arch/ppc64/kernel/pmac_smp.c struct smp_ops_t core99_smp_ops __pmacdata =
Quoted 3 lines
arch/ppc64/kernel/pmac_smp.c +0
-0@@ -308,4 +308,9 @@ struct smp_ops_t core99_smp_ops __pmacdata ={
Quoted 140 lines
Quoted 140 lines
arch/ppc64/kernel/pmac_smp.c +4
-0void __init pmac_setup_smp (void ) { smp_ops = &core99_smp_ops; +#ifdef CONFIG_HOTPLUG_CPU + smp_ops->cpu_enable = generic_cpu_enable; + smp_ops->cpu_disable = generic_cpu_disable; + smp_ops->cpu_die = generic_cpu_die;#endif }arch/ppc64/kernel/setup.c +0
-3@@ -1377,9 +1377,6 @@ early_param("xmon", early_xmon);void cpu_die (void ) { -idle_task_exit ();if (ppc_md.cpu_die) ppc_md.cpu_die (); -local_irq_disable (); -for (;;); }arch/ppc64/kernel/smp.c index renamed from arch/ppc64/kernel/smp.c +0
-0
a9e43792f8fe..cde1947432a1100644arch/ppc64/kernel/smp.c +76
-0@@ -30,6 +30,7 @@#include <linux/err.h> #include <linux/sysdev.h> #include <linux/cpu.h> +#include <linux/notifier.h> #include <asm/ptrace.h> #include <asm/atomic.h> @@ -406,10 +407,89 @@ void __devinit smp_prepare_boot_cpu(void) current_set[boot_cpuid] = current->thread_info; } +#ifdef CONFIG_HOTPLUG_CPU +/* State of each CPU during hotplug phases */ DEFINE_PER_CPU (int, +cpu_state) = { 0 }; + +int generic_cpu_disable (void ) +{ +unsigned int cpu =smp_processor_id (); + +if (cpu == boot_cpuid) +return -EBUSY ; + + systemcfg->processorCount--; +cpu_clear (cpu, cpu_online_map); +fixup_irqs (cpu_online_map); +return 0 ; +} + +int generic_cpu_enable (unsigned int cpu) { +/* Do the normal bootup if we haven't +* already bootstrapped. */ +if (system_state !=SYSTEM_RUNNING ) +return -ENOSYS ; + +/* get the target out of it's holding state */ +per_cpu (cpu_state, cpu) =CPU_UP_PREPARE ; +wmb (); + +while (!cpu_online (cpu)) +cpu_relax (); + +fixup_irqs (cpu_online_map); +/* counter the irq disable in fixup_irqs */ +local_irq_enable (); +return 0 ; +} + +void generic_cpu_die (unsigned int cpu) { +int i; + +for (i =0 ; i <100 ; i++) { +rmb (); +if (per_cpu (cpu_state, cpu) ==CPU_DEAD ) +return ; +msleep (100 ); + } +printk (KERN_ERR "CPU%d didn't die...\n" , cpu); } + +void generic_mach_cpu_die (void ) +{ +unsigned int cpu; + +local_irq_disable (); + cpu =smp_processor_id (); +printk (KERN_DEBUG "CPU%d offline\n" , cpu); +__get_cpu_var (cpu_state) =CPU_DEAD ; +wmb (); +while (__get_cpu_var (cpu_state) !=CPU_UP_PREPARE ) +cpu_relax (); + +flush_tlb_pending (); +cpu_set (cpu, cpu_online_map); +local_irq_enable (); +} +#endif + +static int __devinit cpu_enable (unsigned int cpu) { +if (smp_ops->cpu_enable) +return smp_ops->cpu_enable (cpu); + +return -ENOSYS ; +} +int __devinit __cpu_up (unsigned int cpu) {int c; +if (!cpu_enable (cpu)) +return 0 ; +/* At boot, don't bother with non-present cpus -JSCHOPP */ if (system_state <SYSTEM_RUNNING && !cpu_present (cpu))return -ENOENT ;arch/ppc64/kernel/sysfs.c +2
-4@@ -18,7 +18,7 @@#include <asm/systemcfg.h> #include <asm/paca.h> #include <asm/lppaca.h> - +#include <asm/machdep.h> static DEFINE_PER_CPU(struct cpu, cpu_devices);@@ -413,9 +413,7 @@ static int __init topology_init(void)* CPU. For instance, the boot cpu might never be valid * for hotplugging. */ -#ifdef CONFIG_HOTPLUG_CPU - if (systemcfg->platform != PLATFORM_PSERIES_LPAR) -#endif +if (!ppc_md.cpu_die) c->no_control =1 ;Quoted 2 lines
Quoted 2 lines
arch/ppc64/kernel/sysfs.c +0
-0if (cpu_online(cpu) || (c->no_control == 0)) { diff --git
a/include/asm-ppc64/machdep.hb/include/asm-ppc64/machdep.hindex
Quoted 33 lines
Quoted 33 lines
476d2185ffd1..03fe499c7604100644include/asm-ppc64/machdep.h +1
-0@@ -30,6 +30,7 @@ struct smp_ops_t {void (*setup_cpu)(int nr);void (*take_timebase)(void );void (*give_timebase)(void ); +int (*cpu_enable)(unsigned int nr);int (*cpu_disable)(void ); void (*cpu_die)(unsigned int nr); }; diff --git
a/include/asm-ppc64/smp.hb/include/asm-ppc64/smp.hindex965980bbbb57..c8646fa999c2100644include/asm-ppc64/smp.h +1
-1@@ -29,7 +29,7 @@extern int boot_cpuid;extern int boot_cpuid_phys; -extern void cpu_die (void ) __attribute__((noreturn)); +extern void cpu_die (void );#ifdef CONFIG_SMP @@ -37,6 +37,13 @@ extern void smp_send_debugger_break(int cpu);struct
pt_regs; extern voidsmp_message_recv(int, struct pt_regs *);include/asm-ppc64/smp.h +5
-0+#ifdef CONFIG_HOTPLUG_CPU +extern void fixup_irqs (cpumask_t map);int +generic_cpu_disable (void );int generic_cpu_enable (unsigned int +cpu);void generic_cpu_die (unsigned int cpu);void +generic_mach_cpu_die (void );#endif Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
#define
__smp_processor_id()(get_paca()->paca_index) #definehard_smp_processor_id()(get_paca()->hw_cpu_id)_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
Quoted 7 lines
-----Original Message-----
From: Denis Kirjanov [mailto:[email protected]]
Sent: Thursday, December 24, 2015 6:04 AM
To: Zhang Zhuoyu <[email protected]>
Cc: Michael Ellerman <[email protected]>; =
Quoted 11 lines
[email protected]; [email protected]; [email protected]; [email protected]; Daniel Axtens <[email protected]>
Subject: Re: [PATCH 1/1] powerpc/irq: tidy up inconsistent context inmigrate_irqs()
=20Quoted 5 lines · Denis Kirjanov
Quoted 3 lines · Zhang Zhuoyu
Hi, Denis
Any test result on pmac machine for this patch?
Quoted 7 lines
Quoted 6 lines
Hi,
So I ran the tests by writing to cpuN/online.
with your change I'm observing lines like the following:
[ 713.436922] NOHZ: local_softirq_pending 08=20
Hi,=20
It is a NOHZ warning, NOHZ will check for whether there are softirqs = pending when an online CPU goes
idle, this warning cannot be triggered by offlining CPU, you should = check which driver's
softirq is preventing CPU goes idle.
Quoted 2 lines
Another bad thing that the current powerpc/next kernel crashed on pmac (without this change) while enabling/disabling cpu cores :/ I've =
attached the
Quoted 16 lines
screenshot
=20
=20Quoted 13 lines
Thanks!
Quoted 10 lines
Zhuoyu
Quoted 7 lines
-----Original Message-----
From: Zhang Zhuoyu [mailto:[email protected]]
Sent: Wednesday, December 16, 2015 10:46 PM
To: 'Denis Kirjanov'; 'Michael Ellerman'
Cc: 'Daniel Axtens'; 'Zhang Zhuoyu'; '[email protected]'; '[email protected]'; '[email protected]'; '[email protected]'; '[email protected]'; =
'linux-
Quoted 15 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Subject: RE: [PATCH 1/1] powerpc/irq: tidy up inconsistent context in
migrate_irqs()Quoted 9 lines
-----Original Message-----
From: Denis Kirjanov [mailto:[email protected]]
Sent: Wednesday, December 16, 2015 7:55 PM
To: Michael Ellerman
Cc: Daniel Axtens; Zhang Zhuoyu; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH 1/1] powerpc/irq: tidy up inconsistent =
context
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
in
migrate_irqs()Quoted 9 lines · Michael Ellerman
Quoted 7 lines · Daniel Axtens
Hi,
A couple of things.
Firstly, your two email addresses don't match:
Zhang Zhuoyu <[email protected]> writes:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
From: Zhang Zhuoyu <[email protected]>
Mmm, My mistake, I will correct it next time.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
These lines do seem odd! Are they causing a problem?
I'd be more comfortable removing them if I understood why =
they
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
were added. But they've been around since the beginning of =
git
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
history so that could be a bit difficult.
It's in the fullhist tree, but that doesn't tell us much =
(below,
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
named
fixup_irqs()).But I suspect those lines are actually there very =
deliberately.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
The function is migrating interrupts off the recently offlined cpu, because we don't want to take interrupts on an offline =
cpu.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
After it's finished doing the migration, it wants to make sure there are no interrupts that have already been latched by the =
offline
Quoted 2 lines
cpu.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
So it briefly enables interrupts, waits a bit for the =
interrupts
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
to fire, and the disables them again.
Whether that actually works I couldn't say, it is very old =
code,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
and it's used on platforms where I don't ever test cpu hotplug (85xx & powermac).
Yeah, it would be nice to test this change. I'll try it on my quad-core pmac machine
Thanks Michael for help explaining the code logic, it also =
resolved
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
my doubts.
These snippets are suspected when I did PM benchmark on FSLMPC85xx
Quoted 1 line
Quoted 1 line
Quoted 1 line
series(T1040, T4240), For T4240, which has 24 CPUs, it waits 1ms =
in
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
migrate_irqs()each time a CPU is plugged offline, it seems a waste of time. I also did a test on T1040, after plugging offline/online CPU hundreds of times, system works well. If you have any other suggestion on how to test, I'd like to do more benchmark. (1)for((i=3D0; i<1000; i++)); do echo 0 >
/sys/devices/system/cpu/cpu1/online;
sleep 1; echo 1 >/sys/devices/system/cpu/cpu1/online; done(2)root@t1040rdb:~# cat /proc/interrupts CPU0 CPU1 CPU2 CPU3 36: 393 1 223 1 OpenPIC 36 =
Level
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
serial
LOC: 1946 1486 1555 1361 Local timer
interrupts
DBL: 7371 9707 9390 7568 Doorbell =
interrupts
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
(3)root@t1040rdb:~# ps PID TTY TIME CMD 2751 ttyS0 00:00:00 sh 2757 ttyS0 00:00:00 ps root@t1040rdb:~# taskset -pc 1 2751 pid 2751's current affinity list: 0-3 pid 2751's new affinity =
list:
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
1 root@t1040rdb:~# root@t1040rdb:~# root@t1040rdb:~#
root@t1040rdb:~# echo "hello" hello root@t1040rdb:~#Quoted 8 lines
Quoted 8 lines
cheers
commit
d58830b9a740ad1c3b089196d4afdaea251dc701Author: Zwane Mwaikambo <[email protected]> Date: Fri Mar 4 17:34:00 2005 -0800
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
[PATCH] ppc64: generic hotplug cpu support
Patch provides a generic hotplug cpu implementation, with
the only current
user being pmac. This doesn't replace real hotplug code =
as
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
is currently
used by LPAR systems. Ben i can add the additional pmac
specific code to
put the processor into a sleeping state seperately. =
Thanks
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 12 lines
to Nathan for
testing.Signed-off-by Zwane Mwaikambo <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Linus Torvalds <[email protected]>arch/ppc64/Kconfig index renamed from arch/ppc64/Kconfig +0
-0
a7933ab62e98..861f4460ad02100644arch/ppc64/Kconfig source "drivers/pci/Kconfig" · line 316
Quoted 5 lines
arch/ppc64/Kconfig +1
-1@@ -313,7 +313,7 @@ source "drivers/pci/Kconfig" config HOTPLUG_CPU bool "Support for hot-pluggable CPUs" - depends on SMP && EXPERIMENTAL && PPC_PSERIES + depends on SMP && EXPERIMENTAL && (PPC_PSERIES ||
PPC_PMAC)
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
=
Quoted 4 lines
arch/ppc64/Kconfig +0
-0select HOTPLUG ---help--- Say Y here to be able to turn CPUs off and on.= renamed from arch/ppc64/kernel/idle.c +0
-0
b/arch/ppc64/kernel/idle.c
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
index
398b4682127b..51eb6af14a8f100644arch/ppc64/kernel/idle.c +4
-0@@ -293,6 +293,10 @@ static int native_idle(void)power4_idle ();if (need_resched ())schedule (); + +if (cpu_is_offline (smp_processor_id ()) && + system_state =3D=3D SYSTEM_RUNNING) +cpu_die (); }return 0 ; }arch/ppc64/kernel/irq.c +0
-0index
0ea8016146a2..4fd7f203c1e3100644arch/ppc64/kernel/irq.c +29
-0@@ -116,6 +116,35 @@ skip:return 0 ; } +#ifdef CONFIG_HOTPLUG_CPU +void fixup_irqs (cpumask_t map) +{ +unsigned int irq; +static int warned; + +for_each_irq (irq) { +cpumask_t mask; + +if (irq_desc[irq].status &IRQ_PER_CPU ) +continue ; + +cpus_and (mask, irq_affinity[irq], map); + if (any_online_cpu(mask) =3D=3D NR_CPUS) { +printk ("Breaking affinity for irq %i\n" , irq); + mask =3D map; + } +if (irq_desc[irq].handler->set_affinity) + irq_desc[irq].handler->set_affinity (irq, mask); +else if (irq_desc[irq].action && !(warned++)) +printk ("Cannot set affinity for irq %i\n" , irq); + } + +local_irq_enable (); +mdelay (1 ); +local_irq_disable (); +} +#endif +extern int noirqdebug;
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
arch/ppc64/kernel/pSeries_setup.c static void __init =
Quoted 7 lines
arch/ppc64/kernel/irq.c +0
-0/* arch/ppc64/kernel/pSeries_setup.c +0
-0@@ -320,8 +320,9 @@ static void __init =
pSeries_discover_pic(void)
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
arch/ppc64/kernel/pSeries_setup.c +2
-1} } -static void pSeries_cpu_die (void ) +static void pSeries_mach_cpu_die (void ) { +idle_task_exit ();local_irq_disable ();/* Some hardware requires clearing the CPPR, while other hardware
does not
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
arch/ppc64/kernel/pSeries_setup.c struct machdep_calls __initdata pSeries_md =
Quoted 2 lines
arch/ppc64/kernel/pSeries_setup.c +0
-0* it is safe either way @@ -599,7 +600,7 @@ struct machdep_calls __initdata pSeries_md =
=3D
Quoted 179 lines
{
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
arch/ppc64/kernel/pSeries_setup.c +1
-1.power_off =3D rtas_power_off, .halt =3D rtas_halt, .panic =3D rtas_os_term, - .cpu_die =3D pSeries_cpu_die, + .cpu_die =3D pSeries_mach_cpu_die, .get_boot_time =3D pSeries_get_boot_time, .get_rtc_time =3D pSeries_get_rtc_time, .set_rtc_time =3D pSeries_set_rtc_time,(quoted diff) +0
-0
b/arch/ppc64/kernel/pmac_setup.cindex41fa6e95a06f..5c56fc956245
100644arch/ppc64/kernel/pmac_setup.c +0
-0@@ -439,6 +439,9 @@ static int __init pmac_probe(int platform) }Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
arch/ppc64/kernel/pmac_setup.c +3
-0struct machdep_calls __initdata pmac_md =3D { +#ifdef CONFIG_HOTPLUG_CPU + .cpu_die =3D generic_mach_cpu_die, +#endif .probe =3D pmac_probe, .setup_arch =3D pmac_setup_arch, .init_early =3D pmac_init_early,(quoted diff) +0
-0
b/arch/ppc64/kernel/pmac_smp.cindex
e0b37079943c..c27588ede2feQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
100644
arch/ppc64/kernel/pmac_smp.c struct smp_ops_t core99_smp_ops
Quoted 3 lines
arch/ppc64/kernel/pmac_smp.c +0
-0@@ -308,4 +308,9 @@ struct smp_ops_t core99_smp_ops
__pmacdata=3DQuoted 34 lines
Quoted 34 lines
Quoted 34 lines
{
Quoted 33 lines
Quoted 33 lines
arch/ppc64/kernel/pmac_smp.c +4
-0void __init pmac_setup_smp (void ) { smp_ops =3D &core99_smp_ops; +#ifdef CONFIG_HOTPLUG_CPU + smp_ops->cpu_enable =3D generic_cpu_enable; + smp_ops->cpu_disable =3D generic_cpu_disable; + smp_ops->cpu_die =3D generic_cpu_die; #endif }(quoted diff) +0
-0
b/arch/ppc64/kernel/setup.cindexd98c320828e5..078c3551ce8a100644arch/ppc64/kernel/setup.c +0
-3@@ -1377,9 +1377,6 @@ early_param("xmon", early_xmon);void cpu_die (void ) { -idle_task_exit ();if (ppc_md.cpu_die) ppc_md.cpu_die (); -local_irq_disable (); -for (;;); }arch/ppc64/kernel/smp.c +0
-0index
a9e43792f8fe..cde1947432a1100644arch/ppc64/kernel/smp.c +1
-0@@ -30,6 +30,7 @@#include <linux/err.h> #include <linux/sysdev.h> #include <linux/cpu.h> +#include <linux/notifier.h> Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
arch/ppc64/kernel/smp.c void __devinit
Quoted 3 lines
arch/ppc64/kernel/smp.c +0
-0#include <asm/ptrace.h> #include <asm/atomic.h> @@ -406,10 +407,89 @@ void __devinit
smp_prepare_boot_cpu(void)Quoted 95 lines
Quoted 95 lines
Quoted 95 lines
Quoted 95 lines
Quoted 95 lines
arch/ppc64/kernel/smp.c +75
-0current_set[boot_cpuid] =3D current->thread_info; } +#ifdef CONFIG_HOTPLUG_CPU +/* State of each CPU during hotplug phases */ +DEFINE_PER_CPU (int, +cpu_state) =3D { 0 }; + +int generic_cpu_disable (void ) +{ + unsigned int cpu =3D smp_processor_id(); + + if (cpu =3D=3D boot_cpuid) +return -EBUSY ; + + systemcfg->processorCount--; +cpu_clear (cpu, cpu_online_map); +fixup_irqs (cpu_online_map); +return 0 ; +} + +int generic_cpu_enable (unsigned int cpu) { +/* Do the normal bootup if we haven't +* already bootstrapped. */ + if (system_state !=3D SYSTEM_RUNNING) +return -ENOSYS ; + +/* get the target out of it's holding state */ + per_cpu(cpu_state, cpu) =3D CPU_UP_PREPARE; +wmb (); + +while (!cpu_online (cpu)) +cpu_relax (); + +fixup_irqs (cpu_online_map); +/* counter the irq disable in fixup_irqs */ +local_irq_enable (); +return 0 ; +} + +void generic_cpu_die (unsigned int cpu) { +int i; + + for (i =3D 0; i < 100; i++) { +rmb (); + if (per_cpu(cpu_state, cpu) =3D=3D CPU_DEAD) +return ; +msleep (100 ); + } +printk (KERN_ERR "CPU%d didn't die...\n" , cpu); } + +void generic_mach_cpu_die (void ) { +unsigned int cpu; + +local_irq_disable (); + cpu =3D smp_processor_id(); +printk (KERN_DEBUG "CPU%d offline\n" , cpu); + __get_cpu_var(cpu_state) =3D CPU_DEAD; +wmb (); + while (__get_cpu_var(cpu_state) !=3D CPU_UP_PREPARE) +cpu_relax (); + +flush_tlb_pending (); +cpu_set (cpu, cpu_online_map); +local_irq_enable (); +} +#endif + +static int __devinit cpu_enable (unsigned int cpu) { +if (smp_ops->cpu_enable) +return smp_ops->cpu_enable (cpu); + +return -ENOSYS ; +} +int __devinit __cpu_up (unsigned int cpu) {int c; +if (!cpu_enable (cpu)) +return 0 ; +/* At boot, don't bother with non-present cpus -JSCHOPP */ if (system_state <SYSTEM_RUNNING && !cpu_present (cpu))return -ENOENT ;(quoted diff) +0
-0
b/arch/ppc64/kernel/sysfs.cindexbbc9dcda17f7..0925694c3ce5100644arch/ppc64/kernel/sysfs.c +1
-1@@ -18,7 +18,7 @@#include <asm/systemcfg.h> #include <asm/paca.h> #include <asm/lppaca.h> - +#include <asm/machdep.h> Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
arch/ppc64/kernel/sysfs.c static int __init topology_init(void) · line 413
Quoted 4 lines
arch/ppc64/kernel/sysfs.c +0
-0static DEFINE_PER_CPU(struct cpu, cpu_devices);@@ -413,9 +413,7 @@ static int __init topology_init(void)* CPU. For instance, the boot cpu might never be valid
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/ppc64/kernel/sysfs.c +1
-3* for hotplugging. */ -#ifdef CONFIG_HOTPLUG_CPU - if (systemcfg->platform !=3D PLATFORM_PSERIES_LPAR) -#endif +if (!ppc_md.cpu_die) c->no_control =3D 1;
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
arch/ppc64/kernel/sysfs.c static int __init topology_init(void) · line 419
Quoted 1 line
arch/ppc64/kernel/sysfs.c +0
-0if (cpu_online(cpu) || (c->no_control =3D=3D 0)) { diff =
--git
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 1 line
Quoted 1 line
a/include/asm-ppc64/machdep.hb/include/asm-ppc64/machdep.hindex
Quoted 23 lines
Quoted 23 lines
476d2185ffd1..03fe499c7604100644include/asm-ppc64/machdep.h +1
-0@@ -30,6 +30,7 @@ struct smp_ops_t {void (*setup_cpu)(int nr);void (*take_timebase)(void );void (*give_timebase)(void ); +int (*cpu_enable)(unsigned int nr);int (*cpu_disable)(void ); void (*cpu_die)(unsigned int nr); }; diff --git
a/include/asm-ppc64/smp.hb/include/asm-ppc64/smp.hindex965980bbbb57..c8646fa999c2100644include/asm-ppc64/smp.h +1
-1@@ -29,7 +29,7 @@extern int boot_cpuid;extern int boot_cpuid_phys; -extern void cpu_die (void ) __attribute__((noreturn)); +extern void cpu_die (void );#ifdef CONFIG_SMP
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/asm-ppc64/smp.h extern void smp_send_debugger_break(int
Quoted 1 line
include/asm-ppc64/smp.h +0
-0@@ -37,6 +37,13 @@ extern void smp_send_debugger_break(intcpu);
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
include/asm-ppc64/smp.h
Quoted 6 lines
struct
pt_regs; extern voidsmp_message_recv(int, struct pt_regs *);include/asm-ppc64/smp.h +3
-0+#ifdef CONFIG_HOTPLUG_CPU +extern void fixup_irqs (cpumask_t map);int +generic_cpu_disable(void); int generic_cpu_enable(unsigned =
int
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
include/asm-ppc64/smp.h
Quoted 4 lines
include/asm-ppc64/smp.h +2
-0+cpu); void generic_cpu_die(unsigned int cpu); void +generic_mach_cpu_die (void );#endif #define __smp_processor_id () (get_paca()->paca_index) =
#define
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
hard_smp_processor_id()(get_paca()->hw_cpu_id)_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev