Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH v3] crypto: algif - Mark sgl end at the end of data
@ 2014-12-08 20:03 Tadeusz Struk
  2014-12-22 12:05 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Tadeusz Struk @ 2014-12-08 20:03 UTC (permalink / raw)
  To: herbert; +Cc: davem, linux-crypto, qat-linux

Hi,
algif_skcipher sends 127 sgl buffers for encryption regardless of how
many buffers acctually have data to process, where the few first with
valid len and the rest with zero len. This is not very eficient.
This patch marks the last one with data as the last one to process.

Changes:
v2 - use data len to find the last buffer instead of nents in RX list.
v3 - Mark/unmark end when data is added and sgl->cur changed.

Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
---
 crypto/algif_skcipher.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 3e84f4a..9b84765 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -330,6 +330,7 @@ static int skcipher_sendmsg(struct kiocb *unused, struct socket *sock,
 
 		sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list);
 		sg = sgl->sg;
+		sg_unmark_end(sg + sgl->cur);
 		do {
 			i = sgl->cur;
 			plen = min_t(int, len, PAGE_SIZE);
@@ -355,6 +356,9 @@ static int skcipher_sendmsg(struct kiocb *unused, struct socket *sock,
 			sgl->cur++;
 		} while (len && sgl->cur < MAX_SGL_ENTS);
 
+		if (!size)
+			sg_mark_end(sg + sgl->cur - 1);
+
 		ctx->merge = plen & (PAGE_SIZE - 1);
 	}
 
@@ -401,6 +405,10 @@ static ssize_t skcipher_sendpage(struct socket *sock, struct page *page,
 	ctx->merge = 0;
 	sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list);
 
+	if (sgl->cur)
+		sg_unmark_end(sgl->sg + sgl->cur - 1);
+
+	sg_mark_end(sgl->sg + sgl->cur);
 	get_page(page);
 	sg_set_page(sgl->sg + sgl->cur, page, size, offset);
 	sgl->cur++;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] crypto: algif - Mark sgl end at the end of data
  2014-12-08 20:03 [PATCH v3] crypto: algif - Mark sgl end at the end of data Tadeusz Struk
@ 2014-12-22 12:05 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2014-12-22 12:05 UTC (permalink / raw)
  To: Tadeusz Struk; +Cc: davem, linux-crypto, qat-linux

On Mon, Dec 08, 2014 at 12:03:42PM -0800, Tadeusz Struk wrote:
> Hi,
> algif_skcipher sends 127 sgl buffers for encryption regardless of how
> many buffers acctually have data to process, where the few first with
> valid len and the rest with zero len. This is not very eficient.
> This patch marks the last one with data as the last one to process.
> 
> Changes:
> v2 - use data len to find the last buffer instead of nents in RX list.
> v3 - Mark/unmark end when data is added and sgl->cur changed.
> 
> Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>

Patch applied.
-- 
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] 2+ messages in thread

end of thread, other threads:[~2014-12-22 12:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-08 20:03 [PATCH v3] crypto: algif - Mark sgl end at the end of data Tadeusz Struk
2014-12-22 12:05 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox