Skip to content

kallsyms: cache bpf symbols to avoid quadratic iteration#10892

Open
kernel-patches-daemon-bpf[bot] wants to merge 1 commit intobpf-next_basefrom
series/1048807=>bpf-next
Open

kallsyms: cache bpf symbols to avoid quadratic iteration#10892
kernel-patches-daemon-bpf[bot] wants to merge 1 commit intobpf-next_basefrom
series/1048807=>bpf-next

Conversation

@kernel-patches-daemon-bpf
Copy link

Pull request for series with
subject: kallsyms: cache bpf symbols to avoid quadratic iteration
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 95dbe21
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: b18a761
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: cd77618
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: c7fbf8d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: cda0cbf
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: f0b5b3d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 4bebb99
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 6b95cc5
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 6b95cc5
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: f941479
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: f11f7cf
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: b28dac3
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 78a1605
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 5e6e1dc
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 4af5266
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 6e951a9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 75cd3be
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1048807
version: 1

The existing code iterates the whole list of bpf ksyms until the right
one is found, which means quadratic complexity on top of linked list
pointer chasing under rcu. This is't noticeable for most installations,
but when one has 10000 bpf programs loaded, things start to add up and
reading from `/proc/kallsyms` slows down a lot.

Instead of doing that, we can cache the list of bpf symbols in linear
time when `/proc/kallsyms` is opened, which makes the whole thing fast.

Reading `/proc/kallsyms` on Apple M3 Pro in a VM and measuring system time:

Before:
* 15 bpf symbols: ~35ms
* 10015 bpf symbols: ~1250ms

After:
* 15 bpf symbols: ~35ms
* 10015 bpf symbols: ~50ms

Testing in production on v6.12 series (with ~10000 bpf ksyms as well):

* On AMD EPYC 9684X (Zen4): ~870ms -> ~100ms
* On Ampere Altra Max M128-30: ~4650ms -> ~70ms

Signed-off-by: Ivan Babrou <[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.

1 participant