From: Xiao Liang Date: Sat, 16 Aug 2025 16:30:15 +0000 (+0800) Subject: padata: Reset next CPU when reorder sequence wraps around X-Git-Tag: v6.18-rc1~84^2~60 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=501302d5cee0d8e8ec2c4a5919c37e0df9abc99b;p=thirdparty%2Fkernel%2Fstable.git padata: Reset next CPU when reorder sequence wraps around When seq_nr wraps around, the next reorder job with seq 0 is hashed to the first CPU in padata_do_serial(). Correspondingly, need reset pd->cpu to the first one when pd->processed wraps around. Otherwise, if the number of used CPUs is not a power of 2, padata_find_next() will be checking a wrong list, hence deadlock. Fixes: 6fc4dbcf0276 ("padata: Replace delayed timer with immediate workqueue in padata_reorder") Cc: Signed-off-by: Xiao Liang Signed-off-by: Herbert Xu --- diff --git a/kernel/padata.c b/kernel/padata.c index f85f8bd788d0d..833740d754837 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -291,8 +291,12 @@ static void padata_reorder(struct padata_priv *padata) struct padata_serial_queue *squeue; int cb_cpu; - cpu = cpumask_next_wrap(cpu, pd->cpumask.pcpu); processed++; + /* When sequence wraps around, reset to the first CPU. */ + if (unlikely(processed == 0)) + cpu = cpumask_first(pd->cpumask.pcpu); + else + cpu = cpumask_next_wrap(cpu, pd->cpumask.pcpu); cb_cpu = padata->cb_cpu; squeue = per_cpu_ptr(pd->squeue, cb_cpu);