Skip to content

Commit a6717c0

Browse files
nathanlynchmpe
authored andcommitted
powerpc/rtas: use device model APIs and serialization during LPM
The LPAR migration implementation and userspace-initiated cpu hotplug can interleave their executions like so: 1. Set cpu 7 offline via sysfs. 2. Begin a partition migration, whose implementation requires the OS to ensure all present cpus are online; cpu 7 is onlined: rtas_ibm_suspend_me -> rtas_online_cpus_mask -> cpu_up This sets cpu 7 online in all respects except for the cpu's corresponding struct device; dev->offline remains true. 3. Set cpu 7 online via sysfs. _cpu_up() determines that cpu 7 is already online and returns success. The driver core (device_online) sets dev->offline = false. 4. The migration completes and restores cpu 7 to offline state: rtas_ibm_suspend_me -> rtas_offline_cpus_mask -> cpu_down This leaves cpu7 in a state where the driver core considers the cpu device online, but in all other respects it is offline and unused. Attempts to online the cpu via sysfs appear to succeed but the driver core actually does not pass the request to the lower-level cpuhp support code. This makes the cpu unusable until the cpu device is manually set offline and then online again via sysfs. Instead of directly calling cpu_up/cpu_down, the migration code should use the higher-level device core APIs to maintain consistent state and serialize operations. Fixes: 120496a ("powerpc: Bring all threads online prior to migration/hibernation") Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com> Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20190802192926.19277-2-nathanl@linux.ibm.com
1 parent 415480d commit a6717c0

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎arch/powerpc/kernel/rtas.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,15 +871,17 @@ static int rtas_cpu_state_change_mask(enum rtas_cpu_state state,
871871
return 0;
872872

873873
for_each_cpu(cpu, cpus) {
874+
struct device *dev = get_cpu_device(cpu);
875+
874876
switch (state) {
875877
case DOWN:
876-
cpuret = cpu_down(cpu);
878+
cpuret = device_offline(dev);
877879
break;
878880
case UP:
879-
cpuret = cpu_up(cpu);
881+
cpuret = device_online(dev);
880882
break;
881883
}
882-
if (cpuret) {
884+
if (cpuret < 0) {
883885
pr_debug("%s: cpu_%s for cpu#%d returned %d.\n",
884886
__func__,
885887
((state == UP) ? "up" : "down"),
@@ -966,6 +968,8 @@ int rtas_ibm_suspend_me(u64 handle)
966968
data.token = rtas_token("ibm,suspend-me");
967969
data.complete = &done;
968970

971+
lock_device_hotplug();
972+
969973
/* All present CPUs must be online */
970974
cpumask_andnot(offline_mask, cpu_present_mask, cpu_online_mask);
971975
cpuret = rtas_online_cpus_mask(offline_mask);
@@ -1004,6 +1008,7 @@ int rtas_ibm_suspend_me(u64 handle)
10041008
__func__);
10051009

10061010
out:
1011+
unlock_device_hotplug();
10071012
free_cpumask_var(offline_mask);
10081013
return atomic_read(&data.error);
10091014
}

0 commit comments

Comments
 (0)