live partition migration vs cacheinfo
cover live partition migration vs cacheinfo
Partition migration often results in the platform telling the OS to replace all the cache nodes in the device tree. The cacheinfo code has no knowledge of this, and continues to maintain references to the deleted/detached nodes, causing subsequent CPU online/offline operations to get warnings and oopses. This series addresses this longstanding issue by providing an interface to the cacheinfo layer that the migration code uses to rebuild the cacheinfo data structures at a safe time after migration, with appropriate serialization vs CPU hotplug.
Nathan Lynch (3):
powerpc/cacheinfo: add cacheinfo_teardown, cacheinfo_rebuild powerpc/pseries/mobility: prevent cpu hotplug during DT update powerpc/pseries/mobility: rebuild cacheinfo hierarchy post-migration
arch/powerpc/kernel/cacheinfo.c | 21 +++++++++++++++++++++ arch/powerpc/kernel/cacheinfo.h | 4 ++++ arch/powerpc/platforms/pseries/mobility.c | 19 +++++++++++++++++++ 3 files changed, 44 insertions(+)
Signature · 1 line
2.20.1
PATCH 1/3 powerpc/cacheinfo: add cacheinfo_teardown, cacheinfo_rebuild
Allow external callers to force the cacheinfo code to release all its references to cache nodes, e.g. before processing device tree updates post-migration, and to rebuild the hierarchy afterward.
CPU online/offline must be blocked by callers; enforce this.
--- arch/powerpc/kernel/cacheinfo.c | 21 +++++++++++++++++++++ arch/powerpc/kernel/cacheinfo.h | 4 ++++ 2 files changed, 25 insertions(+)
arch/powerpc/kernel/cacheinfo.c +21 -0
@@ -896,4 +896,25 @@ void cacheinfo_cpu_offline(unsigned int cpu_id)if (cache) cache_cpu_clear(cache, cpu_id); } + +void cacheinfo_teardown (void ) +{ +unsigned int cpu; + +lockdep_assert_cpus_held (); + +for_each_online_cpu (cpu) +cacheinfo_cpu_offline (cpu); +} + +void cacheinfo_rebuild (void ) +{ +unsigned int cpu; + +lockdep_assert_cpus_held (); + +for_each_online_cpu (cpu) +cacheinfo_cpu_online (cpu); +} +#endif /* (CONFIG_PPC_PSERIES && CONFIG_SUSPEND) || CONFIG_HOTPLUG_CPU */
arch/powerpc/kernel/cacheinfo.h +4 -0
@@ -6,4 +6,8 @@extern void cacheinfo_cpu_online (unsigned int cpu_id);extern void cacheinfo_cpu_offline (unsigned int cpu_id); +/* Allow migration/suspend to tear down and rebuild the hierarchy. */ +extern void cacheinfo_teardown (void ); +extern void cacheinfo_rebuild (void ); +#endif /* _PPC_CACHEINFO_H */
Signature · 1 line
2.20.1
Re: [PATCH 1/3] powerpc/cacheinfo: add cacheinfo_teardown, cacheinfo_rebuild
Quoted 9 lines · Nathan Lynch
Allow external callers to force the cacheinfo code to release all its references to cache nodes, e.g. before processing device tree updates post-migration, and to rebuild the hierarchy afterward.
CPU online/offline must be blocked by callers; enforce this.
Fixes 410bccf97881 ("powerpc/pseries: Partition migration in the kernel")Signed-off-by Nathan Lynch <[email protected]>
Quoted 51 lines
--- arch/powerpc/kernel/cacheinfo.c | 21 +++++++++++++++++++++ arch/powerpc/kernel/cacheinfo.h | 4 ++++ 2 files changed, 25 insertions(+)arch/powerpc/kernel/cacheinfo.c +21
-0@@ -896,4 +896,25 @@ void cacheinfo_cpu_offline(unsigned int cpu_id)if (cache) cache_cpu_clear(cache, cpu_id); } + +void cacheinfo_teardown (void ) +{ +unsigned int cpu; + +lockdep_assert_cpus_held (); + +for_each_online_cpu (cpu) +cacheinfo_cpu_offline (cpu); +} + +void cacheinfo_rebuild (void ) +{ +unsigned int cpu; + +lockdep_assert_cpus_held (); + +for_each_online_cpu (cpu) +cacheinfo_cpu_online (cpu); +} +#endif /* (CONFIG_PPC_PSERIES && CONFIG_SUSPEND) || CONFIG_HOTPLUG_CPU */ arch/powerpc/kernel/cacheinfo.h +4
-1@@ -6,4 +6,8 @@extern void cacheinfo_cpu_online (unsigned int cpu_id);extern void cacheinfo_cpu_offline (unsigned int cpu_id); +/* Allow migration/suspend to tear down and rebuild the hierarchy. */ +extern void cacheinfo_teardown (void ); +extern void cacheinfo_rebuild (void ); +#endif /* _PPC_CACHEINFO_H */ --2.20.1
Signature · 2 lines
Thanks and Regards gautham.
Re: [PATCH 1/3] powerpc/cacheinfo: add cacheinfo_teardown, cacheinfo_rebuild
In reply to Nathan LynchQuoted 9 lines · Nathan Lynch
Allow external callers to force the cacheinfo code to release all its references to cache nodes, e.g. before processing device tree updates post-migration, and to rebuild the hierarchy afterward.
CPU online/offline must be blocked by callers; enforce this.
Fixes 410bccf97881 ("powerpc/pseries: Partition migration in the kernel")Signed-off-by Nathan Lynch <[email protected]>Reviewed-by Gautham R. Shenoy <[email protected]>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/d4aa219a074a5abaf95a756b9f0d190b
cheers
PATCH 2/3 powerpc/pseries/mobility: prevent cpu hotplug during DT update
In reply to Nathan LynchCPU online/offline code paths are sensitive to parts of the device tree (various cpu node properties, cache nodes) that can be changed as a result of a migration.
Prevent CPU hotplug while the device tree potentially is inconsistent.
--- arch/powerpc/platforms/pseries/mobility.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/powerpc/platforms/pseries/mobility.c +9 -0
@@ -9,6 +9,7 @@* 2 as published by the Free Software Foundation. */ +#include <linux/cpu.h> #include <linux/kernel.h> #include <linux/kobject.h> #include <linux/smp.h>
@@ -338,11 +339,19 @@ void post_mobility_fixup(void)if (rc)printk (KERN_ERR "Post-mobility activate-fw failed: %d\n" , rc); +/* +* We don't want CPUs to go online/offline while the device +* tree is being updated. +*/ +cpus_read_lock (); + rc =pseries_devicetree_update (MIGRATION_SCOPE );if (rc)printk (KERN_ERR "Post-mobility device tree update " "failed: %d\n" , rc); +cpus_read_unlock (); +/* Possibly switch to a new RFI flush type */ pseries_setup_rfi_flush ();
Signature · 1 line
2.20.1
Re: [PATCH 2/3] powerpc/pseries/mobility: prevent cpu hotplug during DT update
Hello Nathan,
Quoted 9 lines · Nathan Lynch
CPU online/offline code paths are sensitive to parts of the device tree (various cpu node properties, cache nodes) that can be changed as a result of a migration.
Prevent CPU hotplug while the device tree potentially is inconsistent.
Fixes 410bccf97881 ("powerpc/pseries: Partition migration in the kernel")Signed-off-by Nathan Lynch <[email protected]>
Audited the callbacks of of_reconfig_notify(). We are fine with respect to CPU-Hotplug locking.
Quoted 39 lines
--- arch/powerpc/platforms/pseries/mobility.c | 9 +++++++++ 1 file changed, 9 insertions(+)arch/powerpc/platforms/pseries/mobility.c +9
-1@@ -9,6 +9,7 @@* 2 as published by the Free Software Foundation. */ +#include <linux/cpu.h> #include <linux/kernel.h> #include <linux/kobject.h> #include <linux/smp.h> @@ -338,11 +339,19 @@ void post_mobility_fixup(void)if (rc)printk (KERN_ERR "Post-mobility activate-fw failed: %d\n" , rc); +/* +* We don't want CPUs to go online/offline while the device +* tree is being updated. +*/ +cpus_read_lock (); + rc =pseries_devicetree_update (MIGRATION_SCOPE );if (rc)printk (KERN_ERR "Post-mobility device tree update " "failed: %d\n" , rc); +cpus_read_unlock (); +/* Possibly switch to a new RFI flush type */ pseries_setup_rfi_flush (); --2.20.1
Signature · 2 lines
Thanks and Regards gautham.
PATCH 3/3 powerpc/pseries/mobility: rebuild cacheinfo hierarchy post-migration
In reply to Nathan LynchIt's common for the platform to replace the cache device nodes after a migration. Since the cacheinfo code is never informed about this, it never drops its references to the source system's cache nodes, causing it to wind up in an inconsistent state resulting in warnings and oopses as soon as CPU online/offline occurs after the migration, e.g.
cache for /cpus/l3-cache@3113(Unified) refers to cache for /cpus/l2-cache@200d(Unified)
WARNING: CPU: 15 PID: 86 at arch/powerpc/kernel/cacheinfo.c:176 release_cache+0x1bc/0x1d0 [...] NIP [c00000000002d9bc] release_cache+0x1bc/0x1d0 LR [c00000000002d9b8] release_cache+0x1b8/0x1d0 Call Trace: [c0000001fc99fa70] [c00000000002d9b8] release_cache+0x1b8/0x1d0 (unreliable) [c0000001fc99fb10] [c00000000002ebf4] cacheinfo_cpu_offline+0x1c4/0x2c0 [c0000001fc99fbe0] [c00000000002ae58] unregister_cpu_online+0x1b8/0x260 [c0000001fc99fc40] [c000000000165a64] cpuhp_invoke_callback+0x114/0xf40 [c0000001fc99fcd0] [c000000000167450] cpuhp_thread_fun+0x270/0x310 [c0000001fc99fd40] [c0000000001a8bb8] smpboot_thread_fn+0x2c8/0x390 [c0000001fc99fdb0] [c0000000001a1cd8] kthread+0x1b8/0x1c0 [c0000001fc99fe20] [c00000000000c2d4] ret_from_kernel_thread+0x5c/0x68
Using device tree notifiers won't work since we want to rebuild the hierarchy only after all the removals and additions have occurred and the device tree is in a consistent state. Call cacheinfo_teardown() before processing device tree updates, and rebuild the hierarchy afterward.
--- arch/powerpc/platforms/pseries/mobility.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/powerpc/platforms/pseries/mobility.c +10 -0
@@ -23,6 +23,7 @@#include <asm/machdep.h> #include <asm/rtas.h> #include "pseries.h" +#include "../../kernel/cacheinfo.h" static struct kobject *mobility_kobj;
@@ -345,11 +346,20 @@ void post_mobility_fixup(void)*/ cpus_read_lock (); +/* +* It's common for the destination firmware to replace cache +* nodes. Release all of the cacheinfo hierarchy's references +* before updating the device tree. +*/ +cacheinfo_teardown (); + rc =pseries_devicetree_update (MIGRATION_SCOPE );if (rc)printk (KERN_ERR "Post-mobility device tree update " "failed: %d\n" , rc); +cacheinfo_rebuild (); +cpus_read_unlock ();/* Possibly switch to a new RFI flush type */
Signature · 1 line
2.20.1
Re: [PATCH 3/3] powerpc/pseries/mobility: rebuild cacheinfo hierarchy post-migration
Quoted 22 lines · Nathan Lynch
It's common for the platform to replace the cache device nodes after a migration. Since the cacheinfo code is never informed about this, it never drops its references to the source system's cache nodes, causing it to wind up in an inconsistent state resulting in warnings and oopses as soon as CPU online/offline occurs after the migration, e.g.
cache for /cpus/l3-cache@3113(Unified) refers to cache for /cpus/l2-cache@200d(Unified)
WARNING: CPU: 15 PID: 86 at arch/powerpc/kernel/cacheinfo.c:176 release_cache+0x1bc/0x1d0 [...] NIP [c00000000002d9bc] release_cache+0x1bc/0x1d0 LR [c00000000002d9b8] release_cache+0x1b8/0x1d0 Call Trace: [c0000001fc99fa70] [c00000000002d9b8] release_cache+0x1b8/0x1d0 (unreliable) [c0000001fc99fb10] [c00000000002ebf4] cacheinfo_cpu_offline+0x1c4/0x2c0 [c0000001fc99fbe0] [c00000000002ae58] unregister_cpu_online+0x1b8/0x260 [c0000001fc99fc40] [c000000000165a64] cpuhp_invoke_callback+0x114/0xf40 [c0000001fc99fcd0] [c000000000167450] cpuhp_thread_fun+0x270/0x310 [c0000001fc99fd40] [c0000000001a8bb8] smpboot_thread_fn+0x2c8/0x390 [c0000001fc99fdb0] [c0000000001a1cd8] kthread+0x1b8/0x1c0 [c0000001fc99fe20] [c00000000000c2d4] ret_from_kernel_thread+0x5c/0x68
Quoted 8 lines
Using device tree notifiers won't work since we want to rebuild the hierarchy only after all the removals and additions have occurred and the device tree is in a consistent state. Call
cacheinfo_teardown()before processing device tree updates, and rebuild the hierarchy afterward.Fixes 410bccf97881 ("powerpc/pseries: Partition migration in the kernel")Signed-off-by Nathan Lynch <[email protected]>
Quoted 40 lines
--- arch/powerpc/platforms/pseries/mobility.c | 10 ++++++++++ 1 file changed, 10 insertions(+)arch/powerpc/platforms/pseries/mobility.c +10
-1@@ -23,6 +23,7 @@#include <asm/machdep.h> #include <asm/rtas.h> #include "pseries.h" +#include "../../kernel/cacheinfo.h" static struct kobject *mobility_kobj;@@ -345,11 +346,20 @@ void post_mobility_fixup(void)*/ cpus_read_lock (); +/* +* It's common for the destination firmware to replace cache +* nodes. Release all of the cacheinfo hierarchy's references +* before updating the device tree. +*/ +cacheinfo_teardown (); + rc =pseries_devicetree_update (MIGRATION_SCOPE );if (rc)printk (KERN_ERR "Post-mobility device tree update " "failed: %d\n" , rc); +cacheinfo_rebuild (); +cpus_read_unlock ();/* Possibly switch to a new RFI flush type */ --2.20.1
Signature · 2 lines
Thanks and Regards gautham.