Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1632195

Re: [PATCH v2 07/21] crypto: shash, caam: Make use of the new sg_map helper function

From Logan Gunthorpe <logang@deltatee.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 07/21] crypto: shash, caam: Make use of the new sg_map helper function
Date 2017-04-27 17:50 +0200
Message-ID <tATQ6-2Ak-15@gated-at.bofh.it> (permalink)
References <tAdnP-8d5-5@gated-at.bofh.it> <tAdxw-8iW-27@gated-at.bofh.it> <tAIKZ-3hG-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 26/04/17 09:56 PM, Herbert Xu wrote:
> On Tue, Apr 25, 2017 at 12:20:54PM -0600, Logan Gunthorpe wrote:
>> Very straightforward conversion to the new function in the caam driver
>> and shash library.
>>
>> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
>> Cc: Herbert Xu <herbert@gondor.apana.org.au>
>> Cc: "David S. Miller" <davem@davemloft.net>
>> ---
>>  crypto/shash.c                | 9 ++++++---
>>  drivers/crypto/caam/caamalg.c | 8 +++-----
>>  2 files changed, 9 insertions(+), 8 deletions(-)
>>
>> diff --git a/crypto/shash.c b/crypto/shash.c
>> index 5e31c8d..5914881 100644
>> --- a/crypto/shash.c
>> +++ b/crypto/shash.c
>> @@ -283,10 +283,13 @@ int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc)
>>  	if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) {
>>  		void *data;
>>  
>> -		data = kmap_atomic(sg_page(sg));
>> -		err = crypto_shash_digest(desc, data + offset, nbytes,
>> +		data = sg_map(sg, 0, SG_KMAP_ATOMIC);
>> +		if (IS_ERR(data))
>> +			return PTR_ERR(data);
>> +
>> +		err = crypto_shash_digest(desc, data, nbytes,
>>  					  req->result);
>> -		kunmap_atomic(data);
>> +		sg_unmap(sg, data, 0, SG_KMAP_ATOMIC);
>>  		crypto_yield(desc->flags);
>>  	} else
>>  		err = crypto_shash_init(desc) ?:
> 
> Nack.  This is an optimisation for the special case of a single
> SG list entry.  In fact in the common case the kmap_atomic should
> disappear altogether in the no-highmem case.  So replacing it
> with sg_map is not acceptable.

What you seem to have missed is that sg_map is just a thin wrapper
around kmap_atomic. Perhaps with a future check for a mappable page.
This change should have zero impact on performance.

Logan

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 07/21] crypto: shash, caam: Make use of the new sg_map helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-25 20:40 +0200
  Re: [PATCH v2 07/21] crypto: shash, caam: Make use of the new sg_map  helper function Herbert Xu <herbert@gondor.apana.org.au> - 2017-04-27 06:00 +0200
    Re: [PATCH v2 07/21] crypto: shash, caam: Make use of the new sg_map  helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-27 17:50 +0200
      Re: [PATCH v2 07/21] crypto: shash, caam: Make use of the new sg_map  helper function Herbert Xu <herbert@gondor.apana.org.au> - 2017-04-28 08:40 +0200
        Re: [PATCH v2 07/21] crypto: shash, caam: Make use of the new sg_map  helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-28 19:00 +0200
          Re: [PATCH v2 07/21] crypto: shash, caam: Make use of the new sg_map  helper function Herbert Xu <herbert@gondor.apana.org.au> - 2017-04-28 20:40 +0200
            Re: [PATCH v2 07/21] crypto: shash, caam: Make use of the new sg_map  helper function Logan Gunthorpe <logang@deltatee.com> - 2017-04-28 21:10 +0200

csiph-web