Commit 7ab24bfdf9a9a9f87ac8e5ad9a25f80b5b947be7

Authored by David S. Miller
1 parent ed6e4ef836

net+crypto: Use vmalloc for zlib inflate buffers.

They are 64K and result in order-4 allocations, even with SLUB.

Therefore, just like we always have for the deflate buffers, use
vmalloc.

Reported-by: Martin Jackson <mjackson220.list@gmail.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 4 changed files with 11 additions and 14 deletions Side-by-side Diff

... ... @@ -32,7 +32,6 @@
32 32 #include <linux/interrupt.h>
33 33 #include <linux/mm.h>
34 34 #include <linux/net.h>
35   -#include <linux/slab.h>
36 35  
37 36 #define DEFLATE_DEF_LEVEL Z_DEFAULT_COMPRESSION
38 37 #define DEFLATE_DEF_WINBITS 11
... ... @@ -73,7 +72,7 @@
73 72 int ret = 0;
74 73 struct z_stream_s *stream = &ctx->decomp_stream;
75 74  
76   - stream->workspace = kzalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
  75 + stream->workspace = vzalloc(zlib_inflate_workspacesize());
77 76 if (!stream->workspace) {
78 77 ret = -ENOMEM;
79 78 goto out;
... ... @@ -86,7 +85,7 @@
86 85 out:
87 86 return ret;
88 87 out_free:
89   - kfree(stream->workspace);
  88 + vfree(stream->workspace);
90 89 goto out;
91 90 }
92 91  
... ... @@ -99,7 +98,7 @@
99 98 static void deflate_decomp_exit(struct deflate_ctx *ctx)
100 99 {
101 100 zlib_inflateEnd(&ctx->decomp_stream);
102   - kfree(ctx->decomp_stream.workspace);
  101 + vfree(ctx->decomp_stream.workspace);
103 102 }
104 103  
105 104 static int deflate_init(struct crypto_tfm *tfm)
... ... @@ -29,7 +29,6 @@
29 29 #include <linux/interrupt.h>
30 30 #include <linux/mm.h>
31 31 #include <linux/net.h>
32   -#include <linux/slab.h>
33 32  
34 33 #include <crypto/internal/compress.h>
35 34  
... ... @@ -60,7 +59,7 @@
60 59  
61 60 if (stream->workspace) {
62 61 zlib_inflateEnd(stream);
63   - kfree(stream->workspace);
  62 + vfree(stream->workspace);
64 63 stream->workspace = NULL;
65 64 }
66 65 }
67 66  
... ... @@ -228,13 +227,13 @@
228 227 ? nla_get_u32(tb[ZLIB_DECOMP_WINDOWBITS])
229 228 : DEF_WBITS;
230 229  
231   - stream->workspace = kzalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
  230 + stream->workspace = vzalloc(zlib_inflate_workspacesize());
232 231 if (!stream->workspace)
233 232 return -ENOMEM;
234 233  
235 234 ret = zlib_inflateInit2(stream, ctx->decomp_windowBits);
236 235 if (ret != Z_OK) {
237   - kfree(stream->workspace);
  236 + vfree(stream->workspace);
238 237 stream->workspace = NULL;
239 238 return -EINVAL;
240 239 }
drivers/net/bnx2x/bnx2x_main.c
... ... @@ -49,6 +49,7 @@
49 49 #include <linux/zlib.h>
50 50 #include <linux/io.h>
51 51 #include <linux/stringify.h>
  52 +#include <linux/vmalloc.h>
52 53  
53 54 #define BNX2X_MAIN
54 55 #include "bnx2x.h"
... ... @@ -4537,8 +4538,7 @@
4537 4538 if (bp->strm == NULL)
4538 4539 goto gunzip_nomem2;
4539 4540  
4540   - bp->strm->workspace = kmalloc(zlib_inflate_workspacesize(),
4541   - GFP_KERNEL);
  4541 + bp->strm->workspace = vmalloc(zlib_inflate_workspacesize());
4542 4542 if (bp->strm->workspace == NULL)
4543 4543 goto gunzip_nomem3;
4544 4544  
... ... @@ -4562,7 +4562,7 @@
4562 4562 static void bnx2x_gunzip_end(struct bnx2x *bp)
4563 4563 {
4564 4564 if (bp->strm) {
4565   - kfree(bp->strm->workspace);
  4565 + vfree(bp->strm->workspace);
4566 4566 kfree(bp->strm);
4567 4567 bp->strm = NULL;
4568 4568 }
drivers/net/ppp_deflate.c
... ... @@ -305,7 +305,7 @@
305 305  
306 306 if (state) {
307 307 zlib_inflateEnd(&state->strm);
308   - kfree(state->strm.workspace);
  308 + vfree(state->strm.workspace);
309 309 kfree(state);
310 310 }
311 311 }
... ... @@ -345,8 +345,7 @@
345 345  
346 346 state->w_size = w_size;
347 347 state->strm.next_out = NULL;
348   - state->strm.workspace = kmalloc(zlib_inflate_workspacesize(),
349   - GFP_KERNEL|__GFP_REPEAT);
  348 + state->strm.workspace = vmalloc(zlib_inflate_workspacesize());
350 349 if (state->strm.workspace == NULL)
351 350 goto out_free;
352 351