!27 [sync] PR-26: simplify vmlinux.h management with different kernel versions

From: @openeuler-sync-bot 
Reviewed-by: @dowzyx 
Signed-off-by: @dowzyx
This commit is contained in:
openeuler-ci-bot 2022-12-08 01:00:21 +00:00 committed by Gitee
commit 090a329cf9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 92 additions and 144 deletions

View File

@ -1,10 +1,12 @@
%define debug_package %{nil}
%define __os_install_post %{nil}
%define vmlinux_ver 5.10.0-126.0.0.66.oe2203.%{_arch}
Summary: Intelligent ops toolkit for openEuler
Name: gala-gopher
Version: 1.0.0
Release: 9
Release: 10
License: Mulan PSL v2
URL: https://gitee.com/openeuler/gala-gopher
Source: %{name}-%{version}.tar.gz
@ -20,18 +22,13 @@ Requires: flamegraph-stackcollapse iproute
patch0: add-vmlinux-for-2203LTS-2203LTS-SP1.patch
patch1: fix-pgsliprobe.patch
patch2: adapt-libbpf-v08.patch
%ifarch x86_64
patch3: modify-to-adapt-to-oe2203-LTS-SP1-x86.patch
%endif
%ifarch aarch64
patch3: modify-to-adapt-to-oe2203-LTS-SP1-arm.patch
%endif
patch4: fix-bugs-for-ksliprobe-pgsliprobe-stackprobe.patch
patch5: move-docs-about-creating-and-running-in-docker.patch
patch6: fix-the-problem-that-the-gopher-in-docker-doesn-t-su.patch
patch7: add-documentation-related-to-docker-images.patch
patch8: fix-java.probe-build-error-caused-by-a-typo-in-build.patch
patch9: Only-check-the-installation-of-dep-when-building-ebp.patch
patch3: fix-bugs-for-ksliprobe-pgsliprobe-stackprobe.patch
patch4: move-docs-about-creating-and-running-in-docker.patch
patch5: fix-the-problem-that-the-gopher-in-docker-doesn-t-su.patch
patch6: add-documentation-related-to-docker-images.patch
patch7: fix-java.probe-build-error-caused-by-a-typo-in-build.patch
patch8: Only-check-the-installation-of-dep-when-building-ebp.patch
patch9: simplify-vmlinux.h-management-with-different-kernel-.patch
%description
gala-gopher is a low-overhead eBPF-based probes framework
@ -41,7 +38,7 @@ gala-gopher is a low-overhead eBPF-based probes framework
%build
pushd build
sh build.sh --release
sh build.sh --release %{vmlinux_ver}
popd
%install
@ -78,6 +75,9 @@ popd
/usr/lib/systemd/system/gala-gopher.service
%changelog
* Tue Dec 6 2022 Zhen Chen <chenzhen126@huawei.com> - 1.0.0-10
- simplify vmlinux.h management with different kernel versions
* Wed Nov 30 2022 Zhen Chen <chenzhen126@huawei.com> - 1.0.0-9
- fix java.probe build error caused by a typo in build.sh
Only check the installation of dep when building ebpf.probes

View File

