Skip to content

Conversation

@kernel-patches-daemon-bpf
Copy link

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

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 93ce3be
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: c1da3df
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: e5d2e34
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: fea3f5e
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 63066b7
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: c133390
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: ef2c0b2
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: a4d31f4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 4f7bc83
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 6cc73f3
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 4722981
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 4722981
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 4722981
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

…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]>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 4722981
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1023724
version: 2

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants