From: Mathias Krause Date: Fri, 8 Sep 2017 18:57:09 +0000 (+0200) Subject: padata: set cpu_index of unused CPUs to -1 X-Git-Tag: v3.16.84~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b094ba4b6794c2ede4a1e00fd927df604aaba960;p=thirdparty%2Fkernel%2Fstable.git padata: set cpu_index of unused CPUs to -1 commit 1bd845bcb41d5b7f83745e0cb99273eb376f2ec5 upstream. The parallel queue per-cpu data structure gets initialized only for CPUs in the 'pcpu' CPU mask set. This is not sufficient as the reorder timer may run on a different CPU and might wrongly decide it's the target CPU for the next reorder item as per-cpu memory gets memset(0) and we might be waiting for the first CPU in cpumask.pcpu, i.e. cpu_index 0. Make the '__this_cpu_read(pd->pqueue->cpu_index) == next_queue->cpu_index' compare in padata_get_next() fail in this case by initializing the cpu_index member of all per-cpu parallel queues. Use -1 for unused ones. Signed-off-by: Mathias Krause Signed-off-by: Herbert Xu Signed-off-by: Ben Hutchings --- diff --git a/kernel/padata.c b/kernel/padata.c index 8b95e318408d2..26feec13f0283 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -395,8 +395,14 @@ static void padata_init_pqueues(struct parallel_data *pd) struct padata_parallel_queue *pqueue; cpu_index = 0; - for_each_cpu(cpu, pd->cpumask.pcpu) { + for_each_possible_cpu(cpu) { pqueue = per_cpu_ptr(pd->pqueue, cpu); + + if (!cpumask_test_cpu(cpu, pd->cpumask.pcpu)) { + pqueue->cpu_index = -1; + continue; + } + pqueue->pd = pd; pqueue->cpu_index = cpu_index; cpu_index++;