Skip to content

Conversation

@ameryhung
Copy link
Contributor

No description provided.

…elements

Since commit a96a44a (“bpf: bpf_sk_storage: Fix invalid wait
context lockdep report”), mem_uncharge is always true when
unlinking bpf_local_storage_elem from local storage, so drop this
argument. No functional change.

Signed-off-by: Amery Hung <[email protected]>
@ameryhung ameryhung force-pushed the ls_use_kmalloc_nolock branch 2 times, most recently from d83ba59 to d7594a5 Compare November 11, 2025 21:49
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]>
@ameryhung ameryhung force-pushed the ls_use_kmalloc_nolock branch from d7594a5 to bbc6be0 Compare November 12, 2025 00:00
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