Compare commits

..

No commits in common. "5452ed882fd2abdfcd22f9ce4bcebdd70c1d75a8" and "25ce00f8f31d00db4455700df261e89c70cc53d7" have entirely different histories.

5 changed files with 4 additions and 445 deletions

View File

@ -1,56 +0,0 @@
From 11665b5fa21babc17a24ebf13c4282bf4b7d6e07 Mon Sep 17 00:00:00 2001
From: zhangxiang <zhangxiang@iscas.ac.cn>
Date: Mon, 31 Jul 2023 17:06:54 +0800
Subject: [PATCH] Add riscv64 support
---
etmem/CMakeLists.txt | 6 ++++++
etmem/test/CMakeLists.txt | 2 ++
2 files changed, 8 insertions(+)
diff --git a/etmem/CMakeLists.txt b/etmem/CMakeLists.txt
index 9e3194a..0b38f07 100644
--- a/etmem/CMakeLists.txt
+++ b/etmem/CMakeLists.txt
@@ -92,6 +92,8 @@ if( ${ARCHITECTURE} STREQUAL "aarch64" )
target_compile_options(etmemd PRIVATE -march=armv8-a)
elseif( ${ARCHITECTURE} STREQUAL "loongarch64" )
target_compile_options(etmemd PRIVATE -march=loongarch64)
+elseif( ${ARCHITECTURE} STREQUAL "riscv64" )
+ target_compile_options(etmemd PRIVATE -march=rv64gc)
else()
target_compile_options(etmemd PRIVATE -march=core-avx-i -m64)
endif()
@@ -109,6 +111,8 @@ if( ${ARCHITECTURE} STREQUAL "aarch64" )
target_compile_options(etmem PRIVATE -march=armv8-a)
elseif( ${ARCHITECTURE} STREQUAL "loongarch64" )
target_compile_options(etmemd PRIVATE -march=loongarch64)
+elseif( ${ARCHITECTURE} STREQUAL "riscv64" )
+ target_compile_options(etmemd PRIVATE -march=rv64gc)
else()
target_compile_options(etmem PRIVATE -march=core-avx-i -m64)
endif()
@@ -127,6 +131,8 @@ if( ${ARCHITECTURE} STREQUAL "aarch64" )
target_compile_options(etmemd_scan PRIVATE -march=armv8-a)
elseif( ${ARCHITECTURE} STREQUAL "loongarch64" )
target_compile_options(etmemd_scan PRIVATE -march=loongarch64)
+elseif( ${ARCHITECTURE} STREQUAL "riscv64" )
+ target_compile_options(etmemd PRIVATE -march=rv64gc)
else()
target_compile_options(etmemd_scan PRIVATE -march=core-avx-i -m64)
endif()
diff --git a/etmem/test/CMakeLists.txt b/etmem/test/CMakeLists.txt
index 928e358..b808eb2 100644
--- a/etmem/test/CMakeLists.txt
+++ b/etmem/test/CMakeLists.txt
@@ -156,6 +156,8 @@ if( ${ARCHITECTURE} STREQUAL "aarch64")
SET(COMMON_COMPILE_OPT ${COMMON_COMPILE_OPT} -march=armv8-a)
elseif( ${ARCHITECTURE} STREQUAL "loongarch64" )
SET(COMMON_COMPILE_OPT ${COMMON_COMPILE_OPT} -march=loongarch64)
+elseif( ${ARCHITECTURE} STREQUAL "riscv64" )
+ SET(COMMON_COMPILE_OPT ${COMMON_COMPILE_OPT} -march=rv64gc)
else()
SET(COMMON_COMPILE_OPT ${COMMON_COMPILE_OPT} -march=core-avx-i -m64)
endif()
--
Gitee

View File

