-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
add btf support for maps #2192
Merged
Merged
add btf support for maps #2192
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4ast
approved these changes
Feb 10, 2019
yonghong-song
force-pushed
the
yhs_dev
branch
from
February 10, 2019 08:46
970a7b6
to
d1ba693
Compare
The tests involving "b" frontends failed. Will add proper support in this round. |
Added bpf support for maps so map key/value types can be retrieved by user space introspection tool to pretty print map key/values. To associate maps with its key/value types, the below macro BPF_ANNOTATE_KV_PAIR(name, type_key, type_val) is used, similar to usage in kernel tools/testing/selftests/bpf and tools/lib/bpf. Currently, some map types (e.g, PERF_EVENT_ARRAY) do not support pretty print. But common [per_cpu] hash/array maps are supported. Currently, bcc create maps before llvm compilation. To support pretty printing of maps, map creation needs have key/value type id's which can only be obtained after compilation. Therefore, during rewriting, fake map fd is used. After compilation, btf is first loaded and maps are created. With latest bpf-next and latest trunk llvm, bpftool is able to pretty print bcc tool map key/values as below: ; running tcptop.py in one window $ tcptop.py ; running bpftool in another window $ bpftool m s ... 343: hash name ipv4_send_bytes flags 0x0 key 16B value 8B max_entries 10240 memlock 1003520B 344: hash name ipv4_recv_bytes flags 0x0 key 16B value 8B max_entries 10240 memlock 1003520B 345: hash name ipv6_send_bytes flags 0x0 key 64B value 8B max_entries 10240 memlock 1495040B 346: hash name ipv6_recv_bytes flags 0x0 key 64B value 8B max_entries 10240 memlock 1495040B $ bpftool m d id 345 ... },{ "key": { "pid": 5511, "saddr": 0x100007fffff00000000000000000000, "daddr": 0x100007fffff00000000000000000000, "lport": 2378, "dport": 52602 }, "value": 49 },{ "key": { "pid": 2823, "saddr": 0x4e000000cefa7bb0300000db0124, "daddr": 0x60000000cefa7bb0300000db0124, "lport": 2406, "dport": 49348 }, "value": 36 } ... Signed-off-by: Yonghong Song <yhs@fb.com>
yonghong-song
force-pushed
the
yhs_dev
branch
from
February 11, 2019 01:24
d1ba693
to
2787ff7
Compare
palexster
pushed a commit
to palexster/bcc
that referenced
this pull request
Jul 7, 2019
Added bpf support for maps so map key/value types can be retrieved by user space introspection tool to pretty print map key/values. To associate maps with its key/value types, the below macro BPF_ANNOTATE_KV_PAIR(name, type_key, type_val) is used, similar to usage in kernel tools/testing/selftests/bpf and tools/lib/bpf. Currently, some map types (e.g, PERF_EVENT_ARRAY) do not support pretty print. But common [per_cpu] hash/array maps are supported. Currently, bcc create maps before llvm compilation. To support pretty printing of maps, map creation needs have key/value type id's which can only be obtained after compilation. Therefore, during rewriting, fake map fd is used. After compilation, btf is first loaded and maps are created. With latest bpf-next and latest trunk llvm, bpftool is able to pretty print bcc tool map key/values as below: ; running tcptop.py in one window $ tcptop.py ; running bpftool in another window $ bpftool m s ... 343: hash name ipv4_send_bytes flags 0x0 key 16B value 8B max_entries 10240 memlock 1003520B 344: hash name ipv4_recv_bytes flags 0x0 key 16B value 8B max_entries 10240 memlock 1003520B 345: hash name ipv6_send_bytes flags 0x0 key 64B value 8B max_entries 10240 memlock 1495040B 346: hash name ipv6_recv_bytes flags 0x0 key 64B value 8B max_entries 10240 memlock 1495040B $ bpftool m d id 345 ... },{ "key": { "pid": 5511, "saddr": 0x100007fffff00000000000000000000, "daddr": 0x100007fffff00000000000000000000, "lport": 2378, "dport": 52602 }, "value": 49 },{ "key": { "pid": 2823, "saddr": 0x4e000000cefa7bb0300000db0124, "daddr": 0x60000000cefa7bb0300000db0124, "lport": 2406, "dport": 49348 }, "value": 36 } ... Signed-off-by: Yonghong Song <yhs@fb.com>
CrackerCat
pushed a commit
to CrackerCat/bcc
that referenced
this pull request
Jul 31, 2024
Added bpf support for maps so map key/value types can be retrieved by user space introspection tool to pretty print map key/values. To associate maps with its key/value types, the below macro BPF_ANNOTATE_KV_PAIR(name, type_key, type_val) is used, similar to usage in kernel tools/testing/selftests/bpf and tools/lib/bpf. Currently, some map types (e.g, PERF_EVENT_ARRAY) do not support pretty print. But common [per_cpu] hash/array maps are supported. Currently, bcc create maps before llvm compilation. To support pretty printing of maps, map creation needs have key/value type id's which can only be obtained after compilation. Therefore, during rewriting, fake map fd is used. After compilation, btf is first loaded and maps are created. With latest bpf-next and latest trunk llvm, bpftool is able to pretty print bcc tool map key/values as below: ; running tcptop.py in one window $ tcptop.py ; running bpftool in another window $ bpftool m s ... 343: hash name ipv4_send_bytes flags 0x0 key 16B value 8B max_entries 10240 memlock 1003520B 344: hash name ipv4_recv_bytes flags 0x0 key 16B value 8B max_entries 10240 memlock 1003520B 345: hash name ipv6_send_bytes flags 0x0 key 64B value 8B max_entries 10240 memlock 1495040B 346: hash name ipv6_recv_bytes flags 0x0 key 64B value 8B max_entries 10240 memlock 1495040B $ bpftool m d id 345 ... },{ "key": { "pid": 5511, "saddr": 0x100007fffff00000000000000000000, "daddr": 0x100007fffff00000000000000000000, "lport": 2378, "dport": 52602 }, "value": 49 },{ "key": { "pid": 2823, "saddr": 0x4e000000cefa7bb0300000db0124, "daddr": 0x60000000cefa7bb0300000db0124, "lport": 2406, "dport": 49348 }, "value": 36 } ... Signed-off-by: Yonghong Song <yhs@fb.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added bpf support for maps so map key/value types can be
retrieved by user space introspection tool to pretty
print map key/values.
To associate maps with its key/value types, the below macro
is used, similar to usage in kernel tools/testing/selftests/bpf
and tools/lib/bpf. Currently, some map types (e.g,
PERF_EVENT_ARRAY
)do not support pretty print. But common [per_cpu] hash/array maps
are supported.
Currently, bcc create maps before llvm compilation.
To support pretty printing of maps, map creation
needs have key/value type id's which can only be
obtained after compilation. Therefore, during rewriting,
fake map fd is used. After compilation, btf is first
loaded and maps are created.
With latest bpf-next and latest trunk llvm,
bpftool is able to pretty print bcc tool map key/values
as below:
Signed-off-by: Yonghong Song yhs@fb.com