From 1d9bca37184971b99baa88359d37715dfd091685 Mon Sep 17 00:00:00 2001 From: borunfu Date: Sun, 29 Sep 2024 06:14:40 -0400 Subject: [PATCH 01/10] sysak: Fix syntax error Signed-off-by: Borun Fu --- source/sysak.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/sysak.c b/source/sysak.c index 4333b3bd..f7fdc2fd 100755 --- a/source/sysak.c +++ b/source/sysak.c @@ -1075,7 +1075,7 @@ static int subcmd_parse(int argc, char *argv[]) } } exec: - #btf_support_check(); + // btf_support_check(); return exectue(argc, argv); } -- Gitee From a949810942b6c98646238917d6ba68e09e116061 Mon Sep 17 00:00:00 2001 From: borunfu Date: Sun, 29 Sep 2024 22:18:28 -0400 Subject: [PATCH 02/10] raptor: Fix golang version typo Signed-off-by: Borun Fu --- source/tools/monitor/raptor/source/config_goenv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/tools/monitor/raptor/source/config_goenv.sh b/source/tools/monitor/raptor/source/config_goenv.sh index 63df1f5c..e6bb2372 100755 --- a/source/tools/monitor/raptor/source/config_goenv.sh +++ b/source/tools/monitor/raptor/source/config_goenv.sh @@ -2,7 +2,7 @@ GOVERSION=$(go version | awk '{print $3}') -if [ "$GOVERSION" = "go.1.19.3" ]; then +if [ "$GOVERSION" = "go1.19.3" -o "$GOVERSION" \> "go1.19.3" ]; then echo "Golang Env Configed" else echo "No Golang Env, We Start To Config" -- Gitee From ed0521fef56d46fd7f88e94be141368eb23241bf Mon Sep 17 00:00:00 2001 From: borunfu Date: Sun, 29 Sep 2024 22:23:55 -0400 Subject: [PATCH 03/10] raptor: Fix Makefile error Signed-off-by: Borun Fu --- source/tools/monitor/raptor/source/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/tools/monitor/raptor/source/Makefile b/source/tools/monitor/raptor/source/Makefile index d1a729f8..85c31c1f 100644 --- a/source/tools/monitor/raptor/source/Makefile +++ b/source/tools/monitor/raptor/source/Makefile @@ -24,7 +24,7 @@ goenv: .PHONY: build build: - @echo "Complie Golong Code..." \ + @echo "Complie Golong Code..." CGO_CFLAGS="$(EXTRA_CGO_CFLAGS)" \ CGO_LDFLAGS="$(EXTRA_CGO_LDFLAGS)" \ go build -ldflags "-linkmode external -extldflags '-static' -X 'main.version=$(RELEASE_VERSION)' \ -- Gitee From bd22658784731bf78c9df261c77503a1f50cd5c8 Mon Sep 17 00:00:00 2001 From: borunfu Date: Sun, 29 Sep 2024 23:17:10 -0400 Subject: [PATCH 04/10] raptor: Added the dependence of vmlinux.h on build_bpf This patch fixed the compilation error below. COMPLIE eBPF PROFILE... make -C ebpf/src profile make[3]: Entering directory '/zbench/sysak/source/tools/monitor/raptor/source/ebpf/src' make -C bcc/ make[3]: *** No rule to make target 'vmlinux/vmlinux.h', needed by 'oncpu.bpf.o'. Stop. Signed-off-by: Borun Fu --- source/tools/monitor/raptor/source/ebpf/src/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/tools/monitor/raptor/source/ebpf/src/Makefile b/source/tools/monitor/raptor/source/ebpf/src/Makefile index 9e78a71a..1f0afdea 100644 --- a/source/tools/monitor/raptor/source/ebpf/src/Makefile +++ b/source/tools/monitor/raptor/source/ebpf/src/Makefile @@ -106,6 +106,8 @@ build_bpf: make -C libbpf/ cp -f libbpf/src/.github/actions/build-selftests/vmlinux.h vmlinux/vmlinux.h +$(VMLINUX): build_bpf + profile: build_bpf oncpu.bpf.o offcpu.bpf.o user_slow.bpf.o ping_slow.bpf.o nginx.bpf.o oncpu.bpf.o: oncpu.bpf.c profile.bpf.h $(VMLINUX) -- Gitee From f49b3f852c30b95048b8e20d99b6a3c0612ec28d Mon Sep 17 00:00:00 2001 From: borunfu Date: Sun, 29 Sep 2024 23:04:42 -0400 Subject: [PATCH 05/10] xwatcher: Fix tokio features setting This patch fixed the compilation error below. error[E0599]: no function or associated item named `new` found for struct `tokio::runtime::Runtime` in the curr ent scope --> src/nginx/access_log.rs:29:31 | 29 | let rt = Runtime::new().unwrap(); | ^^^ function or associated item not found in `Runtime` warning: variable does not need to be mutable --> src/nginx/nginx.rs:177:17 | 177 | let mut entry = ptree.entry(ppid).or_insert(HashSet::new()); | ----^^^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default ... For more information about this error, try `rustc --explain E0599`. Signed-off-by: Borun Fu --- source/tools/monitor/observ/xwatcher/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/tools/monitor/observ/xwatcher/Cargo.toml b/source/tools/monitor/observ/xwatcher/Cargo.toml index 233d476d..cf6cee0d 100644 --- a/source/tools/monitor/observ/xwatcher/Cargo.toml +++ b/source/tools/monitor/observ/xwatcher/Cargo.toml @@ -29,7 +29,7 @@ get_if_addrs = "0.5.3" rtrace = {path = "../../../detect/net/rtrace"} crossbeam = "0.8.2" once_cell = "1.18.0" -tokio = { version = "1.34.0", features = ["rt"] } +tokio = { version = "1.34.0", features = ["rt", "rt-multi-thread"] } [build-dependencies] -- Gitee From 61c9627c0e5c2274acef50a72d4a7670b30897bd Mon Sep 17 00:00:00 2001 From: borunfu Date: Sun, 29 Sep 2024 05:44:54 -0400 Subject: [PATCH 06/10] pagescan: Adapt to CentOS kernel 4.18.0 Signed-off-by: Borun Fu --- .../detect/mem/pagescan/kernel/mm_types.h | 141 +++++++++++++++++- 1 file changed, 140 insertions(+), 1 deletion(-) diff --git a/source/tools/detect/mem/pagescan/kernel/mm_types.h b/source/tools/detect/mem/pagescan/kernel/mm_types.h index ad4391e1..eb53c4f0 100644 --- a/source/tools/detect/mem/pagescan/kernel/mm_types.h +++ b/source/tools/detect/mem/pagescan/kernel/mm_types.h @@ -175,6 +175,145 @@ struct kmem_cache { unsigned int padding4; /* explicitly add 4 padding */ uintptr_t node[1024]; }; +#elif defined(KERNEL_4_18) +struct page { + long unsigned int flags; + union { + struct { + uintptr_t lru[2]; + uintptr_t mapping; + long unsigned int index; + long unsigned int private; + }; + struct { + uintptr_t dma_addr; + }; + struct { + union { + uintptr_t slab_list[2]; + struct { + uintptr_t next; + int pages; + int pobjects; + }; + }; + uintptr_t slab_cache; + void *freelist; + union { + void *s_mem; + long unsigned int counters; + struct { + unsigned int inuse: 16; + unsigned int objects: 15; + unsigned int frozen: 1; + }; + }; + }; + struct { + long unsigned int compound_head; + unsigned char compound_dtor; + unsigned char compound_order; + int compound_mapcount; + unsigned int mapcount_seqcount; + }; + struct { + long unsigned int _compound_pad_1; + union { + int hpage_pinned_refcount; + struct { + long unsigned int _compound_pad_2; + } rh_kabi_hidden_159; + union { }; + }; + uintptr_t deferred_list[2]; + }; + struct { + long unsigned int _pt_pad_1; + uintptr_t pmd_huge_pte; + long unsigned int _pt_pad_2; + union { + union { + uintptr_t pt_mm; + int pt_frag_refcount; + }; + struct { + uintptr_t pt_mm; + } rh_kabi_hidden_171; + union { }; + }; + unsigned int ptl; + }; + struct { + uintptr_t pgmap; + union { + void *zone_device_data; + struct { + long unsigned int hmm_data; + } rh_kabi_hidden_182; + union { }; + }; + long unsigned int _zd_pad_1; + }; + uintptr_t callback_head[2]; + }; + union { + int _mapcount; + unsigned int page_type; + unsigned int active; + int units; + }; + int _refcount; + union { + long unsigned int memcg_data; + struct { + uintptr_t mem_cgroup; + } rh_kabi_hidden_214; + union { }; + }; +}; + +struct kmem_cache { + uintptr_t cpu_slab; + unsigned int flags; + long unsigned int min_partial; + unsigned int size; + unsigned int object_size; + unsigned int offset; + unsigned int cpu_partial; + unsigned int oo; + unsigned int max; + unsigned int min; + unsigned int allocflags; + int refcount; + void (*ctor)(void *); + unsigned int inuse; + unsigned int align; + unsigned int red_left_pad; + const char *name; + uintptr_t list[2]; + uintptr_t kobj[12]; + union { + uintptr_t reciprocal_size; + struct { + uintptr_t kobj_remove_work[8]; + } rh_kabi_hidden_119; + union { }; + }; + uintptr_t rh_reserved_memcg_params[15]; + unsigned int rh_reserved_max_attr_size; + union { + long unsigned int random; + struct { + uintptr_t memcg_kset; + } rh_kabi_hidden_126; + union { }; + }; + unsigned int remote_node_defrag_ratio; + unsigned int *random_seq; + unsigned int useroffset; + unsigned int usersize; + uintptr_t node[1024]; +}; #elif defined(KERNEL_4_19) struct page { unsigned long flags; @@ -306,7 +445,7 @@ static inline unsigned int get_page_mapcount(struct page *page, { return GET_PAGE_MAPCOUNT(page); } -#elif defined(KERNEL_4_9) || defined(KERNEL_4_19) +#elif defined(KERNEL_4_9) || defined(KERNEL_4_18) || defined(KERNEL_4_19) #define GET_PAGE_REFCOUNT(pg) GET_PAGE_FIELD(pg, _refcount) #define GET_PAGE_COMPOUND_HEAD(pg) GET_PAGE_FIELD(pg, compound_head) #define GET_PAGE_COMPOUND_ORDER(pg) GET_PAGE_FIELD(pg, compound_order) -- Gitee From b66d9630e09fc3ad9b9820051e22306ea0ccdecf Mon Sep 17 00:00:00 2001 From: borunfu Date: Sun, 29 Sep 2024 05:46:39 -0400 Subject: [PATCH 07/10] process_tree: Adapt to CentOS kernel 4.18.0 This patch fixed the compilation issue below. bpf/process_tree.bpf.c:37:29: error: no member named 'pids' in 'struct task_struct'; did you mean 'pid'? p = (BPF_CORE_READ(tsk, pids)[PIDTYPE_PID]).pid; ^~~~ pid Signed-off-by: Borun Fu --- source/mk/bpf.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/mk/bpf.mk b/source/mk/bpf.mk index 8db94475..831bf7a2 100644 --- a/source/mk/bpf.mk +++ b/source/mk/bpf.mk @@ -61,6 +61,11 @@ NEWVER := $(shell echo $(KERNEL_VERSION)|awk -F. '{if($$1>3) print 1; else print ifeq ($(NEWVER),1) KERN_VER := -DVER310_LATER endif + +ifneq ($(findstring 4.18.0,$(KERNEL_VERSION)),) + KERN_VER += $(KERN_VER) -DRHEL_RELEASE_GT_8_0 +endif + $(bpfobjs) : %.o : %.c dirs $(call msg,BPF,$@) $(CLANG) -g -O2 $(KERN_VER) -target bpf -D__TARGET_ARCH_$(ARCH) $(INCLUDES) -c $< -o $(OBJPATH)/$@ -- Gitee From a8902cd91e24700ba3d5ab6207b92ee824e7d05f Mon Sep 17 00:00:00 2001 From: borunfu Date: Wed, 9 Oct 2024 04:54:21 -0400 Subject: [PATCH 08/10] java_collect: Fix Makefile error This patch fixed the compilation error below. mv: cannot move '/zbench/sysak/out/.sysak_components/tools/continuous-profile-collector' to '/zbench/sysak/out/ .sysak_components/tools/jruntime/continuous-profile-collector': File exists make[1]: *** [Makefile:12: java_collect] Error 1 make[1]: Leaving directory '/zbench/sysak/source/tools/detect/java/java_collect' make: *** [Makefile:40: /zbench/sysak/source/tools/detect/java/java_collect] Error 2 Signed-off-by: Borun Fu --- source/tools/detect/java/java_collect/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/source/tools/detect/java/java_collect/Makefile b/source/tools/detect/java/java_collect/Makefile index bdfc1553..90fa5db2 100644 --- a/source/tools/detect/java/java_collect/Makefile +++ b/source/tools/detect/java/java_collect/Makefile @@ -9,6 +9,7 @@ all: $(target) target_rule $(target): $@ cp -r continuous-profile-collector $(TARGET_PATH)/ + rm -rf $(TARGET_PATH)/jruntime mv $(TARGET_PATH)/continuous-profile-collector $(TARGET_PATH)/jruntime cd src && pwd && sh venv.sh && cd ../ cp src/dist/java_collect $(TARGET_PATH)/ -- Gitee From 1fa109892adc7e6af1aa4b787341f3460e47f898 Mon Sep 17 00:00:00 2001 From: borunfu Date: Wed, 9 Oct 2024 05:23:54 -0400 Subject: [PATCH 09/10] cgroup: Fix data structure redefinition errors This patch fixed the compilation errors below. In file included from cpuacct_load.bpf.c:1: In file included from ./../cgtoollib_bpf.h:10: ./../cgtool_comm.h:77:8: error: redefinition of 'page_counter' struct page_counter { ^ /zbench/sysak/source/lib/internal/ebpf/coolbpf/arch/x86_64/vmlinux.h:5573:8: note: previous definition is here struct page_counter { ^ In file included from cpuacct_load.bpf.c:1: In file included from ./../cgtoollib_bpf.h:10: ./../cgtool_comm.h:95:8: error: redefinition of 'vmpressure' struct vmpressure { ^ /zbench/sysak/source/lib/internal/ebpf/coolbpf/arch/x86_64/vmlinux.h:5590:8: note: previous definition is here struct vmpressure { ^ In file included from cpuacct_load.bpf.c:1: In file included from ./../cgtoollib_bpf.h:10: ./../cgtool_comm.h:106:8: error: redefinition of 'mem_cgroup_thresholds' struct mem_cgroup_thresholds { ^ /zbench/sysak/source/lib/internal/ebpf/coolbpf/arch/x86_64/vmlinux.h:5609:8: note: previous definition is here struct mem_cgroup_thresholds { ^ ... make[2]: *** [/zbench/sysak/source/mk/bpf.mk:71: cpuacct_load.bpf.o] Error 1 make[2]: Leaving directory '/zbench/sysak/source/tools/detect/cgroup/cpuacct_load' make[1]: *** [/zbench/sysak/source/mk/sub.mk:14: cpuacct_load] Error 2 make[1]: *** Waiting for unfinished jobs.... make[2]: *** [/zbench/sysak/source/mk/bpf.mk:71: memcg_usage.bpf.o] Error 1 make[2]: Leaving directory '/zbench/sysak/source/tools/detect/cgroup/memcg_usage' make[1]: *** [/zbench/sysak/source/mk/sub.mk:14: memcg_usage] Error 2 Signed-off-by: Borun Fu --- source/tools/detect/cgroup/cgtool_comm.h | 4 ++++ source/tools/detect/cgroup/cgtoollib_bpf.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/source/tools/detect/cgroup/cgtool_comm.h b/source/tools/detect/cgroup/cgtool_comm.h index 07af7325..fe06246c 100644 --- a/source/tools/detect/cgroup/cgtool_comm.h +++ b/source/tools/detect/cgroup/cgtool_comm.h @@ -74,6 +74,7 @@ struct mm_struct___MEMCG { long unsigned int cpu_bitmap[0]; }; +#if 0 struct page_counter { atomic_long_t usage; long unsigned int min; @@ -128,6 +129,7 @@ struct deferred_split { struct list_head split_queue; long unsigned int split_queue_len; }; +#endif union kernfs_node_id { struct { @@ -137,6 +139,7 @@ union kernfs_node_id { u64 id; }; +#if 0 struct mem_cgroup { struct cgroup_subsys_state css; struct mem_cgroup_id id; @@ -214,6 +217,7 @@ struct mem_cgroup { long: 64; long: 64; }; +#endif struct cgroup___MEMCG { struct cgroup_subsys_state self; diff --git a/source/tools/detect/cgroup/cgtoollib_bpf.h b/source/tools/detect/cgroup/cgtoollib_bpf.h index 80e553b1..e797111c 100644 --- a/source/tools/detect/cgroup/cgtoollib_bpf.h +++ b/source/tools/detect/cgroup/cgtoollib_bpf.h @@ -10,7 +10,9 @@ #include "cgtool_comm.h" #define BPF_ANY 0 +#if 0 #define NULL ((void*)0) +#endif static u64 get_knid_by_cgroup(struct cgroup___MEMCG *cgrp) { -- Gitee From 666706ae648ad191a69e2a6f255188d81f4e9a08 Mon Sep 17 00:00:00 2001 From: borunfu Date: Wed, 9 Oct 2024 05:52:59 -0400 Subject: [PATCH 10/10] rpmbuild: Correct rpm spec issues Signed-off-by: Borun Fu --- rpm/sysak-build.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rpm/sysak-build.sh b/rpm/sysak-build.sh index 8e236d50..df35d463 100755 --- a/rpm/sysak-build.sh +++ b/rpm/sysak-build.sh @@ -38,19 +38,23 @@ fi %install mkdir -p \$RPM_BUILD_ROOT/usr/bin +mkdir -p \$RPM_BUILD_ROOT/etc/sysak mkdir -p \$RPM_BUILD_ROOT/usr/local/sysak/log mkdir -p \$RPM_BUILD_ROOT/usr/lib/systemd/system/ /bin/cp -rf $BUILD_DIR/.sysak_components \$RPM_BUILD_ROOT/usr/local/sysak/.sysak_components /bin/cp -rf $BUILD_DIR/sysak \$RPM_BUILD_ROOT/usr/bin/ /bin/cp $SOURCE_DIR/rpm/sysak.service \$RPM_BUILD_ROOT/usr/lib/systemd/system/ /bin/cp -f $BUILD_DIR/.sysak_components/tools/monitor/sysakmon.conf \$RPM_BUILD_ROOT/usr/local/sysak/ +/bin/cp -f $BUILD_DIR/.sysak_components/tools/monitor/monctl.conf \$RPM_BUILD_ROOT/usr/local/sysak +/bin/cp -f $BUILD_DIR/.sysak_components/tools/dist/app/etc/* \$RPM_BUILD_ROOT/etc/sysak/ /bin/cp $SOURCE_DIR/rpm/sysak_server.conf \$RPM_BUILD_ROOT/usr/local/sysak/ /bin/cp $SOURCE_DIR/rpm/.sysak.diag.config \$RPM_BUILD_ROOT/etc/sysak/ +/usr/bin/rm -rf \$RPM_BUILD_ROOT/usr/local/sysak/.sysak_components/tools/$LINUX_VERSION %preun - +systemctl stop sysak /sbin/lsmod | grep sysak > /dev/null -if [ $? -eq 0 ]; then +if [ \$? -eq 0 ]; then /sbin/rmmod sysak exit 0 fi @@ -61,6 +65,7 @@ if [ \$1 -eq 0 ]; then fi %files +/etc/sysak /usr/local/sysak /usr/bin/sysak /usr/lib/systemd/system/sysak.service -- Gitee