Skip to content

Commit 8163bca

Browse files
heicarstrustyrussell
authored andcommitted
stop_machine: fix error code handling on multiple cpus
Using |= for updating a value which might be updated on several cpus concurrently will not always work since we need to make sure that the update happens atomically. To fix this just use a write if the called function returns an error code on a cpu. We end up writing the error code of an arbitrary cpu if multiple ones fail but that should be sufficient. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent c9583e5 commit 8163bca

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎kernel/stop_machine.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static void stop_cpu(struct work_struct *unused)
6666
enum stopmachine_state curstate = STOPMACHINE_NONE;
6767
struct stop_machine_data *smdata = &idle;
6868
int cpu = smp_processor_id();
69+
int err;
6970

7071
if (!active_cpus) {
7172
if (cpu == first_cpu(cpu_online_map))
@@ -86,9 +87,11 @@ static void stop_cpu(struct work_struct *unused)
8687
hard_irq_disable();
8788
break;
8889
case STOPMACHINE_RUN:
89-
/* |= allows error detection if functions on
90-
* multiple CPUs. */
91-
smdata->fnret |= smdata->fn(smdata->data);
90+
/* On multiple CPUs only a single error code
91+
* is needed to tell that something failed. */
92+
err = smdata->fn(smdata->data);
93+
if (err)
94+
smdata->fnret = err;
9295
break;
9396
default:
9497
break;

0 commit comments

Comments
 (0)