@ -1,241 +0,0 @@
From 433c75be35d8e9aeabafa9c35cbd9d38855e0497 Mon Sep 17 00:00:00 2001
From: liubo <liubo254@huawei.com>
Date: Mon, 14 Aug 2023 16:03:38 +0800
Subject: [PATCH] etmem: fix project stop cmd timeout problem
In patch "fix fd leak when user stop task timer", set the
thread to PTHREAD_CANCEL_DISABLE to solve the FD leakage
problem during task obtaining.
However, when the project stop command is executed,
the rpc cmd exits only after all task threads are executed.
But the RPC cmd timeout period is only 10 seconds.
When the task execution time exceeds the timeout period, the RPC
command times out and an error message is returned.
According to code analysis, the most time-consuming part of all
tasks is in the sleep phase of the scanning logic.
The preceding problem is solved by skipping the corresponding
sleep environment and allowing the thread to exit directly.
Signed-off-by: liubo <liubo254@huawei.com>
Signed-off-by: volcanodragon <linfeilong@huawei.com>
---
etmem/inc/etmemd_inc/etmemd_threadpool.h | 2 +-
etmem/src/etmemd_src/etmemd_pool_adapter.c | 5 ++++-
etmem/src/etmemd_src/etmemd_scan.c | 17 ++++++++++++++++-
etmem/src/etmemd_src/etmemd_slide.c | 22 +++++++++++-----------
etmem/src/etmemd_src/etmemd_threadpool.c | 4 ++--
etmem/src/etmemd_src/etmemd_threadtimer.c | 18 ++++++------------
6 files changed, 40 insertions(+), 28 deletions(-)
diff --git a/etmem/inc/etmemd_inc/etmemd_threadpool.h b/etmem/inc/etmemd_inc/etmemd_threadpool.h
index 57af8be..4e62c81 100644
--- a/etmem/inc/etmemd_inc/etmemd_threadpool.h
+++ b/etmem/inc/etmemd_inc/etmemd_threadpool.h
@@ -74,6 +74,6 @@ void threadpool_reset_status(thread_pool** inst);
/*
* Stop and destroy the thread pool instance
* */
-void threadpool_stop_and_destroy(thread_pool** inst);
+void threadpool_stop_and_destroy(thread_pool **inst);
#endif //ETMEMD_THREADPOOL_H
diff --git a/etmem/src/etmemd_src/etmemd_pool_adapter.c b/etmem/src/etmemd_src/etmemd_pool_adapter.c
index dfda3f4..39f9451 100644
--- a/etmem/src/etmemd_src/etmemd_pool_adapter.c
+++ b/etmem/src/etmemd_src/etmemd_pool_adapter.c
@@ -50,6 +50,8 @@ static void *launch_threadtimer_executor(void *arg)
int scheduing_count;
if (tk->eng->proj->start) {
+ (void)pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+
if (etmemd_get_task_pids(tk, true) != 0) {
return NULL;
}
@@ -57,6 +59,7 @@ static void *launch_threadtimer_executor(void *arg)
push_ctrl_workflow(&tk->pids, executor->func);
threadpool_notify(tk->threadpool_inst);
+ (void)pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pool_inst = tk->threadpool_inst;
scheduing_count = __atomic_load_n(&pool_inst->scheduing_size, __ATOMIC_SEQ_CST);
@@ -120,12 +123,12 @@ void stop_and_delete_threadpool_work(struct task *tk)
tk->value, tk->eng->proj->name);
return;
}
-
/* stop the threadtimer first */
thread_timer_stop(tk->timer_inst);
/* destroy them then */
thread_timer_destroy(&tk->timer_inst);
+
threadpool_stop_and_destroy(&tk->threadpool_inst);
}
diff --git a/etmem/src/etmemd_src/etmemd_scan.c b/etmem/src/etmemd_src/etmemd_scan.c
index 699b1cd..5620951 100644
--- a/etmem/src/etmemd_src/etmemd_scan.c
+++ b/etmem/src/etmemd_src/etmemd_scan.c
@@ -120,6 +120,18 @@ void free_vmas(struct vmas *vmas)
free(vmas);
}
+static void clean_vmas_resource_unexpected(void *arg)
+{
+ struct vmas **vmas = (struct vmas **)arg;
+
+ if (*vmas == NULL) {
+ return;
+ }
+
+ free_vmas(*vmas);
+ *vmas = NULL;
+}
+
static bool parse_vma_seg0(struct vma *vma, const char *seg0)
{
int ret;
@@ -777,6 +789,7 @@ struct page_refs *etmemd_do_scan(const struct task_pid *tpid, const struct task
return NULL;
}
+ pthread_cleanup_push(clean_vmas_resource_unexpected, &vmas);
/* get vmas of target pid first. */
vmas = get_vmas(pid);
if (vmas == NULL) {
@@ -799,10 +812,12 @@ struct page_refs *etmemd_do_scan(const struct task_pid *tpid, const struct task
page_refs = NULL;
break;
}
+ (void)pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
sleep((unsigned)page_scan->sleep);
+ (void)pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
}
- free_vmas(vmas);
+ pthread_cleanup_pop(1);
return page_refs;
}
diff --git a/etmem/src/etmemd_src/etmemd_slide.c b/etmem/src/etmemd_src/etmemd_slide.c
index 1a11f45..25fa45d 100644
--- a/etmem/src/etmemd_src/etmemd_slide.c
+++ b/etmem/src/etmemd_src/etmemd_slide.c
@@ -212,13 +212,16 @@ static void *slide_executor(void *arg)
struct memory_grade *memory_grade = NULL;
struct page_sort *page_sort = NULL;
- if (check_should_swap(tk_pid) == DONT_SWAP) {
- return NULL;
- }
+ /* The pthread_setcancelstate interface returns an error only when the
+ * input parameter state is invalid, no need to check return value.
+ */
+ (void)pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
- if (pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL) != 0) {
- etmemd_log(ETMEMD_LOG_ERR, "failed to set pthread cancel state.\n");
- return NULL;
+ /* register cleanup function in case of unexpected cancellation detected */
+ pthread_cleanup_push(clean_page_refs_unexpected, &page_refs);
+
+ if (check_should_swap(tk_pid) == DONT_SWAP) {
+ goto scan_out;
}
page_refs = etmemd_do_scan(tk_pid, tk_pid->tk);
@@ -238,8 +241,7 @@ static void *slide_executor(void *arg)
scan_out:
clean_page_sort_unexpected(&page_sort);
- /* no need to use page_refs any longer. */
- clean_page_refs_unexpected(&page_refs);
+ pthread_cleanup_pop(1);
if (memory_grade == NULL) {
etmemd_log(ETMEMD_LOG_DEBUG, "pid %u memory grade is empty\n", tk_pid->pid);
@@ -261,9 +263,7 @@ exit:
etmemd_log(ETMEMD_LOG_INFO, "malloc_trim to release memory for pid %u fail\n", tk_pid->pid);
}
- if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0) {
- etmemd_log(ETMEMD_LOG_DEBUG, "pthread_setcancelstate PTHREAD_CANCEL_ENABLE failed.\n");
- }
+ (void)pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_testcancel();
return NULL;
diff --git a/etmem/src/etmemd_src/etmemd_threadpool.c b/etmem/src/etmemd_src/etmemd_threadpool.c
index 4375ca1..6d35fe1 100644
--- a/etmem/src/etmemd_src/etmemd_threadpool.c
+++ b/etmem/src/etmemd_src/etmemd_threadpool.c
@@ -203,7 +203,7 @@ static void threadpool_cancel_tasks_working(const thread_pool *inst)
int i;
for (i = 0; i < inst->max_thread_cap; i++) {
- pthread_cancel(inst->tid[i]);
+ (void)pthread_cancel(inst->tid[i]);
}
}
@@ -236,7 +236,7 @@ void threadpool_stop_and_destroy(thread_pool **inst)
threadpool_cancel_tasks_working(thread_instance);
for (i = 0; i < thread_instance->max_thread_cap; i++) {
- pthread_join(thread_instance->tid[i], NULL);
+ (void)pthread_join(thread_instance->tid[i], NULL);
}
free(thread_instance->tid);
diff --git a/etmem/src/etmemd_src/etmemd_threadtimer.c b/etmem/src/etmemd_src/etmemd_threadtimer.c
index 4014c72..582a84d 100644
--- a/etmem/src/etmemd_src/etmemd_threadtimer.c
+++ b/etmem/src/etmemd_src/etmemd_threadtimer.c
@@ -37,11 +37,7 @@ static void *thread_timer_routine(void *arg)
expired_time = timer->expired_time;
- if (pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL) != 0) {
- etmemd_log(ETMEMD_LOG_ERR, "failed to set pthread cancel state.\n");
- return NULL;
- }
-
+ pthread_cleanup_push(threadtimer_cancel_unlock, &timer->cond_mutex);
pthread_mutex_lock(&timer->cond_mutex);
while (!timer->down) {
if (clock_gettime(CLOCK_MONOTONIC, &timespec) != 0) {
@@ -64,12 +60,9 @@ static void *thread_timer_routine(void *arg)
break;
}
}
- threadtimer_cancel_unlock(&timer->cond_mutex);
+ /* unlock th timer->cond_mutex */
+ pthread_cleanup_pop(1);
- if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0) {
- etmemd_log(ETMEMD_LOG_DEBUG, "pthread_setcancelstate PTHREAD_CANCEL_ENABLE failed.\n");
- }
- pthread_testcancel();
pthread_exit(NULL);
}
@@ -149,9 +142,10 @@ void thread_timer_stop(timer_thread* inst)
return;
}
inst->down = true;
+ pthread_cond_broadcast(&(inst->cond));
- pthread_cancel(inst->pthread);
- pthread_join(inst->pthread, NULL);
+ (void)pthread_cancel(inst->pthread);
+ (void)pthread_join(inst->pthread, NULL);
etmemd_log(ETMEMD_LOG_DEBUG, "Timer instance stops ! \n");
}
--
2.33.0

