diff --git a/0001-filter-so-address-pmudata.patch b/0001-filter-so-address-pmudata.patch new file mode 100644 index 0000000000000000000000000000000000000000..5f4ab939dc23ac614a9ca7990783308ab2eeafcd --- /dev/null +++ b/0001-filter-so-address-pmudata.patch @@ -0,0 +1,127 @@ +From bfbec494a98f6b872b7449c4f641d2a94942d84b Mon Sep 17 00:00:00 2001 +From: rfwang07 +Date: Tue, 10 Dec 2024 16:06:31 +0800 +Subject: [PATCH] filter so address pmudata + +--- + include/records.h | 1 + + src/configs.cc | 4 +++- + src/oeaware_plugins/tuner_sysboost.cc | 1 + + src/records.cc | 1 + + src/startup_opt.cc | 28 +++++++++++++++++++++------ + 5 files changed, 28 insertions(+), 7 deletions(-) + +diff --git a/include/records.h b/include/records.h +index c86ce62..df7d39d 100644 +--- a/include/records.h ++++ b/include/records.h +@@ -23,6 +23,7 @@ typedef struct { + typedef struct { + uint64_t processed_samples; + std::map pids; ++ std::map modules; + } global_records; + + extern global_records records; +diff --git a/src/configs.cc b/src/configs.cc +index 9aa6d36..ab96d2a 100644 +--- a/src/configs.cc ++++ b/src/configs.cc +@@ -128,12 +128,14 @@ std::string get_app_collected_profile_path(AppConfig *app) + int parse_app(boost::property_tree::ptree pt, std::string app_name) + { + std::string full_path; ++ char rlpath[1024] = {0}; + try { + full_path = pt.get(app_name + ".FULL_PATH"); +- if (!boost::filesystem::exists(full_path)) { ++ if (!get_real_path(full_path.c_str(), rlpath)) { + ERROR("Error: File does not exist: " << full_path); + return DFOT_ERROR; + } ++ full_path = std::string(rlpath); + } catch (const boost::property_tree::ptree_bad_path &e) { + ERROR("FULL_PATH is needed."); + return DFOT_ERROR; +diff --git a/src/oeaware_plugins/tuner_sysboost.cc b/src/oeaware_plugins/tuner_sysboost.cc +index b471ccf..14025fd 100644 +--- a/src/oeaware_plugins/tuner_sysboost.cc ++++ b/src/oeaware_plugins/tuner_sysboost.cc +@@ -81,6 +81,7 @@ void SysboostTuner::UpdateData(const DataList &dataList) + processing = true; + + int64_t start_ts = get_current_timestamp(); ++ records.modules.clear(); + uint64_t total_samples = 0; + for (unsigned long long i = 0; i < dataList.len; i++) { + PmuSamplingData *data = (PmuSamplingData *)(dataList.data[i]); +diff --git a/src/records.cc b/src/records.cc +index 1f2cbe3..9b212a6 100644 +--- a/src/records.cc ++++ b/src/records.cc +@@ -8,6 +8,7 @@ void reset_records() + { + records.processed_samples = 0; + records.pids.clear(); ++ records.modules.clear(); + } + + void debug_print_records() +diff --git a/src/startup_opt.cc b/src/startup_opt.cc +index 14b4aa4..78cae70 100644 +--- a/src/startup_opt.cc ++++ b/src/startup_opt.cc +@@ -92,9 +92,25 @@ void update_app_profile_data(AppConfig *app, struct PmuData &data) + // {函数名func: {内存地址addr: 计数count, ...}, ...} + auto &funcs = app->profile.funcs; + ++ // 刷新modules记录,避免直接匹配modules字符串,此处的module是relapath路径 ++ auto symbol = data.stack->symbol; ++ if (records.modules.find(symbol->module) == records.modules.end()) { ++ records.modules[symbol->module] = false; ++ if (strcmp(symbol->module, app->full_path.c_str()) == 0) { ++ records.modules[symbol->module] = true; ++ } else if (strstr(symbol->module, ".rto") != nullptr && ++ strncmp(symbol->module, app->full_path.c_str(), strlen(app->full_path.c_str())) == 0) { ++ records.modules[symbol->module] = true; ++ } ++ } ++ ++ if (!records.modules[symbol->module]) { ++ return; ++ } ++ + // symbol->codeMapAddr symbol->offset + // 如果是BOLT优化过后的二进制的采样数据则只需记录地址和计数 +- unsigned long addr = data.stack->symbol->codeMapAddr; ++ unsigned long addr = symbol->codeMapAddr; + + if (records.pids[data.pid]->instance->version > 0) { + if (addrs.find(addr) != addrs.end()) { +@@ -108,18 +124,18 @@ void update_app_profile_data(AppConfig *app, struct PmuData &data) + // 原始二进制的采样数据,读取地址+符号+偏移 + if (addrs.find(addr) != addrs.end()) { + addrs[addr].count++; +- funcs[addrs[addr].name][data.stack->symbol->offset]++; ++ funcs[addrs[addr].name][symbol->offset]++; + } else { + addrs[addr] = AddrInfo(); +- if (data.stack->symbol->mangleName != nullptr) { +- addrs[addr].name = data.stack->symbol->mangleName; ++ if (symbol->mangleName != nullptr) { ++ addrs[addr].name = symbol->mangleName; + } else { + auto sym = SymResolverMapAddr(data.pid, addr); + addrs[addr].name = sym->mangleName; + } +- addrs[addr].offset = data.stack->symbol->offset; ++ addrs[addr].offset = symbol->offset; + addrs[addr].count = 1; +- funcs[addrs[addr].name][data.stack->symbol->offset] = 1; ++ funcs[addrs[addr].name][symbol->offset] = 1; + } + } + +-- +2.39.5 (Apple Git-154) + diff --git a/D-FOT-v1.0.1.tar.gz b/D-FOT-v1.0.1.tar.gz deleted file mode 100644 index 5f60da1f323be37105aecebd82d458d03b032940..0000000000000000000000000000000000000000 Binary files a/D-FOT-v1.0.1.tar.gz and /dev/null differ diff --git a/D-FOT-v1.0.2.tar.gz b/D-FOT-v1.0.2.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..40291a6c7ebb8448fc82716a198f49ff29602c79 Binary files /dev/null and b/D-FOT-v1.0.2.tar.gz differ diff --git a/D-FOT.spec b/D-FOT.spec index 669f6a0540b3c5fcc4a22ce5c7f1ae1626eb2ae6..ad26db7782eb597867d0693a343469bd804fe305 100644 --- a/D-FOT.spec +++ b/D-FOT.spec @@ -1,49 +1,29 @@ Name: D-FOT -Version: v1.0.1 -Release: 1 +Version: v1.0.2 +Release: 3 Summary: %{name} is a dynamic feedback-directed optimization tool for openEuler. License: Mulan PSL v2 URL: https://gitee.com/openeuler/%{name} Source0: %{name}-%{version}.tar.gz -BuildRequires: cmake make gcc-c++ boost-devel log4cplus-devel numactl-devel -BuildRequires: git +Patch1: 0001-filter-so-address-pmudata.patch -Requires: oeAware-manager llvm-bolt +BuildRequires: cmake make gcc-c++ +BuildRequires: boost-devel log4cplus-devel numactl-devel libkperf-devel oeAware-manager-devel +Requires: log4cplus boost libboundscheck oeAware-manager libkperf llvm-bolt ExclusiveArch: aarch64 -%global libkperf_name libkperf -%global libkperf_tagver v1.2.1 -%global libkperf_source https://gitee.com/openeuler/libkperf.git - %description %{name} is a dynamic feedback-directed optimization tool for openEuler. %prep -%autosetup -n %{name}-%{version} -mkdir thirdparty && cd thirdparty -git clone --recurse-submodules %{libkperf_source} -cd %{libkperf_name} -git checkout %{libkperf_tagver} -cd .. -mv %{libkperf_name} %{libkperf_name}-%{libkperf_tagver} -cd .. +%autosetup -n %{name}-%{version} -p1 %build -# build libkperf.so -cd thirdparty/%{libkperf_name}-%{libkperf_tagver} -sh build.sh -cd ../../ - -# build libdfot.so mkdir build && cd build -cmake .. \ - -DLIB_KPERF_LIBPATH=%{_builddir}/%{name}-%{version}/thirdparty/%{libkperf_name}-%{libkperf_tagver}/output/lib \ - -DLIB_KPERF_INCPATH=%{_builddir}/%{name}-%{version}/thirdparty/%{libkperf_name}-%{libkperf_tagver}/output/include \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_SKIP_RPATH=TRUE +cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_SKIP_RPATH=TRUE make %install @@ -58,6 +38,26 @@ install -D -m 0640 ./configs/dfot.ini ${RPM_BUILD_ROOT}/etc/dfot/ %attr(0440,root,root) %{_libdir}/oeAware-plugin/libdfot.so %changelog +* Wed Feb 26 2025 rfwang07 - v1.0.2-3 +- ID:NA +- SUG:NA +- DESC: filter out default cmake options + +* Wed Dec 11 2024 rfwang07 - v1.0.2-2 +- ID:NA +- SUG:NA +- DESC: filter so address in pmudata + +* Tue Dec 10 2024 rfwang07 - v1.0.2-1 +- ID:NA +- SUG:NA +- DESC: fix pmudata processing bugs and add execution check + +* Tue Dec 3 2024 rfwang07 - v1.0.1-2 +- ID:NA +- SUG:NA +- DESC: update libkperf dependence and adapt code for oeaware 2.0 + * Wed Nov 27 2024 rfwang07 - v1.0.1-1 - ID:NA - SUG:NA