Commit a720a2a0 authored by Magnus Karlsson's avatar Magnus Karlsson Committed by Daniel Borkmann

xsk: Use kvcalloc to support large umems

Use kvcalloc() instead of kcalloc() to support large umems with, on my
server, one million pages or more in the umem.
Reported-by: default avatarDan Siemon <dan@coverfire.com>
Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarBjörn Töpel <bjorn@kernel.org>
Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20210521083301.26921-1-magnus.karlsson@gmail.com
parent 8fb33b60
...@@ -27,7 +27,7 @@ static void xdp_umem_unpin_pages(struct xdp_umem *umem) ...@@ -27,7 +27,7 @@ static void xdp_umem_unpin_pages(struct xdp_umem *umem)
{ {
unpin_user_pages_dirty_lock(umem->pgs, umem->npgs, true); unpin_user_pages_dirty_lock(umem->pgs, umem->npgs, true);
kfree(umem->pgs); kvfree(umem->pgs);
umem->pgs = NULL; umem->pgs = NULL;
} }
...@@ -99,8 +99,7 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem, unsigned long address) ...@@ -99,8 +99,7 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem, unsigned long address)
long npgs; long npgs;
int err; int err;
umem->pgs = kcalloc(umem->npgs, sizeof(*umem->pgs), umem->pgs = kvcalloc(umem->npgs, sizeof(*umem->pgs), GFP_KERNEL | __GFP_NOWARN);
GFP_KERNEL | __GFP_NOWARN);
if (!umem->pgs) if (!umem->pgs)
return -ENOMEM; return -ENOMEM;
...@@ -123,7 +122,7 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem, unsigned long address) ...@@ -123,7 +122,7 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem, unsigned long address)
out_pin: out_pin:
xdp_umem_unpin_pages(umem); xdp_umem_unpin_pages(umem);
out_pgs: out_pgs:
kfree(umem->pgs); kvfree(umem->pgs);
umem->pgs = NULL; umem->pgs = NULL;
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment