Skip to content

Commit 2b2095f

Browse files
npigginmpe
authored andcommitted
powerpc/64s: Fix hash__change_memory_range preemption warning
stop_machine_cpuslocked takes a mutex so it must be called in a preemptible context, so it can't simply be fixed by disabling preemption. This is not a bug, because CPU hotplug is locked, so this processor will call in to the stop machine function. So raw_smp_processor_id() could be used. This leaves a small chance that this thread will be migrated to another CPU, so the master work would be done by a CPU from a different context. Better for test coverage to make that a common case by just having the first CPU to call in become the master. Signed-off-by: Nicholas Piggin <[email protected]> Tested-by: Guenter Roeck <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b9ef323 commit 2b2095f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

arch/powerpc/mm/book3s64/hash_pgtable.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,8 @@ EXPORT_SYMBOL_GPL(hash__has_transparent_hugepage);
404404

405405
struct change_memory_parms {
406406
unsigned long start, end, newpp;
407-
unsigned int step, nr_cpus, master_cpu;
407+
unsigned int step, nr_cpus;
408+
atomic_t master_cpu;
408409
atomic_t cpu_counter;
409410
};
410411

@@ -478,7 +479,8 @@ static int change_memory_range_fn(void *data)
478479
{
479480
struct change_memory_parms *parms = data;
480481

481-
if (parms->master_cpu != smp_processor_id())
482+
// First CPU goes through, all others wait.
483+
if (atomic_xchg(&parms->master_cpu, 1) == 1)
482484
return chmem_secondary_loop(parms);
483485

484486
// Wait for all but one CPU (this one) to call-in
@@ -516,7 +518,7 @@ static bool hash__change_memory_range(unsigned long start, unsigned long end,
516518
chmem_parms.end = end;
517519
chmem_parms.step = step;
518520
chmem_parms.newpp = newpp;
519-
chmem_parms.master_cpu = smp_processor_id();
521+
atomic_set(&chmem_parms.master_cpu, 0);
520522

521523
cpus_read_lock();
522524

0 commit comments

Comments
 (0)