* [PATCH V2] mm/damon/schemes: Add the validity judgment of thresholds
@ 2021-11-18 12:46 Xin Hao
0 siblings, 0 replies; only message in thread
From: Xin Hao @ 2021-11-18 12:46 UTC (permalink / raw)
To: sj; +Cc: xhao, akpm, linux-mm, linux-kernel
In dbgfs "schemes" interface, i do some test like this:
# cd /sys/kernel/debug/damon
# echo "2 1 2 1 10 1 3 10 1 1 1 1 1 1 1 1 2 3" > schemes
# cat schemes
# 2 1 2 1 10 1 3 10 1 1 1 1 1 1 1 1 2 3 0 0
There have some unreasonable places, i set the valules of these variables
"<min_sz, max_sz> <min_nr_a, max_nr_a>, <min_age, max_age>, <wmarks.high,
wmarks.mid, wmarks.low>" as "<2, 1>, <2, 1>, <10, 1>, <1, 2, 3>.
So there add a validity judgment for these thresholds value.
Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
---
mm/damon/dbgfs.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
index befb27a29aab..4a96cd4df24f 100644
--- a/mm/damon/dbgfs.c
+++ b/mm/damon/dbgfs.c
@@ -215,6 +215,13 @@ static struct damos **str_to_schemes(const char *str, ssize_t len,
goto fail;
}
+ if (min_sz > max_sz || min_nr_a > max_nr_a || min_age > max_age)
+ goto fail;
+
+ if (wmarks.high < wmarks.mid || wmarks.high < wmarks.low ||
+ wmarks.mid < wmarks.low)
+ goto fail;
+
pos += parsed;
scheme = damon_new_scheme(min_sz, max_sz, min_nr_a, max_nr_a,
min_age, max_age, action, "a, &wmarks);
--
2.31.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-11-18 12:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18 12:46 [PATCH V2] mm/damon/schemes: Add the validity judgment of thresholds Xin Hao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).