Skip to content

Commit f84155c

Browse files
Anthony Yznagaherbertx
Anthony Yznaga
authored andcommitted
padata: use alignment when calculating the number of worker threads
For multithreaded jobs the computed chunk size is rounded up by the caller-specified alignment. However, the number of worker threads to use is computed using the minimum chunk size without taking alignment into account. A sufficiently large alignment value can result in too many worker threads being allocated for the job. Signed-off-by: Anthony Yznaga <[email protected]> Acked-by: Daniel Jordan <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 1e62044 commit f84155c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/padata.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ void __init padata_do_multithreaded(struct padata_mt_job *job)
491491
return;
492492

493493
/* Ensure at least one thread when size < min_chunk. */
494-
nworks = max(job->size / job->min_chunk, 1ul);
494+
nworks = max(job->size / max(job->min_chunk, job->align), 1ul);
495495
nworks = min(nworks, job->max_threads);
496496

497497
if (nworks == 1) {

0 commit comments

Comments
 (0)