Skip to content

Commit

Permalink
crypto: algif - Mark sgl end at the end of data
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
tstruk authored and herbertx committed Dec 22, 2014
1 parent 2d2ec06 commit 0f477b6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crypto/algif_skcipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down Expand Up @@ -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++;
Expand Down

0 comments on commit 0f477b6

Please sign in to comment.