@ -1,65 +0,0 @@
From be59848fc48885c656dda02565b55e84dc4bcb12 Mon Sep 17 00:00:00 2001
From: zhaoyuxing <zhaoyuxing2@huawei.com>
Date: Wed, 10 Aug 2022 17:12:16 +0800
Subject: [PATCH] modify vmlinux.h and version infos of oe-22.03 LTS SP1 arm
---
src/probes/extends/ebpf.probe/build.sh | 20 +++-----------------
src/probes/extends/ebpf.probe/src/mk/var.mk | 10 ++++------
2 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/src/probes/extends/ebpf.probe/build.sh b/src/probes/extends/ebpf.probe/build.sh
index ab4aa3e..ff08ab0 100755
--- a/src/probes/extends/ebpf.probe/build.sh
+++ b/src/probes/extends/ebpf.probe/build.sh
@@ -82,23 +82,9 @@ function compile_probe()
MATCH_VMLINUX=linux_${LINUX_VER}.h
cd ${VMLINUX_DIR}
- if [ -f ${MATCH_VMLINUX} ];then
- rm -f vmlinux.h
- ln -s ${MATCH_VMLINUX} vmlinux.h
- echo "debug: match vmlinux :" ${MATCH_VMLINUX}
- elif [ -f "vmlinux.h" ];then
- echo "debug: vmlinux.h is already here, continue compile."
- else
- echo "======================================ERROR==============================================="
- echo "there no match vmlinux :" ${MATCH_VMLINUX}
- echo "please create vmlinux.h manually."
- echo "methods:"
- echo " 1. generate linux_xxx.h by compile the kernel, refer to gen_vmlinux_h.sh;"
- echo " 2. ln -s vmlinux.h linux_xxx.h, (there are some include files in directory src/include)"
- echo " if your kernel version is similar to the include files provided, you can use method 2"
- echo "=========================================================================================="
- exit
- fi
+ rm -rf vmlinux.h
+ ln -s linux_5.10.0-126.0.0.66.oe2203.aarch64.h vmlinux.h
+ echo "debug: openEuler 22.03 LTS SP1 vmlinux :" ${MATCH_VMLINUX}
cd ${SRC_DIR}
echo "=======Begin to compile ebpf-based probes======:" ${EBPF_PROBES}
diff --git a/src/probes/extends/ebpf.probe/src/mk/var.mk b/src/probes/extends/ebpf.probe/src/mk/var.mk
index 2522a6f..16a14d0 100644
--- a/src/probes/extends/ebpf.probe/src/mk/var.mk
+++ b/src/probes/extends/ebpf.probe/src/mk/var.mk
@@ -23,12 +23,10 @@ else ifeq ($(ARCH), aarch64)
ARCH = arm64
endif
-KER_VER = $(shell uname -r | awk -F'-' '{print $$1}')
-KER_VER_MAJOR = $(shell echo $(KER_VER) | awk -F'.' '{print $$1}')
-KER_VER_MINOR = $(shell echo $(KER_VER) | awk -F'.' '{print $$2}')
-KER_VER_PATCH = $(shell echo $(KER_VER) | awk -F'.' '{print $$3}')
-RELEASE_INFOS = $(shell uname -r | awk -F'-' '{print $$2}')
-KER_RELEASE = $(shell echo $(RELEASE_INFOS) | awk -F'.' '{print $$1}')
+KER_VER_MAJOR = 5
+KER_VER_MINOR = 10
+KER_VER_PATCH = 0
+KER_RELEASE = 126
LIBBPF_VER = $(shell rpm -qa | grep libbpf-devel | awk -F'-' '{print $$3}')
LIBBPF_VER_MAJOR = $(shell echo $(LIBBPF_VER) | awk -F'.' '{print $$1}')
--
2.27.0

View File

@ -1,65 +0,0 @@
From 5c1507c880fb8c80bfe6e1809cc03195e9fd9c7f Mon Sep 17 00:00:00 2001
From: zhaoyuxing <zhaoyuxing2@huawei.com>
Date: Wed, 10 Aug 2022 17:12:16 +0800
Subject: [PATCH] modify vmlinux.h and version infos of oe-22.03 LTS SP1 x86
---
src/probes/extends/ebpf.probe/build.sh | 20 +++-----------------
src/probes/extends/ebpf.probe/src/mk/var.mk | 10 ++++------
2 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/src/probes/extends/ebpf.probe/build.sh b/src/probes/extends/ebpf.probe/build.sh
index ab4aa3e..00f9bd8 100755
--- a/src/probes/extends/ebpf.probe/build.sh
+++ b/src/probes/extends/ebpf.probe/build.sh
@@ -82,23 +82,9 @@ function compile_probe()
MATCH_VMLINUX=linux_${LINUX_VER}.h
cd ${VMLINUX_DIR}
- if [ -f ${MATCH_VMLINUX} ];then
- rm -f vmlinux.h
- ln -s ${MATCH_VMLINUX} vmlinux.h
- echo "debug: match vmlinux :" ${MATCH_VMLINUX}
- elif [ -f "vmlinux.h" ];then
- echo "debug: vmlinux.h is already here, continue compile."
- else
- echo "======================================ERROR==============================================="
- echo "there no match vmlinux :" ${MATCH_VMLINUX}
- echo "please create vmlinux.h manually."
- echo "methods:"
- echo " 1. generate linux_xxx.h by compile the kernel, refer to gen_vmlinux_h.sh;"
- echo " 2. ln -s vmlinux.h linux_xxx.h, (there are some include files in directory src/include)"
- echo " if your kernel version is similar to the include files provided, you can use method 2"
- echo "=========================================================================================="
- exit
- fi
+ rm -rf vmlinux.h
+ ln -s linux_5.10.0-126.0.0.66.oe2203.x86_64.h vmlinux.h
+ echo "debug: openEuler 22.03 LTS SP1 match vmlinux :" ${MATCH_VMLINUX}
cd ${SRC_DIR}
echo "=======Begin to compile ebpf-based probes======:" ${EBPF_PROBES}
diff --git a/src/probes/extends/ebpf.probe/src/mk/var.mk b/src/probes/extends/ebpf.probe/src/mk/var.mk
index 2522a6f..16a14d0 100644
--- a/src/probes/extends/ebpf.probe/src/mk/var.mk
+++ b/src/probes/extends/ebpf.probe/src/mk/var.mk
@@ -23,12 +23,10 @@ else ifeq ($(ARCH), aarch64)
ARCH = arm64
endif
-KER_VER = $(shell uname -r | awk -F'-' '{print $$1}')
-KER_VER_MAJOR = $(shell echo $(KER_VER) | awk -F'.' '{print $$1}')
-KER_VER_MINOR = $(shell echo $(KER_VER) | awk -F'.' '{print $$2}')
-KER_VER_PATCH = $(shell echo $(KER_VER) | awk -F'.' '{print $$3}')
-RELEASE_INFOS = $(shell uname -r | awk -F'-' '{print $$2}')
-KER_RELEASE = $(shell echo $(RELEASE_INFOS) | awk -F'.' '{print $$1}')
+KER_VER_MAJOR = 5
+KER_VER_MINOR = 10
+KER_VER_PATCH = 0
+KER_RELEASE = 126
LIBBPF_VER = $(shell rpm -qa | grep libbpf-devel | awk -F'-' '{print $$3}')
LIBBPF_VER_MAJOR = $(shell echo $(LIBBPF_VER) | awk -F'.' '{print $$1}')
--
2.27.0

