Sync the features and bug fixed in the etmem source repository. Signed-off-by: liubo <liubo254@huawei.com> (cherry picked from commit 07dd6a411bce9ed3d9f617a6f01ae076e24a3adf)
94 lines
3.5 KiB
Diff
94 lines
3.5 KiB
Diff
From fff3255965293f42b9b6af79d0766110411c49d4 Mon Sep 17 00:00:00 2001
|
|
From: liubo <liubo254@huawei.com>
|
|
Date: Sat, 12 Feb 2022 10:15:28 +0800
|
|
Subject: [PATCH 19/33] etmem: fix the swapcache wmark configuration parse
|
|
error
|
|
|
|
swapcache_high_wmark and swapcache_low_wmark should
|
|
appear in pairs, missing either part should report
|
|
an error.
|
|
In addition, swapcache_high_wmark should be greater
|
|
than swapcache_low_wmark.
|
|
|
|
Signed-off-by: liubo <liubo254@huawei.com>
|
|
---
|
|
etmem/src/etmemd_src/etmemd_migrate.c | 2 +-
|
|
etmem/src/etmemd_src/etmemd_project.c | 20 ++++++++++++++------
|
|
2 files changed, 15 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/etmem/src/etmemd_src/etmemd_migrate.c b/etmem/src/etmemd_src/etmemd_migrate.c
|
|
index a5cce41..a143c5e 100644
|
|
--- a/etmem/src/etmemd_src/etmemd_migrate.c
|
|
+++ b/etmem/src/etmemd_src/etmemd_migrate.c
|
|
@@ -115,7 +115,7 @@ static bool check_should_reclaim_swapcache(const struct task_pid *tk_pid)
|
|
unsigned long swapcache_total;
|
|
int ret;
|
|
|
|
- if (proj->swapcache_high_wmark == 0) {
|
|
+ if (proj->swapcache_high_wmark == -1 || proj->swapcache_low_wmark == -1) {
|
|
return false;
|
|
}
|
|
|
|
diff --git a/etmem/src/etmemd_src/etmemd_project.c b/etmem/src/etmemd_src/etmemd_project.c
|
|
index 72d7335..e238e66 100644
|
|
--- a/etmem/src/etmemd_src/etmemd_project.c
|
|
+++ b/etmem/src/etmemd_src/etmemd_project.c
|
|
@@ -649,13 +649,13 @@ static int fill_project_sysmem_threshold(void *obj, void *val)
|
|
}
|
|
|
|
/* fill the project parameter: swapcache_low_wmark
|
|
- * swapcache_low_wmark: [0, 100]. */
|
|
+ * swapcache_low_wmark: (0, 100]. */
|
|
static int fill_project_swapcache_low_wmark(void *obj, void *val)
|
|
{
|
|
struct project *proj = (struct project *)obj;
|
|
int swapcache_low_wmark = parse_to_int(val);
|
|
|
|
- if (swapcache_low_wmark < 0 || swapcache_low_wmark > MAX_SWAPCACHE_WMARK_VALUE) {
|
|
+ if (swapcache_low_wmark <= 0 || swapcache_low_wmark > MAX_SWAPCACHE_WMARK_VALUE) {
|
|
etmemd_log(ETMEMD_LOG_ERR, "invaild project swapcache_low_wmark value %d, it must between 0 and 100.\n",
|
|
swapcache_low_wmark);
|
|
return -1;
|
|
@@ -672,7 +672,7 @@ static int fill_project_swapcache_high_wmark(void *obj, void *val)
|
|
struct project *proj = (struct project *)obj;
|
|
int swapcache_high_wmark = parse_to_int(val);
|
|
|
|
- if (swapcache_high_wmark < 0 || swapcache_high_wmark > MAX_SWAPCACHE_WMARK_VALUE) {
|
|
+ if (swapcache_high_wmark <= 0 || swapcache_high_wmark > MAX_SWAPCACHE_WMARK_VALUE) {
|
|
etmemd_log(ETMEMD_LOG_ERR, "invaild project swapcache_high_wmark value %d, it must between 0 and 100.\n",
|
|
swapcache_high_wmark);
|
|
return -1;
|
|
@@ -684,11 +684,17 @@ static int fill_project_swapcache_high_wmark(void *obj, void *val)
|
|
|
|
static bool check_swapcache_wmark_valid(struct project *proj)
|
|
{
|
|
- if (proj->swapcache_low_wmark > proj->swapcache_high_wmark) {
|
|
- return false;
|
|
+ if (proj->swapcache_high_wmark == -1 && proj->swapcache_low_wmark == -1) {
|
|
+ return true;
|
|
}
|
|
|
|
- return true;
|
|
+ if ((proj->swapcache_high_wmark > 0) &&
|
|
+ (proj->swapcache_low_wmark > 0) &&
|
|
+ (proj->swapcache_high_wmark > proj->swapcache_low_wmark)) {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ return false;
|
|
}
|
|
|
|
static struct config_item g_project_config_items[] = {
|
|
@@ -759,6 +765,8 @@ enum opt_result etmemd_project_add(GKeyFile *config)
|
|
}
|
|
|
|
proj->sysmem_threshold = -1;
|
|
+ proj->swapcache_high_wmark = -1;
|
|
+ proj->swapcache_low_wmark = -1;
|
|
|
|
if (project_fill_by_conf(config, proj) != 0) {
|
|
etmemd_log(ETMEMD_LOG_ERR, "fill project from configuration file fail\n");
|
|
--
|
|
1.8.3.1
|
|
|