Rebase to the latest version
Rebase bcc to bcc-0.27.0. Resolves: bz#2117708 Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
This commit is contained in:
parent
07adf8a6f2
commit
fa672ef8dd
1
.gitignore
vendored
1
.gitignore
vendored
@ -19,3 +19,4 @@
|
|||||||
/bcc-0.24.0.tar.gz
|
/bcc-0.24.0.tar.gz
|
||||||
/bcc-0.25.0.tar.gz
|
/bcc-0.25.0.tar.gz
|
||||||
/bcc-0.26.0.tar.gz
|
/bcc-0.26.0.tar.gz
|
||||||
|
/bcc-0.27.0.tar.gz
|
||||||
|
@ -1,198 +0,0 @@
|
|||||||
From f47f9a045b70789ca4ed00799d3622ae348c2136 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jerome Marchand <jmarchan@redhat.com>
|
|
||||||
Date: Wed, 15 Mar 2023 13:01:28 +0100
|
|
||||||
Subject: [PATCH] Porting from distutils to setuptools
|
|
||||||
|
|
||||||
Distutils has been deprecated in python 3.10 and will be removed from
|
|
||||||
python 3.12. Distutils itself has for a long time recommended to use
|
|
||||||
setuptools instead.
|
|
||||||
|
|
||||||
This patch migrate from distutils to setuptools mostly using using the
|
|
||||||
migration advice from PEP 632:
|
|
||||||
https://peps.python.org/pep-0632/
|
|
||||||
|
|
||||||
The use of packaging.version.Version() doesn't work with the kernel
|
|
||||||
version format of some distribution (incompatible with PEP 440), so I
|
|
||||||
replaced it by an adhoc regex parsing.
|
|
||||||
|
|
||||||
Also remove a couple of unused distutils import.
|
|
||||||
|
|
||||||
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
|
||||||
---
|
|
||||||
INSTALL.md | 12 ++++++------
|
|
||||||
examples/usdt_sample/usdt_sample.md | 2 +-
|
|
||||||
examples/usdt_sample/usdt_sample.sh | 2 +-
|
|
||||||
snap/snapcraft.yaml | 3 +--
|
|
||||||
src/python/setup.py.in | 2 +-
|
|
||||||
tests/python/test_rlimit.py | 1 -
|
|
||||||
tests/python/test_tools_smoke.py | 1 -
|
|
||||||
tests/python/utils.py | 18 ++++++++++--------
|
|
||||||
8 files changed, 20 insertions(+), 21 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/INSTALL.md b/INSTALL.md
|
|
||||||
index da10fc30..abbe8809 100644
|
|
||||||
--- a/INSTALL.md
|
|
||||||
+++ b/INSTALL.md
|
|
||||||
@@ -344,7 +344,7 @@ sudo apt-get install arping bison clang-format cmake dh-python \
|
|
||||||
dpkg-dev pkg-kde-tools ethtool flex inetutils-ping iperf \
|
|
||||||
libbpf-dev libclang-dev libclang-cpp-dev libedit-dev libelf-dev \
|
|
||||||
libfl-dev libzip-dev linux-libc-dev llvm-dev libluajit-5.1-dev \
|
|
||||||
- luajit python3-netaddr python3-pyroute2 python3-distutils python3
|
|
||||||
+ luajit python3-netaddr python3-pyroute2 python3-setuptools python3
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Install and compile BCC
|
|
||||||
@@ -376,23 +376,23 @@ sudo apt-get update
|
|
||||||
|
|
||||||
# For Bionic (18.04 LTS)
|
|
||||||
sudo apt-get -y install bison build-essential cmake flex git libedit-dev \
|
|
||||||
- libllvm6.0 llvm-6.0-dev libclang-6.0-dev python zlib1g-dev libelf-dev libfl-dev python3-distutils
|
|
||||||
+ libllvm6.0 llvm-6.0-dev libclang-6.0-dev python zlib1g-dev libelf-dev libfl-dev python3-setuptools
|
|
||||||
|
|
||||||
# For Focal (20.04.1 LTS)
|
|
||||||
sudo apt install -y bison build-essential cmake flex git libedit-dev \
|
|
||||||
- libllvm12 llvm-12-dev libclang-12-dev python zlib1g-dev libelf-dev libfl-dev python3-distutils
|
|
||||||
+ libllvm12 llvm-12-dev libclang-12-dev python zlib1g-dev libelf-dev libfl-dev python3-setuptools
|
|
||||||
|
|
||||||
# For Hirsute (21.04) or Impish (21.10)
|
|
||||||
sudo apt install -y bison build-essential cmake flex git libedit-dev \
|
|
||||||
-libllvm11 llvm-11-dev libclang-11-dev python3 zlib1g-dev libelf-dev libfl-dev python3-distutils
|
|
||||||
+libllvm11 llvm-11-dev libclang-11-dev python3 zlib1g-dev libelf-dev libfl-dev python3-setuptools
|
|
||||||
|
|
||||||
# For Jammy (22.04)
|
|
||||||
sudo apt install -y bison build-essential cmake flex git libedit-dev \
|
|
||||||
-libllvm14 llvm-14-dev libclang-14-dev python3 zlib1g-dev libelf-dev libfl-dev python3-distutils
|
|
||||||
+libllvm14 llvm-14-dev libclang-14-dev python3 zlib1g-dev libelf-dev libfl-dev python3-setuptools
|
|
||||||
|
|
||||||
# For other versions
|
|
||||||
sudo apt-get -y install bison build-essential cmake flex git libedit-dev \
|
|
||||||
- libllvm3.7 llvm-3.7-dev libclang-3.7-dev python zlib1g-dev libelf-dev python3-distutils
|
|
||||||
+ libllvm3.7 llvm-3.7-dev libclang-3.7-dev python zlib1g-dev libelf-dev python3-setuptools
|
|
||||||
|
|
||||||
# For Lua support
|
|
||||||
sudo apt-get -y install luajit luajit-5.1-dev
|
|
||||||
diff --git a/examples/usdt_sample/usdt_sample.md b/examples/usdt_sample/usdt_sample.md
|
|
||||||
index d3561322..1eee9038 100644
|
|
||||||
--- a/examples/usdt_sample/usdt_sample.md
|
|
||||||
+++ b/examples/usdt_sample/usdt_sample.md
|
|
||||||
@@ -4,7 +4,7 @@
|
|
||||||
## Ubuntu 21.10 prerequisites
|
|
||||||
|
|
||||||
```bash
|
|
||||||
-$ sudo apt-get install linux-headers-$(uname -r) "llvm-13*" libclang-13-dev luajit luajit-5.1-dev libelf-dev python3-distutils libdebuginfod-dev arping netperf iperf
|
|
||||||
+$ sudo apt-get install linux-headers-$(uname -r) "llvm-13*" libclang-13-dev luajit luajit-5.1-dev libelf-dev python3-setutools libdebuginfod-dev arping netperf iperf
|
|
||||||
```
|
|
||||||
|
|
||||||
## Building bcc tools
|
|
||||||
diff --git a/examples/usdt_sample/usdt_sample.sh b/examples/usdt_sample/usdt_sample.sh
|
|
||||||
index 8b147694..2a90d159 100755
|
|
||||||
--- a/examples/usdt_sample/usdt_sample.sh
|
|
||||||
+++ b/examples/usdt_sample/usdt_sample.sh
|
|
||||||
@@ -1,6 +1,6 @@
|
|
||||||
#!/usr/bin/bash
|
|
||||||
|
|
||||||
-# sudo apt-get install linux-headers-$(uname -r) "llvm-13*" libclang-13-dev luajit luajit-5.1-dev libelf-dev python3-distutils libdebuginfod-dev arping netperf iperf
|
|
||||||
+# sudo apt-get install linux-headers-$(uname -r) "llvm-13*" libclang-13-dev luajit luajit-5.1-dev libelf-dev python3-setuptools libdebuginfod-dev arping netperf iperf
|
|
||||||
# mkdir -p build && cd build
|
|
||||||
# cmake .. -DPYTHON_CMD=python3
|
|
||||||
# make -j4
|
|
||||||
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
|
|
||||||
index 9eedafd9..d6c87e3e 100644
|
|
||||||
--- a/snap/snapcraft.yaml
|
|
||||||
+++ b/snap/snapcraft.yaml
|
|
||||||
@@ -85,8 +85,7 @@ adopt-info: bcc
|
|
||||||
- libtinfo5
|
|
||||||
- libzzip-0-13
|
|
||||||
- python3
|
|
||||||
- - python3-distutils
|
|
||||||
- - python3-distutils-extra
|
|
||||||
+ - python3-packaging
|
|
||||||
- python3-pip
|
|
||||||
- python3-setuptools
|
|
||||||
prime:
|
|
||||||
diff --git a/src/python/setup.py.in b/src/python/setup.py.in
|
|
||||||
index dca35541..46e20602 100644
|
|
||||||
--- a/src/python/setup.py.in
|
|
||||||
+++ b/src/python/setup.py.in
|
|
||||||
@@ -1,6 +1,6 @@
|
|
||||||
# Copyright (c) PLUMgrid, Inc.
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License")
|
|
||||||
-from distutils.core import setup
|
|
||||||
+from setuptools import setup
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
diff --git a/tests/python/test_rlimit.py b/tests/python/test_rlimit.py
|
|
||||||
index 040b99c1..39d8aac6 100755
|
|
||||||
--- a/tests/python/test_rlimit.py
|
|
||||||
+++ b/tests/python/test_rlimit.py
|
|
||||||
@@ -9,7 +9,6 @@ from __future__ import print_function
|
|
||||||
from bcc import BPF
|
|
||||||
from unittest import main, skipUnless, TestCase
|
|
||||||
from utils import kernel_version_ge
|
|
||||||
-import distutils.version
|
|
||||||
import os, resource
|
|
||||||
|
|
||||||
@skipUnless(not kernel_version_ge(5, 11), "Since d5299b67dd59 \"bpf: Memcg-based memory accounting for bpf maps\""\
|
|
||||||
diff --git a/tests/python/test_tools_smoke.py b/tests/python/test_tools_smoke.py
|
|
||||||
index aa821b9e..c8023f74 100755
|
|
||||||
--- a/tests/python/test_tools_smoke.py
|
|
||||||
+++ b/tests/python/test_tools_smoke.py
|
|
||||||
@@ -2,7 +2,6 @@
|
|
||||||
# Copyright (c) Sasha Goldshtein, 2017
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License")
|
|
||||||
|
|
||||||
-import distutils.version
|
|
||||||
import subprocess
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
diff --git a/tests/python/utils.py b/tests/python/utils.py
|
|
||||||
index 40e7b157..23404787 100644
|
|
||||||
--- a/tests/python/utils.py
|
|
||||||
+++ b/tests/python/utils.py
|
|
||||||
@@ -1,10 +1,8 @@
|
|
||||||
from pyroute2 import NSPopen
|
|
||||||
-from distutils.spawn import find_executable
|
|
||||||
import traceback
|
|
||||||
-import distutils.version
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
-import logging, os, sys
|
|
||||||
+import logging, os, sys, re
|
|
||||||
|
|
||||||
if 'PYTHON_TEST_LOGFILE' in os.environ:
|
|
||||||
logfile=os.environ['PYTHON_TEST_LOGFILE']
|
|
||||||
@@ -15,7 +13,7 @@ import logging, os, sys
|
|
||||||
logger = logging.getLogger()
|
|
||||||
|
|
||||||
def has_executable(name):
|
|
||||||
- path = find_executable(name)
|
|
||||||
+ path = shutil.which(name)
|
|
||||||
if path is None:
|
|
||||||
raise Exception(name + ": command not found")
|
|
||||||
return path
|
|
||||||
@@ -82,13 +80,17 @@ logger = logging.getLogger()
|
|
||||||
has_executable(name)
|
|
||||||
super(NSPopenWithCheck, self).__init__(nsname, *argv, **kwarg)
|
|
||||||
|
|
||||||
+KERNEL_VERSION_PATTERN = r"v?(?P<major>[0-9]+)\.(?P<minor>[0-9]+).*"
|
|
||||||
+
|
|
||||||
def kernel_version_ge(major, minor):
|
|
||||||
# True if running kernel is >= X.Y
|
|
||||||
- version = distutils.version.LooseVersion(os.uname()[2]).version
|
|
||||||
- if version[0] > major:
|
|
||||||
+ match = re.match(KERNEL_VERSION_PATTERN, os.uname()[2])
|
|
||||||
+ x = int(match.group("major"))
|
|
||||||
+ y = int(match.group("minor"))
|
|
||||||
+ if x > major:
|
|
||||||
return True
|
|
||||||
- if version[0] < major:
|
|
||||||
+ if x < major:
|
|
||||||
return False
|
|
||||||
- if minor and version[1] < minor:
|
|
||||||
+ if minor and y < minor:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
|
|
226610
Updating-Powerpc-vmlinux-headers-from-Linux-kernel-6.patch
Normal file
226610
Updating-Powerpc-vmlinux-headers-from-Linux-kernel-6.patch
Normal file
File diff suppressed because it is too large
Load Diff
12
bcc.spec
12
bcc.spec
@ -24,15 +24,14 @@
|
|||||||
|
|
||||||
|
|
||||||
Name: bcc
|
Name: bcc
|
||||||
Version: 0.26.0
|
Version: 0.27.0
|
||||||
Release: 2%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: BPF Compiler Collection (BCC)
|
Summary: BPF Compiler Collection (BCC)
|
||||||
License: ASL 2.0
|
License: ASL 2.0
|
||||||
URL: https://github.com/iovisor/bcc
|
URL: https://github.com/iovisor/bcc
|
||||||
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
|
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||||
Patch0: tools-slabratetop-Fix-error-incomplete-definition-of.patch
|
Patch0: Updating-Powerpc-vmlinux-headers-from-Linux-kernel-6.patch
|
||||||
Patch1: tools-readahead-Fix-Failed-to-attach-BPF-program-ent.patch
|
Patch1: sync-with-latest-libbpf-repo.patch
|
||||||
Patch2: Porting-from-distutils-to-setuptools.patch
|
|
||||||
|
|
||||||
# Arches will be included as upstream support is added and dependencies are
|
# Arches will be included as upstream support is added and dependencies are
|
||||||
# satisfied in the respective arches
|
# satisfied in the respective arches
|
||||||
@ -241,6 +240,9 @@ cp -a libbpf-tools/tmp-install/bin/* %{buildroot}/%{_sbindir}/
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Apr 21 2023 Jerome Marchand <jmarchan@redhat.com> - 0.27.0-1
|
||||||
|
- Rebase to the latest release version (#2117708)
|
||||||
|
|
||||||
* Mon Apr 03 2023 Jerome Marchand <jmarchan@redhat.com> - 0.26.0-2
|
* Mon Apr 03 2023 Jerome Marchand <jmarchan@redhat.com> - 0.26.0-2
|
||||||
- Remove the dependency on distutils (RHBZ#2155029)
|
- Remove the dependency on distutils (RHBZ#2155029)
|
||||||
- Fix macro-in-comment (fedpkg lint warning)
|
- Fix macro-in-comment (fedpkg lint warning)
|
||||||
|
2
sources
2
sources
@ -1 +1 @@
|
|||||||
SHA512 (bcc-0.26.0.tar.gz) = 394872a5780cc7651c91b584ccc13f18f64585b5843364433c042d9ded70faaf15a2e1125d51498508427b089f5bf826f13004d15a1892aada1a5f228a2a8adb
|
SHA512 (bcc-0.27.0.tar.gz) = 16df9f42444bcac3be967a43ba4183349b71e75c370957f518977051968277f9ffa8a5e3dfdb2f3bdc9b6b59b575ed82e694f5504ebc74bc0ca4cf3a4b753bfd
|
||||||
|
364
sync-with-latest-libbpf-repo.patch
Normal file
364
sync-with-latest-libbpf-repo.patch
Normal file
@ -0,0 +1,364 @@
|
|||||||
|
From 70e879960428f5726067db93f7c742c8b39d4886 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yonghong Song <yhs@fb.com>
|
||||||
|
Date: Wed, 19 Apr 2023 23:46:53 -0700
|
||||||
|
Subject: [PATCH] sync with latest libbpf repo
|
||||||
|
|
||||||
|
Sync libbpf submodule up to the following commit:
|
||||||
|
44b0bc9ad70a ci: Regenerate latest vmlinux.h for old kernel CI tests.
|
||||||
|
|
||||||
|
Signed-off-by: Yonghong Song <yhs@fb.com>
|
||||||
|
---
|
||||||
|
src/cc/compat/linux/virtual_bpf.h | 141 ++++++++++++++++++++++++++----
|
||||||
|
src/cc/export/helpers.h | 6 +-
|
||||||
|
src/cc/libbpf | 2 +-
|
||||||
|
3 files changed, 127 insertions(+), 22 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/cc/compat/linux/virtual_bpf.h b/src/cc/compat/linux/virtual_bpf.h
|
||||||
|
index be3a4627..a182123e 100644
|
||||||
|
--- a/src/cc/compat/linux/virtual_bpf.h
|
||||||
|
+++ b/src/cc/compat/linux/virtual_bpf.h
|
||||||
|
@@ -1034,6 +1034,7 @@ enum bpf_attach_type {
|
||||||
|
BPF_PERF_EVENT,
|
||||||
|
BPF_TRACE_KPROBE_MULTI,
|
||||||
|
BPF_LSM_CGROUP,
|
||||||
|
+ BPF_STRUCT_OPS,
|
||||||
|
__MAX_BPF_ATTACH_TYPE
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -1109,7 +1110,7 @@ enum bpf_link_type {
|
||||||
|
*/
|
||||||
|
#define BPF_F_STRICT_ALIGNMENT (1U << 0)
|
||||||
|
|
||||||
|
-/* If BPF_F_ANY_ALIGNMENT is used in BPF_PROF_LOAD command, the
|
||||||
|
+/* If BPF_F_ANY_ALIGNMENT is used in BPF_PROG_LOAD command, the
|
||||||
|
* verifier will allow any alignment whatsoever. On platforms
|
||||||
|
* with strict alignment requirements for loads ands stores (such
|
||||||
|
* as sparc and mips) the verifier validates that all loads and
|
||||||
|
@@ -1157,6 +1158,11 @@ enum bpf_link_type {
|
||||||
|
*/
|
||||||
|
#define BPF_F_XDP_HAS_FRAGS (1U << 5)
|
||||||
|
|
||||||
|
+/* If BPF_F_XDP_DEV_BOUND_ONLY is used in BPF_PROG_LOAD command, the loaded
|
||||||
|
+ * program becomes device-bound but can access XDP metadata.
|
||||||
|
+ */
|
||||||
|
+#define BPF_F_XDP_DEV_BOUND_ONLY (1U << 6)
|
||||||
|
+
|
||||||
|
/* link_create.kprobe_multi.flags used in LINK_CREATE command for
|
||||||
|
* BPF_TRACE_KPROBE_MULTI attach type to create return probe.
|
||||||
|
*/
|
||||||
|
@@ -1262,6 +1268,9 @@ enum {
|
||||||
|
|
||||||
|
/* Create a map that is suitable to be an inner map with dynamic max entries */
|
||||||
|
BPF_F_INNER_MAP = (1U << 12),
|
||||||
|
+
|
||||||
|
+/* Create a map that will be registered/unregesitered by the backed bpf_link */
|
||||||
|
+ BPF_F_LINK = (1U << 13),
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Flags for BPF_PROG_QUERY. */
|
||||||
|
@@ -1399,6 +1408,11 @@ union bpf_attr {
|
||||||
|
__aligned_u64 fd_array; /* array of FDs */
|
||||||
|
__aligned_u64 core_relos;
|
||||||
|
__u32 core_relo_rec_size; /* sizeof(struct bpf_core_relo) */
|
||||||
|
+ /* output: actual total log contents size (including termintaing zero).
|
||||||
|
+ * It could be both larger than original log_size (if log was
|
||||||
|
+ * truncated), or smaller (if log buffer wasn't filled completely).
|
||||||
|
+ */
|
||||||
|
+ __u32 log_true_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct { /* anonymous struct used by BPF_OBJ_* commands */
|
||||||
|
@@ -1484,6 +1498,11 @@ union bpf_attr {
|
||||||
|
__u32 btf_size;
|
||||||
|
__u32 btf_log_size;
|
||||||
|
__u32 btf_log_level;
|
||||||
|
+ /* output: actual total log contents size (including termintaing zero).
|
||||||
|
+ * It could be both larger than original log_size (if log was
|
||||||
|
+ * truncated), or smaller (if log buffer wasn't filled completely).
|
||||||
|
+ */
|
||||||
|
+ __u32 btf_log_true_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct {
|
||||||
|
@@ -1503,7 +1522,10 @@ union bpf_attr {
|
||||||
|
} task_fd_query;
|
||||||
|
|
||||||
|
struct { /* struct used by BPF_LINK_CREATE command */
|
||||||
|
- __u32 prog_fd; /* eBPF program to attach */
|
||||||
|
+ union {
|
||||||
|
+ __u32 prog_fd; /* eBPF program to attach */
|
||||||
|
+ __u32 map_fd; /* struct_ops to attach */
|
||||||
|
+ };
|
||||||
|
union {
|
||||||
|
__u32 target_fd; /* object to attach to */
|
||||||
|
__u32 target_ifindex; /* target ifindex */
|
||||||
|
@@ -1544,12 +1566,23 @@ union bpf_attr {
|
||||||
|
|
||||||
|
struct { /* struct used by BPF_LINK_UPDATE command */
|
||||||
|
__u32 link_fd; /* link fd */
|
||||||
|
- /* new program fd to update link with */
|
||||||
|
- __u32 new_prog_fd;
|
||||||
|
+ union {
|
||||||
|
+ /* new program fd to update link with */
|
||||||
|
+ __u32 new_prog_fd;
|
||||||
|
+ /* new struct_ops map fd to update link with */
|
||||||
|
+ __u32 new_map_fd;
|
||||||
|
+ };
|
||||||
|
__u32 flags; /* extra flags */
|
||||||
|
- /* expected link's program fd; is specified only if
|
||||||
|
- * BPF_F_REPLACE flag is set in flags */
|
||||||
|
- __u32 old_prog_fd;
|
||||||
|
+ union {
|
||||||
|
+ /* expected link's program fd; is specified only if
|
||||||
|
+ * BPF_F_REPLACE flag is set in flags.
|
||||||
|
+ */
|
||||||
|
+ __u32 old_prog_fd;
|
||||||
|
+ /* expected link's map fd; is specified only
|
||||||
|
+ * if BPF_F_REPLACE flag is set.
|
||||||
|
+ */
|
||||||
|
+ __u32 old_map_fd;
|
||||||
|
+ };
|
||||||
|
} link_update;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
@@ -1643,17 +1676,17 @@ union bpf_attr {
|
||||||
|
* Description
|
||||||
|
* This helper is a "printk()-like" facility for debugging. It
|
||||||
|
* prints a message defined by format *fmt* (of size *fmt_size*)
|
||||||
|
- * to file *\/sys/kernel/debug/tracing/trace* from DebugFS, if
|
||||||
|
+ * to file *\/sys/kernel/tracing/trace* from TraceFS, if
|
||||||
|
* available. It can take up to three additional **u64**
|
||||||
|
* arguments (as an eBPF helpers, the total number of arguments is
|
||||||
|
* limited to five).
|
||||||
|
*
|
||||||
|
* Each time the helper is called, it appends a line to the trace.
|
||||||
|
- * Lines are discarded while *\/sys/kernel/debug/tracing/trace* is
|
||||||
|
- * open, use *\/sys/kernel/debug/tracing/trace_pipe* to avoid this.
|
||||||
|
+ * Lines are discarded while *\/sys/kernel/tracing/trace* is
|
||||||
|
+ * open, use *\/sys/kernel/tracing/trace_pipe* to avoid this.
|
||||||
|
* The format of the trace is customizable, and the exact output
|
||||||
|
* one will get depends on the options set in
|
||||||
|
- * *\/sys/kernel/debug/tracing/trace_options* (see also the
|
||||||
|
+ * *\/sys/kernel/tracing/trace_options* (see also the
|
||||||
|
* *README* file under the same directory). However, it usually
|
||||||
|
* defaults to something like:
|
||||||
|
*
|
||||||
|
@@ -2002,6 +2035,9 @@ union bpf_attr {
|
||||||
|
* sending the packet. This flag was added for GRE
|
||||||
|
* encapsulation, but might be used with other protocols
|
||||||
|
* as well in the future.
|
||||||
|
+ * **BPF_F_NO_TUNNEL_KEY**
|
||||||
|
+ * Add a flag to tunnel metadata indicating that no tunnel
|
||||||
|
+ * key should be set in the resulting tunnel header.
|
||||||
|
*
|
||||||
|
* Here is a typical usage on the transmit path:
|
||||||
|
*
|
||||||
|
@@ -2645,6 +2681,11 @@ union bpf_attr {
|
||||||
|
* Use with BPF_F_ADJ_ROOM_ENCAP_L2 flag to further specify the
|
||||||
|
* L2 type as Ethernet.
|
||||||
|
*
|
||||||
|
+ * * **BPF_F_ADJ_ROOM_DECAP_L3_IPV4**,
|
||||||
|
+ * **BPF_F_ADJ_ROOM_DECAP_L3_IPV6**:
|
||||||
|
+ * Indicate the new IP header version after decapsulating the outer
|
||||||
|
+ * IP header. Used when the inner and outer IP versions are different.
|
||||||
|
+ *
|
||||||
|
* A call to this helper is susceptible to change the underlying
|
||||||
|
* packet buffer. Therefore, at load time, all checks on pointers
|
||||||
|
* previously done by the verifier are invalidated and must be
|
||||||
|
@@ -2789,7 +2830,7 @@ union bpf_attr {
|
||||||
|
*
|
||||||
|
* long bpf_perf_prog_read_value(struct bpf_perf_event_data *ctx, struct bpf_perf_event_value *buf, u32 buf_size)
|
||||||
|
* Description
|
||||||
|
- * For en eBPF program attached to a perf event, retrieve the
|
||||||
|
+ * For an eBPF program attached to a perf event, retrieve the
|
||||||
|
* value of the event counter associated to *ctx* and store it in
|
||||||
|
* the structure pointed by *buf* and of size *buf_size*. Enabled
|
||||||
|
* and running times are also stored in the structure (see
|
||||||
|
@@ -3122,6 +3163,11 @@ union bpf_attr {
|
||||||
|
* **BPF_FIB_LOOKUP_OUTPUT**
|
||||||
|
* Perform lookup from an egress perspective (default is
|
||||||
|
* ingress).
|
||||||
|
+ * **BPF_FIB_LOOKUP_SKIP_NEIGH**
|
||||||
|
+ * Skip the neighbour table lookup. *params*->dmac
|
||||||
|
+ * and *params*->smac will not be set as output. A common
|
||||||
|
+ * use case is to call **bpf_redirect_neigh**\ () after
|
||||||
|
+ * doing **bpf_fib_lookup**\ ().
|
||||||
|
*
|
||||||
|
* *ctx* is either **struct xdp_md** for XDP programs or
|
||||||
|
* **struct sk_buff** tc cls_act programs.
|
||||||
|
@@ -4952,6 +4998,12 @@ union bpf_attr {
|
||||||
|
* different maps if key/value layout matches across maps.
|
||||||
|
* Every bpf_timer_set_callback() can have different callback_fn.
|
||||||
|
*
|
||||||
|
+ * *flags* can be one of:
|
||||||
|
+ *
|
||||||
|
+ * **BPF_F_TIMER_ABS**
|
||||||
|
+ * Start the timer in absolute expire value instead of the
|
||||||
|
+ * default relative one.
|
||||||
|
+ *
|
||||||
|
* Return
|
||||||
|
* 0 on success.
|
||||||
|
* **-EINVAL** if *timer* was not initialized with bpf_timer_init() earlier
|
||||||
|
@@ -5294,7 +5346,7 @@ union bpf_attr {
|
||||||
|
* Return
|
||||||
|
* Nothing. Always succeeds.
|
||||||
|
*
|
||||||
|
- * long bpf_dynptr_read(void *dst, u32 len, struct bpf_dynptr *src, u32 offset, u64 flags)
|
||||||
|
+ * long bpf_dynptr_read(void *dst, u32 len, const struct bpf_dynptr *src, u32 offset, u64 flags)
|
||||||
|
* Description
|
||||||
|
* Read *len* bytes from *src* into *dst*, starting from *offset*
|
||||||
|
* into *src*.
|
||||||
|
@@ -5304,22 +5356,36 @@ union bpf_attr {
|
||||||
|
* of *src*'s data, -EINVAL if *src* is an invalid dynptr or if
|
||||||
|
* *flags* is not 0.
|
||||||
|
*
|
||||||
|
- * long bpf_dynptr_write(struct bpf_dynptr *dst, u32 offset, void *src, u32 len, u64 flags)
|
||||||
|
+ * long bpf_dynptr_write(const struct bpf_dynptr *dst, u32 offset, void *src, u32 len, u64 flags)
|
||||||
|
* Description
|
||||||
|
* Write *len* bytes from *src* into *dst*, starting from *offset*
|
||||||
|
* into *dst*.
|
||||||
|
- * *flags* is currently unused.
|
||||||
|
+ *
|
||||||
|
+ * *flags* must be 0 except for skb-type dynptrs.
|
||||||
|
+ *
|
||||||
|
+ * For skb-type dynptrs:
|
||||||
|
+ * * All data slices of the dynptr are automatically
|
||||||
|
+ * invalidated after **bpf_dynptr_write**\ (). This is
|
||||||
|
+ * because writing may pull the skb and change the
|
||||||
|
+ * underlying packet buffer.
|
||||||
|
+ *
|
||||||
|
+ * * For *flags*, please see the flags accepted by
|
||||||
|
+ * **bpf_skb_store_bytes**\ ().
|
||||||
|
* Return
|
||||||
|
* 0 on success, -E2BIG if *offset* + *len* exceeds the length
|
||||||
|
* of *dst*'s data, -EINVAL if *dst* is an invalid dynptr or if *dst*
|
||||||
|
- * is a read-only dynptr or if *flags* is not 0.
|
||||||
|
+ * is a read-only dynptr or if *flags* is not correct. For skb-type dynptrs,
|
||||||
|
+ * other errors correspond to errors returned by **bpf_skb_store_bytes**\ ().
|
||||||
|
*
|
||||||
|
- * void *bpf_dynptr_data(struct bpf_dynptr *ptr, u32 offset, u32 len)
|
||||||
|
+ * void *bpf_dynptr_data(const struct bpf_dynptr *ptr, u32 offset, u32 len)
|
||||||
|
* Description
|
||||||
|
* Get a pointer to the underlying dynptr data.
|
||||||
|
*
|
||||||
|
* *len* must be a statically known value. The returned data slice
|
||||||
|
* is invalidated whenever the dynptr is invalidated.
|
||||||
|
+ *
|
||||||
|
+ * skb and xdp type dynptrs may not use bpf_dynptr_data. They should
|
||||||
|
+ * instead use bpf_dynptr_slice and bpf_dynptr_slice_rdwr.
|
||||||
|
* Return
|
||||||
|
* Pointer to the underlying dynptr data, NULL if the dynptr is
|
||||||
|
* read-only, if the dynptr is invalid, or if the offset and length
|
||||||
|
@@ -5415,7 +5481,7 @@ union bpf_attr {
|
||||||
|
* Drain samples from the specified user ring buffer, and invoke
|
||||||
|
* the provided callback for each such sample:
|
||||||
|
*
|
||||||
|
- * long (\*callback_fn)(struct bpf_dynptr \*dynptr, void \*ctx);
|
||||||
|
+ * long (\*callback_fn)(const struct bpf_dynptr \*dynptr, void \*ctx);
|
||||||
|
*
|
||||||
|
* If **callback_fn** returns 0, the helper will continue to try
|
||||||
|
* and drain the next sample, up to a maximum of
|
||||||
|
@@ -5765,6 +5831,7 @@ enum {
|
||||||
|
BPF_F_ZERO_CSUM_TX = (1ULL << 1),
|
||||||
|
BPF_F_DONT_FRAGMENT = (1ULL << 2),
|
||||||
|
BPF_F_SEQ_NUMBER = (1ULL << 3),
|
||||||
|
+ BPF_F_NO_TUNNEL_KEY = (1ULL << 4),
|
||||||
|
};
|
||||||
|
|
||||||
|
/* BPF_FUNC_skb_get_tunnel_key flags. */
|
||||||
|
@@ -5804,6 +5871,8 @@ enum {
|
||||||
|
BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4),
|
||||||
|
BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5),
|
||||||
|
BPF_F_ADJ_ROOM_ENCAP_L2_ETH = (1ULL << 6),
|
||||||
|
+ BPF_F_ADJ_ROOM_DECAP_L3_IPV4 = (1ULL << 7),
|
||||||
|
+ BPF_F_ADJ_ROOM_DECAP_L3_IPV6 = (1ULL << 8),
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
@@ -6339,6 +6408,9 @@ struct bpf_link_info {
|
||||||
|
struct {
|
||||||
|
__u32 ifindex;
|
||||||
|
} xdp;
|
||||||
|
+ struct {
|
||||||
|
+ __u32 map_id;
|
||||||
|
+ } struct_ops;
|
||||||
|
};
|
||||||
|
} __attribute__((aligned(8)));
|
||||||
|
|
||||||
|
@@ -6735,6 +6807,7 @@ struct bpf_raw_tracepoint_args {
|
||||||
|
enum {
|
||||||
|
BPF_FIB_LOOKUP_DIRECT = (1U << 0),
|
||||||
|
BPF_FIB_LOOKUP_OUTPUT = (1U << 1),
|
||||||
|
+ BPF_FIB_LOOKUP_SKIP_NEIGH = (1U << 2),
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
@@ -6902,6 +6975,21 @@ struct bpf_list_node {
|
||||||
|
__u64 :64;
|
||||||
|
} __attribute__((aligned(8)));
|
||||||
|
|
||||||
|
+struct bpf_rb_root {
|
||||||
|
+ __u64 :64;
|
||||||
|
+ __u64 :64;
|
||||||
|
+} __attribute__((aligned(8)));
|
||||||
|
+
|
||||||
|
+struct bpf_rb_node {
|
||||||
|
+ __u64 :64;
|
||||||
|
+ __u64 :64;
|
||||||
|
+ __u64 :64;
|
||||||
|
+} __attribute__((aligned(8)));
|
||||||
|
+
|
||||||
|
+struct bpf_refcount {
|
||||||
|
+ __u32 :32;
|
||||||
|
+} __attribute__((aligned(4)));
|
||||||
|
+
|
||||||
|
struct bpf_sysctl {
|
||||||
|
__u32 write; /* Sysctl is being read (= 0) or written (= 1).
|
||||||
|
* Allows 1,2,4-byte read, but no write.
|
||||||
|
@@ -7051,5 +7139,22 @@ struct bpf_core_relo {
|
||||||
|
enum bpf_core_relo_kind kind;
|
||||||
|
};
|
||||||
|
|
||||||
|
+/*
|
||||||
|
+ * Flags to control bpf_timer_start() behaviour.
|
||||||
|
+ * - BPF_F_TIMER_ABS: Timeout passed is absolute time, by default it is
|
||||||
|
+ * relative to current time.
|
||||||
|
+ */
|
||||||
|
+enum {
|
||||||
|
+ BPF_F_TIMER_ABS = (1ULL << 0),
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+/* BPF numbers iterator state */
|
||||||
|
+struct bpf_iter_num {
|
||||||
|
+ /* opaque iterator state; having __u64 here allows to preserve correct
|
||||||
|
+ * alignment requirements in vmlinux.h, generated from BTF
|
||||||
|
+ */
|
||||||
|
+ __u64 __opaque[1];
|
||||||
|
+} __attribute__((aligned(8)));
|
||||||
|
+
|
||||||
|
#endif /* _UAPI__LINUX_BPF_H__ */
|
||||||
|
)********"
|
||||||
|
diff --git a/src/cc/export/helpers.h b/src/cc/export/helpers.h
|
||||||
|
index 3873c4a4..dae050bb 100644
|
||||||
|
--- a/src/cc/export/helpers.h
|
||||||
|
+++ b/src/cc/export/helpers.h
|
||||||
|
@@ -1006,13 +1006,13 @@ static void (*bpf_ringbuf_submit_dynptr)(struct bpf_dynptr *ptr, __u64 flags) =
|
||||||
|
(void *)BPF_FUNC_ringbuf_submit_dynptr;
|
||||||
|
static void (*bpf_ringbuf_discard_dynptr)(struct bpf_dynptr *ptr, __u64 flags) =
|
||||||
|
(void *)BPF_FUNC_ringbuf_discard_dynptr;
|
||||||
|
-static long (*bpf_dynptr_read)(void *dst, __u32 len, struct bpf_dynptr *src, __u32 offset,
|
||||||
|
+static long (*bpf_dynptr_read)(void *dst, __u32 len, const struct bpf_dynptr *src, __u32 offset,
|
||||||
|
__u64 flags) =
|
||||||
|
(void *)BPF_FUNC_dynptr_read;
|
||||||
|
-static long (*bpf_dynptr_write)(struct bpf_dynptr *dst, __u32 offset, void *src, __u32 len,
|
||||||
|
+static long (*bpf_dynptr_write)(const struct bpf_dynptr *dst, __u32 offset, void *src, __u32 len,
|
||||||
|
__u64 flags) =
|
||||||
|
(void *)BPF_FUNC_dynptr_write;
|
||||||
|
-static void *(*bpf_dynptr_data)(struct bpf_dynptr *ptr, __u32 offset, __u32 len) =
|
||||||
|
+static void *(*bpf_dynptr_data)(const struct bpf_dynptr *ptr, __u32 offset, __u32 len) =
|
||||||
|
(void *)BPF_FUNC_dynptr_data;
|
||||||
|
static __s64 (*bpf_tcp_raw_gen_syncookie_ipv4)(struct iphdr *iph, struct tcphdr *th,
|
||||||
|
__u32 th_len) =
|
||||||
|
--
|
||||||
|
2.39.2
|
||||||
|
|
@ -1,159 +0,0 @@
|
|||||||
From c5152f68588d2195295e66daccff2126de1c35cf Mon Sep 17 00:00:00 2001
|
|
||||||
From: Rong Tao <rongtao@cestc.cn>
|
|
||||||
Date: Mon, 30 Jan 2023 17:39:35 +0800
|
|
||||||
Subject: [PATCH] tools/readahead: Fix: Failed to attach BPF program
|
|
||||||
entry__do_page_cache_readahead
|
|
||||||
|
|
||||||
since commit 56a4d67c264e("mm/readahead: Switch to page_cache_ra_order") switch
|
|
||||||
do_page_cache_ra() to page_cache_ra_order() (v5.17), and commit bb3c579e25e5
|
|
||||||
("mm/filemap: Add filemap_alloc_folio") swap __page_cache_alloc() to
|
|
||||||
filemap_alloc_folio() (since v5.15)
|
|
||||||
|
|
||||||
Reprocude the error(fedora37, 6.1.7-200.fc37.aarch64):
|
|
||||||
|
|
||||||
$ sudo ./readahead.py
|
|
||||||
cannot attach kprobe, probe entry may not exist
|
|
||||||
Traceback (most recent call last):
|
|
||||||
File "/home/rongtao/Git/bcc/tools/./readahead.py", line 159, in <module>
|
|
||||||
b.attach_kprobe(event=ra_event, fn_name="entry__do_page_cache_readahead")
|
|
||||||
File "/usr/lib/python3.11/site-packages/bcc/__init__.py", line 840, in attach_kprobe
|
|
||||||
raise Exception("Failed to attach BPF program %s to kprobe %s" %
|
|
||||||
Exception: Failed to attach BPF program b'entry__do_page_cache_readahead' to kprobe b'do_page_cache_ra'
|
|
||||||
|
|
||||||
Signed-off-by: Rong Tao <rongtao@cestc.cn>
|
|
||||||
---
|
|
||||||
tools/readahead.py | 69 +++++++++++++++++++++++++++++++++++++---------
|
|
||||||
1 file changed, 56 insertions(+), 13 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/tools/readahead.py b/tools/readahead.py
|
|
||||||
index f2afdcb3..adad2ea8 100755
|
|
||||||
--- a/tools/readahead.py
|
|
||||||
+++ b/tools/readahead.py
|
|
||||||
@@ -12,6 +12,7 @@
|
|
||||||
#
|
|
||||||
# 20-Aug-2020 Suchakra Sharma Ported from bpftrace to BCC
|
|
||||||
# 17-Sep-2021 Hengqi Chen Migrated to kfunc
|
|
||||||
+# 30-Jan-2023 Rong Tao Support more kfunc/kprobe, introduce folio
|
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
from bcc import BPF
|
|
||||||
@@ -38,6 +39,7 @@ args = parser.parse_args()
|
|
||||||
bpf_text = """
|
|
||||||
#include <uapi/linux/ptrace.h>
|
|
||||||
#include <linux/mm_types.h>
|
|
||||||
+#include <linux/mm.h>
|
|
||||||
|
|
||||||
BPF_HASH(flag, u32, u8); // used to track if we are in do_page_cache_readahead()
|
|
||||||
BPF_HASH(birth, struct page*, u64); // used to track timestamps of cache alloc'ed page
|
|
||||||
@@ -65,7 +67,7 @@ int exit__do_page_cache_readahead(struct pt_regs *ctx) {
|
|
||||||
int exit__page_cache_alloc(struct pt_regs *ctx) {
|
|
||||||
u32 pid;
|
|
||||||
u64 ts;
|
|
||||||
- struct page *retval = (struct page*) PT_REGS_RC(ctx);
|
|
||||||
+ struct page *retval = (struct page*) GET_RETVAL_PAGE;
|
|
||||||
u32 zero = 0; // static key for accessing pages[0]
|
|
||||||
pid = bpf_get_current_pid_tgid();
|
|
||||||
u8 *f = flag.lookup(&pid);
|
|
||||||
@@ -111,6 +113,23 @@ KRETFUNC_PROBE(RA_FUNC)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
+KFUNC_PROBE(mark_page_accessed, struct page *arg0)
|
|
||||||
+{
|
|
||||||
+ u64 ts, delta;
|
|
||||||
+ u32 zero = 0; // static key for accessing pages[0]
|
|
||||||
+ u64 *bts = birth.lookup(&arg0);
|
|
||||||
+
|
|
||||||
+ if (bts != NULL) {
|
|
||||||
+ delta = bpf_ktime_get_ns() - *bts;
|
|
||||||
+ dist.atomic_increment(bpf_log2l(delta/1000000));
|
|
||||||
+ pages.atomic_increment(zero, -1);
|
|
||||||
+ birth.delete(&arg0); // remove the entry from hashmap
|
|
||||||
+ }
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+"""
|
|
||||||
+
|
|
||||||
+bpf_text_kfunc_cache_alloc_ret_page = """
|
|
||||||
KRETFUNC_PROBE(__page_cache_alloc, gfp_t gfp, struct page *retval)
|
|
||||||
{
|
|
||||||
u64 ts;
|
|
||||||
@@ -125,18 +144,22 @@ KRETFUNC_PROBE(__page_cache_alloc, gfp_t gfp, struct page *retval)
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
+"""
|
|
||||||
|
|
||||||
-KFUNC_PROBE(mark_page_accessed, struct page *arg0)
|
|
||||||
+bpf_text_kfunc_cache_alloc_ret_folio = """
|
|
||||||
+KRETFUNC_PROBE(filemap_alloc_folio, gfp_t gfp, unsigned int order,
|
|
||||||
+ struct folio *retval)
|
|
||||||
{
|
|
||||||
- u64 ts, delta;
|
|
||||||
+ u64 ts;
|
|
||||||
u32 zero = 0; // static key for accessing pages[0]
|
|
||||||
- u64 *bts = birth.lookup(&arg0);
|
|
||||||
+ u32 pid = bpf_get_current_pid_tgid();
|
|
||||||
+ u8 *f = flag.lookup(&pid);
|
|
||||||
+ struct page *page = folio_page(retval, 0);
|
|
||||||
|
|
||||||
- if (bts != NULL) {
|
|
||||||
- delta = bpf_ktime_get_ns() - *bts;
|
|
||||||
- dist.atomic_increment(bpf_log2l(delta/1000000));
|
|
||||||
- pages.atomic_increment(zero, -1);
|
|
||||||
- birth.delete(&arg0); // remove the entry from hashmap
|
|
||||||
+ if (f != NULL && *f == 1) {
|
|
||||||
+ ts = bpf_ktime_get_ns();
|
|
||||||
+ birth.update(&page, &ts);
|
|
||||||
+ pages.atomic_increment(zero);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -145,20 +168,40 @@ KFUNC_PROBE(mark_page_accessed, struct page *arg0)
|
|
||||||
if BPF.support_kfunc():
|
|
||||||
if BPF.get_kprobe_functions(b"__do_page_cache_readahead"):
|
|
||||||
ra_func = "__do_page_cache_readahead"
|
|
||||||
- else:
|
|
||||||
+ elif BPF.get_kprobe_functions(b"do_page_cache_ra"):
|
|
||||||
ra_func = "do_page_cache_ra"
|
|
||||||
+ elif BPF.get_kprobe_functions(b"page_cache_ra_order"):
|
|
||||||
+ ra_func = "page_cache_ra_order"
|
|
||||||
+ else:
|
|
||||||
+ print("Not found any kfunc.")
|
|
||||||
+ exit()
|
|
||||||
bpf_text += bpf_text_kfunc.replace("RA_FUNC", ra_func)
|
|
||||||
+ if BPF.get_kprobe_functions(b"__page_cache_alloc"):
|
|
||||||
+ bpf_text += bpf_text_kfunc_cache_alloc_ret_page
|
|
||||||
+ else:
|
|
||||||
+ bpf_text += bpf_text_kfunc_cache_alloc_ret_folio
|
|
||||||
b = BPF(text=bpf_text)
|
|
||||||
else:
|
|
||||||
bpf_text += bpf_text_kprobe
|
|
||||||
- b = BPF(text=bpf_text)
|
|
||||||
if BPF.get_kprobe_functions(b"__do_page_cache_readahead"):
|
|
||||||
ra_event = "__do_page_cache_readahead"
|
|
||||||
- else:
|
|
||||||
+ elif BPF.get_kprobe_functions(b"do_page_cache_ra"):
|
|
||||||
ra_event = "do_page_cache_ra"
|
|
||||||
+ elif BPF.get_kprobe_functions(b"page_cache_ra_order"):
|
|
||||||
+ ra_event = "page_cache_ra_order"
|
|
||||||
+ else:
|
|
||||||
+ print("Not found any kprobe.")
|
|
||||||
+ exit()
|
|
||||||
+ if BPF.get_kprobe_functions(b"__page_cache_alloc"):
|
|
||||||
+ cache_func = "__page_cache_alloc"
|
|
||||||
+ bpf_text = bpf_text.replace('GET_RETVAL_PAGE', 'PT_REGS_RC(ctx)')
|
|
||||||
+ else:
|
|
||||||
+ cache_func = "filemap_alloc_folio"
|
|
||||||
+ bpf_text = bpf_text.replace('GET_RETVAL_PAGE', 'folio_page((struct folio *)PT_REGS_RC(ctx), 0)')
|
|
||||||
+ b = BPF(text=bpf_text)
|
|
||||||
b.attach_kprobe(event=ra_event, fn_name="entry__do_page_cache_readahead")
|
|
||||||
b.attach_kretprobe(event=ra_event, fn_name="exit__do_page_cache_readahead")
|
|
||||||
- b.attach_kretprobe(event="__page_cache_alloc", fn_name="exit__page_cache_alloc")
|
|
||||||
+ b.attach_kretprobe(event=cache_func, fn_name="exit__page_cache_alloc")
|
|
||||||
b.attach_kprobe(event="mark_page_accessed", fn_name="entry_mark_page_accessed")
|
|
||||||
|
|
||||||
# header
|
|
||||||
--
|
|
||||||
2.39.1
|
|
||||||
|
|
@ -1,140 +0,0 @@
|
|||||||
From 01b7a5320857676f4f5b610db588d4e7d14a2372 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Rong Tao <rongtao@cestc.cn>
|
|
||||||
Date: Sun, 22 Jan 2023 15:44:46 +0800
|
|
||||||
Subject: [PATCH] tools/slabratetop: Fix error: incomplete definition of type
|
|
||||||
'struct slab'
|
|
||||||
|
|
||||||
kernel commit 40f3bf0cb04c("mm: Convert struct page to struct slab in functions
|
|
||||||
used by other subsystems") introduce slab_address() function, commit 6e48a966dfd1
|
|
||||||
("mm/kasan: Convert to struct folio and struct slab") linux/kasan.h adds a
|
|
||||||
dependency on the slab struct, This leads to the following problems:
|
|
||||||
|
|
||||||
$ sudo ./slabratetop.py
|
|
||||||
In file included from /virtual/main.c:13:
|
|
||||||
include/linux/slub_def.h:162:26: warning: call to undeclared function 'slab_address';
|
|
||||||
ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
|
|
||||||
void *object = x - (x - slab_address(slab)) % cache->size;
|
|
||||||
^
|
|
||||||
include/linux/slub_def.h:162:46: error: invalid operands to binary expression ('void *' and 'unsigned int')
|
|
||||||
void *object = x - (x - slab_address(slab)) % cache->size;
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
|
|
||||||
include/linux/slub_def.h:164:8: error: incomplete definition of type 'struct slab'
|
|
||||||
(slab->objects - 1) * cache->size;
|
|
||||||
~~~~^
|
|
||||||
include/linux/kasan.h:13:8: note: forward declaration of 'struct slab'
|
|
||||||
struct slab;
|
|
||||||
^
|
|
||||||
...
|
|
||||||
|
|
||||||
At first, I wanted to fix this with a kernel patch [1], however, bcc as a
|
|
||||||
downstream project of the kernel, this issue should be solved inside the bcc
|
|
||||||
project. This is agreed by kernel maintainer and bcc maintainer @yonghong-song.
|
|
||||||
|
|
||||||
This solution is provided by @yonghong-song [0].
|
|
||||||
|
|
||||||
[0] https://github.com/iovisor/bcc/issues/4438
|
|
||||||
[1] https://lore.kernel.org/all/tencent_ABA832E296819D1053D6C625ADCAF76BC706@qq.com/
|
|
||||||
|
|
||||||
Signed-off-by: Rong Tao <rongtao@cestc.cn>
|
|
||||||
Signed-off-by: Yonghong Song <yhs@fb.com>
|
|
||||||
---
|
|
||||||
tools/slabratetop.py | 76 ++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
1 file changed, 76 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/tools/slabratetop.py b/tools/slabratetop.py
|
|
||||||
index ac44b2bd..8fbcac5e 100755
|
|
||||||
--- a/tools/slabratetop.py
|
|
||||||
+++ b/tools/slabratetop.py
|
|
||||||
@@ -14,6 +14,9 @@
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License")
|
|
||||||
#
|
|
||||||
# 15-Oct-2016 Brendan Gregg Created this.
|
|
||||||
+# 23-Jan-2023 Rong Tao Introduce kernel internal data structure and
|
|
||||||
+# functions to temporarily solve problem for
|
|
||||||
+# >=5.16(TODO: fix this workaround)
|
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
from bcc import BPF
|
|
||||||
@@ -65,6 +68,79 @@ bpf_text = """
|
|
||||||
// 5.9, but it does not hurt to have it here for versions 5.4 to 5.8.
|
|
||||||
struct memcg_cache_params {};
|
|
||||||
|
|
||||||
+// introduce kernel interval slab structure and slab_address() function, solved
|
|
||||||
+// 'undefined' error for >=5.16. TODO: we should fix this workaround if BCC
|
|
||||||
+// framework support BTF/CO-RE.
|
|
||||||
+struct slab {
|
|
||||||
+ unsigned long __page_flags;
|
|
||||||
+
|
|
||||||
+#if defined(CONFIG_SLAB)
|
|
||||||
+
|
|
||||||
+ struct kmem_cache *slab_cache;
|
|
||||||
+ union {
|
|
||||||
+ struct {
|
|
||||||
+ struct list_head slab_list;
|
|
||||||
+ void *freelist; /* array of free object indexes */
|
|
||||||
+ void *s_mem; /* first object */
|
|
||||||
+ };
|
|
||||||
+ struct rcu_head rcu_head;
|
|
||||||
+ };
|
|
||||||
+ unsigned int active;
|
|
||||||
+
|
|
||||||
+#elif defined(CONFIG_SLUB)
|
|
||||||
+
|
|
||||||
+ struct kmem_cache *slab_cache;
|
|
||||||
+ union {
|
|
||||||
+ struct {
|
|
||||||
+ union {
|
|
||||||
+ struct list_head slab_list;
|
|
||||||
+#ifdef CONFIG_SLUB_CPU_PARTIAL
|
|
||||||
+ struct {
|
|
||||||
+ struct slab *next;
|
|
||||||
+ int slabs; /* Nr of slabs left */
|
|
||||||
+ };
|
|
||||||
+#endif
|
|
||||||
+ };
|
|
||||||
+ /* Double-word boundary */
|
|
||||||
+ void *freelist; /* first free object */
|
|
||||||
+ union {
|
|
||||||
+ unsigned long counters;
|
|
||||||
+ struct {
|
|
||||||
+ unsigned inuse:16;
|
|
||||||
+ unsigned objects:15;
|
|
||||||
+ unsigned frozen:1;
|
|
||||||
+ };
|
|
||||||
+ };
|
|
||||||
+ };
|
|
||||||
+ struct rcu_head rcu_head;
|
|
||||||
+ };
|
|
||||||
+ unsigned int __unused;
|
|
||||||
+
|
|
||||||
+#elif defined(CONFIG_SLOB)
|
|
||||||
+
|
|
||||||
+ struct list_head slab_list;
|
|
||||||
+ void *__unused_1;
|
|
||||||
+ void *freelist; /* first free block */
|
|
||||||
+ long units;
|
|
||||||
+ unsigned int __unused_2;
|
|
||||||
+
|
|
||||||
+#else
|
|
||||||
+#error "Unexpected slab allocator configured"
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+ atomic_t __page_refcount;
|
|
||||||
+#ifdef CONFIG_MEMCG
|
|
||||||
+ unsigned long memcg_data;
|
|
||||||
+#endif
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+// slab_address() will not be used, and NULL will be returned directly, which
|
|
||||||
+// can avoid adaptation of different kernel versions
|
|
||||||
+static inline void *slab_address(const struct slab *slab)
|
|
||||||
+{
|
|
||||||
+ return NULL;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
#ifdef CONFIG_SLUB
|
|
||||||
#include <linux/slub_def.h>
|
|
||||||
#else
|
|
||||||
--
|
|
||||||
2.39.1
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user