View File

@ -0,0 +1,78 @@
From ce5349ae6bcc922130bd19cbed5224727ee21c9a Mon Sep 17 00:00:00 2001
From: Vchanger <348085547@qq.com>
Date: Sun, 4 Dec 2022 21:51:03 +0800
Subject: [PATCH] simplify vmlinux.h management with different kernel versions
---
build/build.sh | 2 ++
src/probes/extends/ebpf.probe/build.sh | 12 ++++--------
src/probes/extends/ebpf.probe/src/mk/var.mk | 4 ++--
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/build/build.sh b/build/build.sh
index 7d259e3..40171e3 100755
--- a/build/build.sh
+++ b/build/build.sh
@@ -17,6 +17,8 @@ DAEMON_FOLDER=${PROJECT_FOLDER}/src/daemon
TAILOR_PATH=${PROJECT_FOLDER}/tailor.conf
TAILOR_PATH_TMP=${TAILOR_PATH}.tmp
+export LINUX_VER="${2:-$(uname -r)}"
+
function load_tailor()
{
if [ -f ${TAILOR_PATH} ]; then
diff --git a/src/probes/extends/ebpf.probe/build.sh b/src/probes/extends/ebpf.probe/build.sh
index 05a1547..dcc7ffe 100755
--- a/src/probes/extends/ebpf.probe/build.sh
+++ b/src/probes/extends/ebpf.probe/build.sh
@@ -6,24 +6,20 @@ PRJ_DIR=$(dirname $(readlink -f "$0"))
TOOLS_DIR=${PRJ_DIR}/tools
SRC_DIR=${PRJ_DIR}/src
VMLINUX_DIR=${SRC_DIR}/include
-LINUX_VER=$(uname -r)
DEP_LIST=(elfutils-devel libbpf libbpf-devel clang llvm)
-function gen_vmlinux_header_file()
+function add_bpftool()
{
cd ${TOOLS_DIR}
if [ ! -f "bpftool" ];then
ln -s bpftool_${ARCH} bpftool
fi
- ./gen_vmlinux_h.sh
}
-function add_bpftool()
+function gen_vmlinux_header_file()
{
- cd ${TOOLS_DIR}
- if [ ! -f "bpftool" ];then
- ln -s bpftool_${ARCH} bpftool
- fi
+ add_bpftool
+ ./gen_vmlinux_h.sh
}
function check_dep()
diff --git a/src/probes/extends/ebpf.probe/src/mk/var.mk b/src/probes/extends/ebpf.probe/src/mk/var.mk
index fc33e22..8990bda 100644
--- a/src/probes/extends/ebpf.probe/src/mk/var.mk
+++ b/src/probes/extends/ebpf.probe/src/mk/var.mk
@@ -23,11 +23,11 @@ else ifeq ($(ARCH), aarch64)
ARCH = arm64
endif
-KER_VER = $(shell uname -r | awk -F'-' '{print $$1}')
+KER_VER = $(shell echo $(LINUX_VER) | awk -F'-' '{print $$1}')
KER_VER_MAJOR = $(shell echo $(KER_VER) | awk -F'.' '{print $$1}')
KER_VER_MINOR = $(shell echo $(KER_VER) | awk -F'.' '{print $$2}')
KER_VER_PATCH = $(shell echo $(KER_VER) | awk -F'.' '{print $$3}')
-RELEASE_INFOS = $(shell uname -r | awk -F'-' '{print $$2}')
+RELEASE_INFOS = $(shell echo $(LINUX_VER) | awk -F'-' '{print $$2}')
KER_RELEASE = $(shell echo $(RELEASE_INFOS) | awk -F'.' '{print $$1}')
LIBBPF_VER = $(shell rpm -qa | grep libbpf-devel | awk -F'-' '{print $$3}')
--
2.33.0