-
Notifications
You must be signed in to change notification settings - Fork 5
Replace BPF memory allocator with kmalloc_nolock() in local storage #6358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace BPF memory allocator with kmalloc_nolock() in local storage #6358
Conversation
|
Upstream branch: 93ce3be |
67d3dd3 to
488318d
Compare
|
Upstream branch: c1da3df |
2b7b0c6 to
39877dd
Compare
488318d to
728ac5f
Compare
|
Upstream branch: fea3f5e |
39877dd to
96833c3
Compare
728ac5f to
4fcc7e1
Compare
|
Upstream branch: 63066b7 |
96833c3 to
bcfdc9d
Compare
4fcc7e1 to
1aeb398
Compare
|
Upstream branch: c133390 |
bcfdc9d to
e9fefdc
Compare
1aeb398 to
f68d848
Compare
|
Upstream branch: ef2c0b2 |
e9fefdc to
ca488db
Compare
f68d848 to
3fd24de
Compare
|
Upstream branch: a4d31f4 |
ca488db to
31befde
Compare
3fd24de to
22f76ea
Compare
|
Upstream branch: 4f7bc83 |
31befde to
3717a50
Compare
22f76ea to
d766c2f
Compare
|
Upstream branch: 6cc73f3 |
3717a50 to
a62eab2
Compare
d766c2f to
86f62c3
Compare
|
Upstream branch: 4722981 |
a62eab2 to
016fd1e
Compare
|
Upstream branch: 4722981 |
016fd1e to
3f9e1d2
Compare
|
Upstream branch: 4722981 |
3f9e1d2 to
5a5c066
Compare
|
Upstream branch: 4722981 |
5a5c066 to
5cbd922
Compare
|
Upstream branch: 4722981 |
5cbd922 to
61479dc
Compare
86f62c3 to
c8a7e22
Compare
|
Upstream branch: 7dc211c |
61479dc to
7264159
Compare
c8a7e22 to
c919396
Compare
|
Upstream branch: ec12ab2 |
…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]> Reviewed-by: Martin KaFai Lau <[email protected]>
Since selem already saves a pointer to smap, use it instead of an additional argument in bpf_selem_free(). This requires moving the SDATA(selem)->smap assignment from bpf_selem_link_map() to bpf_selem_alloc() since bpf_selem_free() may be called without the selem being linked to smap in bpf_local_storage_update(). Signed-off-by: Amery Hung <[email protected]> Reviewed-by: Martin KaFai Lau <[email protected]>
Save the memory allocation method used for bpf_local_storage in the struct explicitly so that we don't need to go through the hassle to find out the info. When a later patch replaces BPF memory allocator with kmalloc_noloc(), bpf_local_storage_free() will no longer need smap->storage_ma to return the memory and completely remove the dependency on smap in bpf_local_storage_free(). Signed-off-by: Amery Hung <[email protected]> Reviewed-by: Martin KaFai Lau <[email protected]>
Replace bpf memory allocator with kmalloc_nolock() to reduce memory wastage due to preallocation. In bpf_selem_free(), an selem now needs to wait for a RCU grace period before being freed when reuse_now == true. Therefore, rcu_barrier() should be always be called in bpf_local_storage_map_free(). In bpf_local_storage_free(), since smap->storage_ma is no longer needed to return the memory, the function is now independent from smap. Remove the outdated comment in bpf_local_storage_alloc(). 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]> Reviewed-by: Martin KaFai Lau <[email protected]>
7264159 to
d11c6ac
Compare
c919396 to
73c6b0b
Compare
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724 irrelevant now. Closing PR. |
Pull request for series with
subject: Replace BPF memory allocator with kmalloc_nolock() in local storage
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724