Adapt to openEuler 22.09

Signed-off-by: Lv Ying <lvying6@huawei.com>
(cherry picked from commit 994fb9d0d85f6c732fbb54911baba45198c1bd18)
This commit is contained in:
Lv Ying 2022-08-03 03:22:59 +08:00 committed by openeuler-sync-bot
parent 75ca68d574
commit f0938cbe68
4 changed files with 45685 additions and 37959 deletions

View File

@ -0,0 +1,37 @@
From 870d20f15defab4e3ff6f1cee721b8373ce2eb6d Mon Sep 17 00:00:00 2001
From: Lv Ying <lvying6@huawei.com>
Date: Wed, 3 Aug 2022 08:14:25 +0800
Subject: [PATCH] Drop using legacy BPF map declaration
https://github.com/libbpf/libbpf/wiki/Libbpf:-the-road-to-v1.0#drop-support-for-legacy-bpf-map-declaration-syntax
Signed-off-by: Lv Ying <lvying6@huawei.com>
---
readahead_tune.bpf.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/readahead_tune.bpf.c b/readahead_tune.bpf.c
index 24a6ff9..cb29f3d 100644
--- a/readahead_tune.bpf.c
+++ b/readahead_tune.bpf.c
@@ -43,12 +43,12 @@ struct {
__uint(max_entries, MAP_ARRAY_SIZE);
} arraymap SEC(".maps");
-struct bpf_map_def SEC("maps") htab = {
- .type = BPF_MAP_TYPE_HASH,
- .key_size = sizeof(long),
- .value_size = sizeof(struct file_rd_hnode),
- .max_entries = MAX_HASH_TABLE_ENTRY,
-};
+struct {
+ __uint(type, BPF_MAP_TYPE_HASH);
+ __type(key, u64);
+ __type(value, struct file_rd_hnode);
+ __uint(max_entries, MAX_HASH_TABLE_ENTRY);
+} htab SEC(".maps");
/*
* This first paramater should be the exact position of variable, otherwise the start
--
2.33.0

View File

@ -1,13 +1,15 @@
Name: A-Tune-BPF-Collection Name: A-Tune-BPF-Collection
Version: 1.0.0 Version: 1.0.0
Release: 3 Release: 4
License: Mulan PSL v2 License: Mulan PSL v2
Summary: BPF program collection to adjust fine-grained kernel mode to get better performance Summary: BPF program collection to adjust fine-grained kernel mode to get better performance
URL: https://gitee.com/openeuler/A-Tune-BPF-Collection URL: https://gitee.com/openeuler/A-Tune-BPF-Collection
Source0: https://gitee.com/openeuler/A-Tune-BPF-Collection/repository/archive/v%{version}.tar.gz Source0: https://gitee.com/openeuler/A-Tune-BPF-Collection/repository/archive/v%{version}.tar.gz
Patch1: use-generated-vmlinux.h-instead-of-bpftool-gen-vmlin.patch Patch1: remove-spec-file-and-change-start_readahead_tune-s-d.patch
Patch2: Add-stack-protector-compile-option.patch Patch2: Drop-using-legacy-BPF-map-declaration.patch
Patch3: use-generated-vmlinux.h-instead-of-bpftool-gen-vmlin.patch
Patch4: Add-stack-protector-compile-option.patch
BuildRequires: clang, llvm, libbpf-devel BuildRequires: clang, llvm, libbpf-devel
Requires: libbpf Requires: libbpf
@ -39,6 +41,12 @@ install -D -p -m 0644 readahead_tune.conf %{buildroot}%{_sysconfdir}/sysconfig/r
%config(noreplace) %{_sysconfdir}/sysconfig/readahead_tune.conf %config(noreplace) %{_sysconfdir}/sysconfig/readahead_tune.conf
%changelog %changelog
* Wed Aug 3 2022 lvying<lvying6@huawei.com> - 1.0.0-4
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: Adapt new kernel and BPF compatibility
* Wed Mar 9 2022 lvying<lvying6@huawei.com> - 1.0.0-3 * Wed Mar 9 2022 lvying<lvying6@huawei.com> - 1.0.0-3
- Type:enhancement - Type:enhancement
- ID:NA - ID:NA

View File

@ -0,0 +1,79 @@
From 6b8c86e0caf821c7b58d168a0161a6aab000c8f2 Mon Sep 17 00:00:00 2001
From: Lv Ying <lvying6@huawei.com>
Date: Tue, 2 Aug 2022 19:18:17 +0800
Subject: [PATCH] remove spec file and change start_readahead_tune's directory
Signed-off-by: Lv Ying <lvying6@huawei.com>
---
atune_bpf_collection.spec | 45 ---------------------------------------
start_readahead_tune | 3 +++
2 files changed, 3 insertions(+), 45 deletions(-)
delete mode 100644 atune_bpf_collection.spec
diff --git a/atune_bpf_collection.spec b/atune_bpf_collection.spec
deleted file mode 100644
index 0ce6dce..0000000
--- a/atune_bpf_collection.spec
+++ /dev/null
@@ -1,45 +0,0 @@
-Name: A-Tune-BPF-Collection
-Version: 0.1
-Release: 1
-License: Mulan PSL v2
-Summary: BPF program collection to adjust fine-grained kernel mode to get better performance
-URL: https://gitee.com/openeuler/A-Tune-BPF-Collection
-Source0: https://gitee.com/openeuler/A-Tune-BPF-Collection/repository/archive/v%{version}.tar.gz
-
-BuildRequires: clang, llvm, libbpf-devel, bpftool, dwarves
-Requires: libbpf
-Provides: readahead_tune
-
-%define debug_package %{nil}
-
-%description
-A-Tune BPF Collection contains a set of BPF program which can interact with kernel in real time.
-It has the following capabilities:
-readahead_tune: trace file reading characteristics, then ajust file read mode to get maximum I/O efficency
-
-%prep
-%autosetup -n %{name}-%{version} -p1
-
-%build
-make %{?_smp_mflags}
-
-%install
-install -D -p -m 0755 readahead_tune %{buildroot}/%{_sbindir}/readahead_tune
-install -D -p -m 0644 readahead_tune.bpf.o %{buildroot}/%{_sbindir}/readahead_tune.bpf.o
-install -D -p -m 0755 start_readahead_tune %{buildroot}/%{_sbindir}/start_readahead_tune
-install -D -p -m 0755 stop_readahead_tune %{buildroot}/%{_sbindir}/stop_readahead_tune
-install -D -p -m 0644 readahead_tune.conf %{buildroot}%{_sysconfdir}/sysconfig/readahead_tune.conf
-
-%files
-%{_sbindir}/readahead_tune
-%{_sbindir}/readahead_tune.bpf.o
-%{_sbindir}/start_readahead_tune
-%{_sbindir}/stop_readahead_tune
-%config(noreplace) %{_sysconfdir}/sysconfig/readahead_tune.conf
-
-%changelog
-* Tue Nov 9 2021 lvying<lvying6@huawei.com> - 0.1-1
-- Type:feature
-- ID:NA
-- SUG:NA
-- DESC: Init A-Tune-BPF-Collection repo and add readahead_tune service
diff --git a/start_readahead_tune b/start_readahead_tune
index afae00c..5d5cd08 100755
--- a/start_readahead_tune
+++ b/start_readahead_tune
@@ -1,5 +1,8 @@
#!/bin/bash
+# change working directory to current binary position
+cd "$(dirname "$0")"
+
function usage()
{
echo "Usage: $0 [ -h | --help] [ -c | --config CONFIG_FILE ]"
--
2.33.0

File diff suppressed because it is too large Load Diff