From: Magnus Karlsson <magnus.karlsson@gmail.com>
To: magnus.karlsson@intel.com, bjorn@kernel.org, ast@kernel.org,
daniel@iogearbox.net, netdev@vger.kernel.org,
maciej.fijalkowski@intel.com
Cc: jonathan.lemon@gmail.com, bpf@vger.kernel.org,
Dan Siemon <dan@coverfire.com>
Subject: [PATCH bpf-next] xsk: use kvcalloc to support large umems
Date: Fri, 21 May 2021 10:33:01 +0200 [thread overview]
Message-ID: <20210521083301.26921-1-magnus.karlsson@gmail.com> (raw)
From: Magnus Karlsson <magnus.karlsson@intel.com>
Use kvcalloc() instead of kcalloc() to support large umems with, on my
server, one million pages or more in the umem.
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Reported-by: Dan Siemon <dan@coverfire.com>
---
net/xdp/xdp_umem.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
index 56a28a686988..f01ef6bda390 100644
--- a/net/xdp/xdp_umem.c
+++ b/net/xdp/xdp_umem.c
@@ -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;
}
@@ -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;
@@ -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;
}
base-commit: a49e72b3bda73d36664a084e47da9727a31b8095
--
2.29.0
next reply other threads:[~2021-05-21 8:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-21 8:33 Magnus Karlsson [this message]
2021-05-22 14:12 ` [PATCH bpf-next] xsk: use kvcalloc to support large umems Björn Töpel
2021-05-24 17:59 ` John Fastabend
2021-05-25 11:30 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210521083301.26921-1-magnus.karlsson@gmail.com \
--to=magnus.karlsson@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dan@coverfire.com \
--cc=daniel@iogearbox.net \
--cc=jonathan.lemon@gmail.com \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).