* [PATCH] padata: use alignment when calculating the number of worker threads
@ 2023-02-23 0:33 Anthony Yznaga
2023-03-01 16:36 ` Daniel Jordan
2023-03-10 11:28 ` Herbert Xu
0 siblings, 2 replies; 3+ messages in thread
From: Anthony Yznaga @ 2023-02-23 0:33 UTC (permalink / raw)
To: daniel.m.jordan, steffen.klassert; +Cc: linux-crypto, linux-kernel
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>
---
kernel/padata.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/padata.c b/kernel/padata.c
index e007b8a4b738..4abc536ecdb1 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -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) {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] padata: use alignment when calculating the number of worker threads
2023-02-23 0:33 [PATCH] padata: use alignment when calculating the number of worker threads Anthony Yznaga
@ 2023-03-01 16:36 ` Daniel Jordan
2023-03-10 11:28 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Jordan @ 2023-03-01 16:36 UTC (permalink / raw)
To: Anthony Yznaga; +Cc: steffen.klassert, linux-crypto, linux-kernel
On Wed, Feb 22, 2023 at 04:33:12PM -0800, Anthony Yznaga wrote:
> 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>
No effect for now since the page init code uses the same align and
min_chunk, but it protects future users from this problem so
Acked-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Thanks.
> ---
> kernel/padata.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/padata.c b/kernel/padata.c
> index e007b8a4b738..4abc536ecdb1 100644
> --- a/kernel/padata.c
> +++ b/kernel/padata.c
> @@ -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) {
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] padata: use alignment when calculating the number of worker threads
2023-02-23 0:33 [PATCH] padata: use alignment when calculating the number of worker threads Anthony Yznaga
2023-03-01 16:36 ` Daniel Jordan
@ 2023-03-10 11:28 ` Herbert Xu
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2023-03-10 11:28 UTC (permalink / raw)
To: Anthony Yznaga
Cc: daniel.m.jordan, steffen.klassert, linux-crypto, linux-kernel
Anthony Yznaga <anthony.yznaga@oracle.com> wrote:
> 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>
> ---
> kernel/padata.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-10 11:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-23 0:33 [PATCH] padata: use alignment when calculating the number of worker threads Anthony Yznaga
2023-03-01 16:36 ` Daniel Jordan
2023-03-10 11:28 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.