lkml.org 
[lkml]   [2022]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] crypto: skcipher - always yield at end of walk
On Mon, Dec 19, 2022 at 02:37:31PM -0600, Robert Elliott wrote:
>
> diff --git a/crypto/skcipher.c b/crypto/skcipher.c
> index 0ecab31cfe79..cdead632117a 100644
> --- a/crypto/skcipher.c
> +++ b/crypto/skcipher.c
> @@ -153,13 +153,20 @@ int skcipher_walk_done(struct skcipher_walk *walk, int err)
> scatterwalk_done(&walk->in, 0, nbytes);
> scatterwalk_done(&walk->out, 1, nbytes);
>
> - if (nbytes) {
> - crypto_yield(walk->flags & SKCIPHER_WALK_SLEEP ?
> - CRYPTO_TFM_REQ_MAY_SLEEP : 0);
> + /*
> + * Allow scheduler to use the CPU since it has been busy,
> + * regardless of whether another loop pass is due
> + */
> + crypto_yield(walk->flags & SKCIPHER_WALK_SLEEP ?
> + CRYPTO_TFM_REQ_MAY_SLEEP : 0);
> +
> + if (nbytes)
> return skcipher_walk_next(walk);
> - }
>
> finish:
> + crypto_yield(walk->flags & SKCIPHER_WALK_SLEEP ?
> + CRYPTO_TFM_REQ_MAY_SLEEP : 0);
> +

You're calling crypto_yield twice if nbytes == 0. How about
deleting the second crypto_yield call because the only case
where it would matter is when n == 0.

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

\
 
 \ /
  Last update: 2023-03-26 23:15    [W:0.067 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site