Skip to content

Commit

Permalink
padata: use alignment when calculating the number of worker threads
Browse files Browse the repository at this point in the history
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 <anthony.yznaga@oracle.com>
Acked-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Anthony Yznaga authored and Herbert Xu committed Mar 14, 2023
1 parent 1e62044 commit f84155c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/padata.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ void __init padata_do_multithreaded(struct padata_mt_job *job)
return;

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

if (nworks == 1) {
Expand Down

0 comments on commit f84155c

Please sign in to comment.