View File

@ -1,59 +0,0 @@
From ae1a854beda0b9318e080acff64de3375eff75d3 Mon Sep 17 00:00:00 2001
From: Liu Chao <liuchao173@huawei.com>
Date: Tue, 2 Apr 2024 16:01:50 +0800
Subject: [PATCH] etmem: construct etmem debug info package
Currently, there is no debug info package for etmem, and this
can be a problem when trying to analyze a coredump
Signed-off-by: tangyuchen <tangyuchen5@huawei.com>
---
etmem/CMakeLists.txt | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/etmem/CMakeLists.txt b/etmem/CMakeLists.txt
index 0b38f07..6018ce0 100644
--- a/etmem/CMakeLists.txt
+++ b/etmem/CMakeLists.txt
@@ -83,9 +83,11 @@ target_compile_options(etmemd PRIVATE -fsigned-char -fno-omit-frame-pointer -Wal
if(CONFIG_DEBUG STREQUAL "y")
target_compile_options(etmemd PRIVATE -g)
+else()
+ target_link_options(etmemd PRIVATE -s)
endif()
-set_target_properties(etmemd PROPERTIES LINK_FLAGS "-s -fPIE -pie -fPIC -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines")
+target_link_options(etmemd PRIVATE -fPIE -pie -fPIC -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines)
target_link_libraries(etmemd PRIVATE pthread dl rt boundscheck numa ${GLIB2_LIBRARIES})
if( ${ARCHITECTURE} STREQUAL "aarch64" )
@@ -102,9 +104,11 @@ target_compile_options(etmem PRIVATE -fsigned-char -fno-omit-frame-pointer -Wall
if(CONFIG_DEBUG STREQUAL "y")
target_compile_options(etmem PRIVATE -g)
+else()
+ target_link_options(etmem PRIVATE -s)
endif()
-set_target_properties(etmem PROPERTIES LINK_FLAGS "-s -fPIE -pie -fPIC -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines")
+target_link_options(etmem PRIVATE -fPIE -pie -fPIC -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines)
target_link_libraries(etmem PRIVATE pthread dl rt boundscheck)
if( ${ARCHITECTURE} STREQUAL "aarch64" )
@@ -122,9 +126,11 @@ target_compile_options(etmemd_scan PRIVATE -fsigned-char -fno-omit-frame-pointer
if(CONFIG_DEBUG STREQUAL "y")
target_compile_options(etmemd_scan PRIVATE -g)
+else()
+ target_link_options(etmemd_scan PRIVATE -s)
endif()
-set_target_properties(etmemd_scan PROPERTIES LINK_FLAGS "-s -fPIE -pie -fPIC -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -Wl,--version-script=${ETMEMD_SRC_DIR}/etmemd_scan.version")
+target_link_options(etmemd_scan PRIVATE -fPIE -pie -fPIC -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines -Wl,--version-script=${ETMEMD_SRC_DIR}/etmemd_scan.version)
target_link_libraries(etmemd_scan PRIVATE pthread dl rt boundscheck numa ${GLIB2_LIBRARIES})
if( ${ARCHITECTURE} STREQUAL "aarch64" )
--
2.33.0

View File

@ -1,56 +0,0 @@
From e0703d2fc07f99c184d678d1d33ccf6fa7855d81 Mon Sep 17 00:00:00 2001
From: chenrenhui <chenrenhui1@huawei.com>
Date: Thu, 15 Aug 2024 20:29:15 +0800
Subject: [PATCH] etmem: set scan_type optional, and fix sequence of header file
Signed-off-by: chenrenhui <chenrenhui1@huawei.com>
---
etmem/inc/etmemd_inc/etmemd_thirdparty_export.h | 2 +-
etmem/src/etmemd_src/etmemd_file.c | 3 +++
etmem/src/etmemd_src/etmemd_project.c | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/etmem/inc/etmemd_inc/etmemd_thirdparty_export.h b/etmem/inc/etmemd_inc/etmemd_thirdparty_export.h
index 9d145ce..6cd8094 100644
--- a/etmem/inc/etmemd_inc/etmemd_thirdparty_export.h
+++ b/etmem/inc/etmemd_inc/etmemd_thirdparty_export.h
@@ -16,8 +16,8 @@
#ifndef ETMEM_THIRDPARTY_EXPORT_H
#define ETMEM_THIRDPARTY_EXPORT_H
-#include "etmemd_project_exp.h"
#include "etmemd_engine_exp.h"
+#include "etmemd_project_exp.h"
#include "etmemd_task_exp.h"
#endif
diff --git a/etmem/src/etmemd_src/etmemd_file.c b/etmem/src/etmemd_src/etmemd_file.c
index d204685..8e739d0 100644
--- a/etmem/src/etmemd_src/etmemd_file.c
+++ b/etmem/src/etmemd_src/etmemd_file.c
@@ -22,6 +22,9 @@ static int parse_item(GKeyFile *config, char *group_name, struct config_item *it
void *val;
if (!g_key_file_has_key(config, group_name, item->key, NULL)) {
+ if (strcmp(item->key, "scan_type") == 0) {
+ return item->fill(obj, "page");
+ }
if (item->option) {
return 0;
}
diff --git a/etmem/src/etmemd_src/etmemd_project.c b/etmem/src/etmemd_src/etmemd_project.c
index d1c34f3..4990fdb 100644
--- a/etmem/src/etmemd_src/etmemd_project.c
+++ b/etmem/src/etmemd_src/etmemd_project.c
@@ -716,7 +716,7 @@ static bool check_swapcache_wmark_valid(struct project *proj)
static struct config_item g_project_config_items[] = {
{"name", STR_VAL, fill_project_name, false},
- {"scan_type", STR_VAL, fill_project_scan_type, false},
+ {"scan_type", STR_VAL, fill_project_scan_type, true},
{"sysmem_threshold", INT_VAL, fill_project_sysmem_threshold, true},
{"swapcache_high_wmark", INT_VAL, fill_project_swapcache_high_wmark, true},
{"swapcache_low_wmark", INT_VAL, fill_project_swapcache_low_wmark, true},
--
2.45.1.windows.1

View File

@ -1,6 +1,8 @@
%global debug_package %{nil}
Name: etmem Name: etmem
Version: 1.1 Version: 1.1
Release: 9 Release: 4
Summary: etmem Summary: etmem
License: MulanPSL-2.0 License: MulanPSL-2.0
URL: https://gitee.com/openeuler/etmem URL: https://gitee.com/openeuler/etmem
@ -10,10 +12,6 @@ Patch0000: 0001-etmem-1.1-add-loongarch64-support.patch
Patch0001: 0002-etmem-remove-unnecessary-log-code.patch Patch0001: 0002-etmem-remove-unnecessary-log-code.patch
Patch0002: 0003-etmem-fix-memory-leak-and-fd-leak.patch Patch0002: 0003-etmem-fix-memory-leak-and-fd-leak.patch
Patch0003: 0004-etmem-fix-multiple-etmemd-and-too-many-err-log-probl.patch Patch0003: 0004-etmem-fix-multiple-etmemd-and-too-many-err-log-probl.patch
Patch0004: 0005-etmem-1.1-add-riscv64-support.patch
Patch0005: 0006-etmem-fix-project-stop-cmd-timeout-problem.patch
Patch0006: 0007-etmem-construct-etmem-debug-info-package.patch
Patch0007: 0008-etmem-set-scan_type-optional-and-fix-sequence-of-head.patch
#Dependency #Dependency
BuildRequires: cmake gcc gcc-c++ glib2-devel BuildRequires: cmake gcc gcc-c++ glib2-devel
@ -31,10 +29,7 @@ etmem module
%build %build
mkdir -p build mkdir -p build
cd build cd build
%if "%{?toolchain}" == "clang" cmake ..
CFLAGS="${CFLAGS:-%{?build_cflags}} -Wno-typedef-redefinition"; export CFLAGS;
%endif
cmake .. -DCONFIG_DEBUG=y
make make
%install %install
@ -70,30 +65,6 @@ install -m 0644 userswap/include/uswap_api.h $RPM_BUILD_ROOT%{_includedir}
%postun -p /sbin/ldconfig %postun -p /sbin/ldconfig
%changelog %changelog
* Mon Nov 4 2024 chenrenhui <chenrenhui1@huawei.com> - 1.1-9
- Type: bugfix
- CVE:NA
- SUG:NA
- DESC:set scan_type optional, and fix sequence of header file
* Tue Apr 2 2024 tangyuchen <tangyuchen5@huawei.com> - 1.1-8
- Type: bugfix
- CVE:NA
- SUG:NA
- DESC:add debug info support for etmem
* Thu Feb 22 2024 luofng <luofeng13@huawei.com> - 1.1-7
- Type: enhencement
- CVE:NA
- SUG:NA
- DESC:support for building with clang
* Thu Aug 24 2023 volcanodragon <linfeilong@huawei.com> - 1.1-6
- fix project stop cmd timeout problem
* Thu Jul 20 2023 zhangxiang <zhangxiang@iscas.ac.cn> - 1.1-5
- Add riscv64 support
* Thu Jun 8 2023 liubo <liubo254@huawei.com> 1.1-4 * Thu Jun 8 2023 liubo <liubo254@huawei.com> 1.1-4
- backport bugfix patch from upstream - backport bugfix patch from upstream