Skip to content

Conversation

@ameryhung
Copy link
Contributor

No description provided.

@ameryhung ameryhung force-pushed the ls_use_kmalloc_nolock branch 3 times, most recently from d7594a5 to bbc6be0 Compare November 12, 2025 00:00
…elements

Since commit a96a44a ("bpf: bpf_sk_storage: Fix invalid wait
context lockdep report"), {charge,uncharge}_mem are always true when
allocating a bpf_local_storage_elem or unlinking a bpf_local_storage_elem
from local storage, so drop these arguments. No functional change.

Signed-off-by: Amery Hung <[email protected]>
Simplify local storage and selem memory alloc/free paths by switching to
kmalloc_nolock unconditionally.

While it is okay to call bpf_obj_free_fields() immediately in
bpf_selem_free() when reuse_now == true, it is kept only in
bpf_selem_free_rcu() to simplify the code. This requires rcu_barrier()
to be called unconditionally in bpf_local_storage_map_free() since
bpf_obj_free_fields() may also be called from rcu callbacks.

In addition, remove the argument, smap, from bpf_selem_free() and rely
on SDATA(selem)->smap for bpf_obj_free_fields(). This requires
initializing SDATA(selem)->smap earlier during bpf_selem_alloc() as
bpf_local_storage_update() can allocate an selem and free it without
ever linking it to a map.

Finally, clean up and update comments. Note that, we already free selem
after an RCU grace period in bpf_local_storage_update() when
bpf_local_storage_alloc() failed the cmpxchg since commit c0d63f3
("bpf: Add bpf_selem_free()").

Signed-off-by: Amery Hung <[email protected]>
With kmalloc_nolock(), we no longer need to pass gfp_flags from bpf()
syscalls and helpers for local storage. Remove the argument and fixup
in the verifier.

Signed-off-by: Amery Hung <[email protected]>
@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot force-pushed the bpf-next_base branch 3 times, most recently from f882b4c to 4752827 Compare November 14, 2025 04:22
@ameryhung ameryhung force-pushed the ls_use_kmalloc_nolock branch from bbc6be0 to bf1c16d Compare November 14, 2025 19:27
@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot force-pushed the bpf-next_base branch 4 times, most recently from 6a32d09 to b967d93 Compare November 14, 2025 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant