diff options
author | Bernhard Kaindl <bernhardkaindl7@gmail.com> | 2024-05-07 22:34:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-07 13:34:32 -0700 |
commit | 77c05910b1be96467547904c837da9eab7b775a5 (patch) | |
tree | 1c64e86a91b58233133970dde47c81f50049361f | |
parent | fef9003e2e2f29c893543d49b762dd413a352f05 (diff) | |
download | bcc-77c05910b1be96467547904c837da9eab7b775a5.tar.gz |
profile.py: On pre-5.7 kernels, skip pid ns mapping (fallback) (#4974)
bpf_get_ns_current_pid_tgid() is not available before Linux 5.7:
When the kernel is prior to 5.7, skip pid namespace translation,
as bpf_get_ns_current_pid_tgid() would not be available then.
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
-rwxr-xr-x | tools/profile.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/profile.py b/tools/profile.py index 7961550a..74259256 100755 --- a/tools/profile.py +++ b/tools/profile.py @@ -228,6 +228,9 @@ int do_perf_event(struct bpf_perf_event_data *ctx) { # pid-namespace translation try: devinfo = os.stat("/proc/self/ns/pid") + version = "".join([ver.zfill(2) for ver in os.uname().release.split(".")]) + # Need Linux >= 5.7 to have helper bpf_get_ns_current_pid_tgid() available: + assert(version[:4] >= "0507") bpf_text = bpf_text.replace('USE_PIDNS', "1") bpf_text = bpf_text.replace('PIDNS_DEV', str(devinfo.st_dev)) bpf_text = bpf_text.replace('PIDNS_INO', str(devinfo.st_ino)) |