[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMB2axM0-NF5F=O6Lq1WPbb8PJtdZrQaOTFKWApWEhfT7MD4hw@mail.gmail.com>
Date: Wed, 12 Nov 2025 11:51:28 -0800
From: Amery Hung <ameryhung@...il.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: bpf <bpf@...r.kernel.org>, Network Development <netdev@...r.kernel.org>,
Andrii Nakryiko <andrii@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <martin.lau@...nel.org>, Kumar Kartikeya Dwivedi <memxor@...il.com>, KP Singh <kpsingh@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, Song Liu <song@...nel.org>,
Kernel Team <kernel-team@...a.com>
Subject: Re: [PATCH RFC bpf-next 2/2] bpf: Use kmalloc_nolock() in local
storage unconditionally
On Wed, Nov 12, 2025 at 11:35 AM Alexei Starovoitov
<alexei.starovoitov@...il.com> wrote:
>
> On Wed, Nov 12, 2025 at 9:59 AM Amery Hung <ameryhung@...il.com> wrote:
> >
> > @@ -80,23 +80,12 @@ bpf_selem_alloc(struct bpf_local_storage_map *smap, void *owner,
> > if (mem_charge(smap, owner, smap->elem_size))
> > return NULL;
> >
> > - if (smap->bpf_ma) {
> > - selem = bpf_mem_cache_alloc_flags(&smap->selem_ma, gfp_flags);
> > - if (selem)
> > - /* Keep the original bpf_map_kzalloc behavior
> > - * before started using the bpf_mem_cache_alloc.
> > - *
> > - * No need to use zero_map_value. The bpf_selem_free()
> > - * only does bpf_mem_cache_free when there is
> > - * no other bpf prog is using the selem.
> > - */
> > - memset(SDATA(selem)->data, 0, smap->map.value_size);
> > - } else {
> > - selem = bpf_map_kzalloc(&smap->map, smap->elem_size,
> > - gfp_flags | __GFP_NOWARN);
> > - }
> > + selem = bpf_map_kmalloc_nolock(&smap->map, smap->elem_size, gfp_flags, NUMA_NO_NODE);
>
>
> Pls enable CONFIG_DEBUG_VM=y then you'll see that the above triggers:
> void *kmalloc_nolock_noprof(size_t size, gfp_t gfp_flags, int node)
> {
> gfp_t alloc_gfp = __GFP_NOWARN | __GFP_NOMEMALLOC | gfp_flags;
> ...
> VM_WARN_ON_ONCE(gfp_flags & ~(__GFP_ACCOUNT | __GFP_ZERO |
> __GFP_NO_OBJ_EXT));
>
> and benchmarking numbers have to be redone, since with
> unsupported gfp flags kmalloc_nolock() is likely doing something wrong.
I see. Thanks for pointing it out. Currently the verifier determines
the flag and rewrites the program based on if the caller of
storage_get helpers is sleepable. I will remove it and redo the
benchmark.
Thanks,
Amery
Powered by blists - more mailing lists