Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

padata: use cpumask_nth()

padata_do_parallel() and padata_index_to_cpu() duplicate cpumask_nth().
Fix both and use the generic helper.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Yury Norov and committed by
Herbert Xu
758f5bdf 4b7ed1ce

+3 -19
+3 -19
kernel/padata.c
··· 63 63 padata_put_pd_cnt(pd, 1); 64 64 } 65 65 66 - static int padata_index_to_cpu(struct parallel_data *pd, int cpu_index) 67 - { 68 - int cpu, target_cpu; 69 - 70 - target_cpu = cpumask_first(pd->cpumask.pcpu); 71 - for (cpu = 0; cpu < cpu_index; cpu++) 72 - target_cpu = cpumask_next(target_cpu, pd->cpumask.pcpu); 73 - 74 - return target_cpu; 75 - } 76 - 77 66 static int padata_cpu_hash(struct parallel_data *pd, unsigned int seq_nr) 78 67 { 79 68 /* ··· 71 82 */ 72 83 int cpu_index = seq_nr % cpumask_weight(pd->cpumask.pcpu); 73 84 74 - return padata_index_to_cpu(pd, cpu_index); 85 + return cpumask_nth(cpu_index, pd->cpumask.pcpu); 75 86 } 76 87 77 88 static struct padata_work *padata_work_alloc(void) ··· 181 192 struct padata_priv *padata, int *cb_cpu) 182 193 { 183 194 struct padata_instance *pinst = ps->pinst; 184 - int i, cpu, cpu_index, err; 185 195 struct parallel_data *pd; 186 196 struct padata_work *pw; 197 + int cpu_index, err; 187 198 188 199 rcu_read_lock_bh(); 189 200 ··· 199 210 200 211 /* Select an alternate fallback CPU and notify the caller. */ 201 212 cpu_index = *cb_cpu % cpumask_weight(pd->cpumask.cbcpu); 202 - 203 - cpu = cpumask_first(pd->cpumask.cbcpu); 204 - for (i = 0; i < cpu_index; i++) 205 - cpu = cpumask_next(cpu, pd->cpumask.cbcpu); 206 - 207 - *cb_cpu = cpu; 213 + *cb_cpu = cpumask_nth(cpu_index, pd->cpumask.cbcpu); 208 214 } 209 215 210 216 err = -EBUSY;