aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorTadeusz Struk <tadeusz.struk@intel.com>2014-12-08 15:03:42 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2014-12-22 07:02:41 -0500
commit0f477b655a524515ec9a263d70d51f460c05a161 (patch)
tree5cfb69e0ac66a1edcfe7eb10cb1b6d7a131a9c8a /crypto
parent2d2ec0642a85966b6a299bbcd94707982327ace8 (diff)
crypto: algif - Mark sgl end at the end of data
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. Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/algif_skcipher.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index c12207c8dde9..38a6757e3ccc 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,
330 330
331 sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list); 331 sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list);
332 sg = sgl->sg; 332 sg = sgl->sg;
333 sg_unmark_end(sg + sgl->cur);
333 do { 334 do {
334 i = sgl->cur; 335 i = sgl->cur;
335 plen = min_t(int, len, PAGE_SIZE); 336 plen = min_t(int, len, PAGE_SIZE);
@@ -355,6 +356,9 @@ static int skcipher_sendmsg(struct kiocb *unused, struct socket *sock,
355 sgl->cur++; 356 sgl->cur++;
356 } while (len && sgl->cur < MAX_SGL_ENTS); 357 } while (len && sgl->cur < MAX_SGL_ENTS);
357 358
359 if (!size)
360 sg_mark_end(sg + sgl->cur - 1);
361
358 ctx->merge = plen & (PAGE_SIZE - 1); 362 ctx->merge = plen & (PAGE_SIZE - 1);
359 } 363 }
360 364
@@ -401,6 +405,10 @@ static ssize_t skcipher_sendpage(struct socket *sock, struct page *page,
401 ctx->merge = 0; 405 ctx->merge = 0;
402 sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list); 406 sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list);
403 407
408 if (sgl->cur)
409 sg_unmark_end(sgl->sg + sgl->cur - 1);
410
411 sg_mark_end(sgl->sg + sgl->cur);
404 get_page(page); 412 get_page(page);
405 sg_set_page(sgl->sg + sgl->cur, page, size, offset); 413 sg_set_page(sgl->sg + sgl->cur, page, size, offset);
406 sgl->cur++; 414 sgl->cur++;