Skip to content

Commit

Permalink
xsk: Use kvcalloc to support large umems
Browse files Browse the repository at this point in the history
Use kvcalloc() instead of kcalloc() to support large umems with, on my
server, one million pages or more in the umem.

Reported-by: Dan Siemon <[email protected]>
Signed-off-by: Magnus Karlsson <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Björn Töpel <[email protected]>
Acked-by: John Fastabend <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
magnus-karlsson authored and borkmann committed May 25, 2021
1 parent 8fb33b6 commit a720a2a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions net/xdp/xdp_umem.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void xdp_umem_unpin_pages(struct xdp_umem *umem)
{
unpin_user_pages_dirty_lock(umem->pgs, umem->npgs, true);

kfree(umem->pgs);
kvfree(umem->pgs);
umem->pgs = NULL;
}

Expand Down Expand Up @@ -99,8 +99,7 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem, unsigned long address)
long npgs;
int err;

umem->pgs = kcalloc(umem->npgs, sizeof(*umem->pgs),
GFP_KERNEL | __GFP_NOWARN);
umem->pgs = kvcalloc(umem->npgs, sizeof(*umem->pgs), GFP_KERNEL | __GFP_NOWARN);
if (!umem->pgs)
return -ENOMEM;

Expand All @@ -123,7 +122,7 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem, unsigned long address)
out_pin:
xdp_umem_unpin_pages(umem);
out_pgs:
kfree(umem->pgs);
kvfree(umem->pgs);
umem->pgs = NULL;
return err;
}
Expand Down

0 comments on commit a720a2a

Please sign in to comment.