[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ+HfNjBwNjGwuT1jkkPO+n06GFnN4yornYpxb3M9MNg7+EYgg@mail.gmail.com>
Date: Sat, 22 May 2021 16:12:12 +0200
From: Björn Töpel <bjorn.topel@...il.com>
To: Magnus Karlsson <magnus.karlsson@...il.com>
Cc: "Karlsson, Magnus" <magnus.karlsson@...el.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Netdev <netdev@...r.kernel.org>,
"Fijalkowski, Maciej" <maciej.fijalkowski@...el.com>,
Jonathan Lemon <jonathan.lemon@...il.com>,
bpf <bpf@...r.kernel.org>, Dan Siemon <dan@...erfire.com>
Subject: Re: [PATCH bpf-next] xsk: use kvcalloc to support large umems
On Fri, 21 May 2021 at 10:33, Magnus Karlsson <magnus.karlsson@...il.com> wrote:
>
> From: Magnus Karlsson <magnus.karlsson@...el.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@...el.com>
> Reported-by: Dan Siemon <dan@...erfire.com>
Nice!
Acked-by: Björn Töpel <bjorn@...nel.org>
> ---
> 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
>
Powered by blists - more mailing lists