Skip to content

Commit f74b2a6

Browse files
npigginmpe
authored andcommitted
powerpc/64s: Use dec_mm_active_cpus helper
Avoid open-coded atomic_dec on mm->context.active_cpus and use the function made for it. Add CONFIG_DEBUG_VM underflow checking on the counter. Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent c3c2e93 commit f74b2a6

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

arch/powerpc/include/asm/book3s/64/mmu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static inline void radix_init_pseries(void) { }
261261
#define arch_clear_mm_cpumask_cpu(cpu, mm) \
262262
do { \
263263
if (cpumask_test_cpu(cpu, mm_cpumask(mm))) { \
264-
atomic_dec(&(mm)->context.active_cpus); \
264+
dec_mm_active_cpus(mm); \
265265
cpumask_clear_cpu(cpu, mm_cpumask(mm)); \
266266
} \
267267
} while (0)

arch/powerpc/include/asm/mmu_context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ static inline void inc_mm_active_cpus(struct mm_struct *mm)
127127

128128
static inline void dec_mm_active_cpus(struct mm_struct *mm)
129129
{
130+
VM_WARN_ON_ONCE(atomic_read(&mm->context.active_cpus) <= 0);
130131
atomic_dec(&mm->context.active_cpus);
131132
}
132133

arch/powerpc/mm/book3s64/radix_tlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ void exit_lazy_flush_tlb(struct mm_struct *mm, bool always_flush)
820820
* that's what the caller expects.
821821
*/
822822
if (cpumask_test_cpu(cpu, mm_cpumask(mm))) {
823-
atomic_dec(&mm->context.active_cpus);
823+
dec_mm_active_cpus(mm);
824824
cpumask_clear_cpu(cpu, mm_cpumask(mm));
825825
always_flush = true;
826826
}

0 commit comments

Comments
 (0)