提交 21eb0b09 编写于 作者: X Xin Hao 提交者: Zheng Zengkai

mm/damon/schemes: add the validity judgment of thresholds

mainline inclusion
from mainline-v5.17-rc1
commit c89ae63e
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4RTX9

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c89ae63eb0662b6c9f82dbfad3ef010239b8c1b1

--------------------------------

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.

Link: https://lkml.kernel.org/r/d78360e52158d786fcbf20bc62c96785742e76d3.1637239568.git.xhao@linux.alibaba.comSigned-off-by: NXin Hao <xhao@linux.alibaba.com>
Reviewed-by: NSeongJae Park <sj@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit c89ae63e)
Signed-off-by: NYue Zou <zouyue3@huawei.com>
Reviewed-by: Kefeng Wang<wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 27926a15
...@@ -213,6 +213,13 @@ static struct damos **str_to_schemes(const char *str, ssize_t len, ...@@ -213,6 +213,13 @@ static struct damos **str_to_schemes(const char *str, ssize_t len,
if (!damos_action_valid(action)) if (!damos_action_valid(action))
goto fail; 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; pos += parsed;
scheme = damon_new_scheme(min_sz, max_sz, min_nr_a, max_nr_a, scheme = damon_new_scheme(min_sz, max_sz, min_nr_a, max_nr_a,
min_age, max_age, action, &quota, &wmarks); min_age, max_age, action, &quota, &wmarks);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册