Skip to contentSkip to conversation

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

PATCH Superseded Xin Hao 2 participants 3 messages Nov 18, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xin Hao

author
#0 lore raw

PATCH 1/1 mm/damon/schemes: Add the validity judgment of thresholds

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 threshold values.

---
 mm/damon/dbgfs.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
mm/damon/dbgfs.c +11 -0
index befb27a29aab..a4c94d563d3d 100644
@@ -215,6 +215,17 @@ 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) {
+			pr_err("mininum > maxinum\n");
+			goto fail;
+		}
+
+		if (wmarks.high < wmarks.mid || wmarks.high < wmarks.low ||
+		    wmarks.mid <  wmarks.low) {
+			pr_err("wrong wmarks\n");
+			goto fail;
+		}
+
 		pos += parsed;
 		scheme = damon_new_scheme(min_sz, max_sz, min_nr_a, max_nr_a,
 				min_age, max_age, action, &quota, &wmarks);
Signature · 1 line
2.31.0
maintainer
#1 lore raw

Hi Xin,

Thank you for this patch.

From next time, please send patches for DAMON to [email protected] instead of [email protected].

Quoted 22 lines · On Thu, 18 Nov 2021 12:16:02 +0800 Xin Hao <[email protected]> wrote:

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 threshold values.

---
 mm/damon/dbgfs.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
mm/damon/dbgfs.c +0 -0
index befb27a29aab..a4c94d563d3d 100644

mm/damon/dbgfs.c static struct damos **str_to_schemes(const char *str, ssize_t len, · line 219

Quoted 5 lines
mm/damon/dbgfs.c +2 -0
@@ -215,6 +215,17 @@ 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) {
+			pr_err("mininum > maxinum\n");

I think this error message is not really needed.

mm/damon/dbgfs.c static struct damos **str_to_schemes(const char *str, ssize_t len, · line 225

Quoted 6 lines
mm/damon/dbgfs.c +6 -0
+			goto fail;
+		}
+
+		if (wmarks.high < wmarks.mid || wmarks.high < wmarks.low ||
+		    wmarks.mid <  wmarks.low) {
+			pr_err("wrong wmarks\n");

Ditto.

Thanks,
SJ

Quoted 8 lines
mm/damon/dbgfs.c +3 -0
+			goto fail;
+		}
+
 		pos += parsed;
 		scheme = damon_new_scheme(min_sz, max_sz, min_nr_a, max_nr_a,
 				min_age, max_age, action, &quota, &wmarks);
Signature · 1 line
2.31.0
author
#2 lore raw
Quoted 9 lines · SeongJae Park

Hi Xin,

Thank you for this patch.

From next time, please send patches for DAMON to [email protected] instead of
[email protected].

On Thu, 18 Nov 2021 12:16:02 +0800 Xin Hao <[email protected]> wrote:

Oh,l will.

Quoted 25 lines
Quoted 25 lines

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 threshold values.

---
  mm/damon/dbgfs.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
mm/damon/dbgfs.c +0 -0
index befb27a29aab..a4c94d563d3d 100644
@@ -215,6 +215,17 @@ static struct damos **str_to_schemes(const char *str, ssize_t len,
  			goto fail;
  		}
 
Quoted 3 lines

mm/damon/dbgfs.c static struct damos **str_to_schemes(const char *str, ssize_t len, · line 219

Quoted 2 lines
mm/damon/dbgfs.c +2 -0
+		if (min_sz > max_sz || min_nr_a > max_nr_a || min_age > max_age) {
+			pr_err("mininum > maxinum\n");

I think this error message is not really needed.

Ok, i will remove it, i add this message is aim to better find where is wrong, because there have so many variables

Quoted 21 lines

mm/damon/dbgfs.c static struct damos **str_to_schemes(const char *str, ssize_t len, · line 225

Quoted 7 lines
mm/damon/dbgfs.c +6 -0
+			goto fail;
+		}
+
+		if (wmarks.high < wmarks.mid || wmarks.high < wmarks.low ||
+		    wmarks.mid <  wmarks.low) {
+			pr_err("wrong wmarks\n");

Ditto.

Thanks,
SJ

Quoted 8 lines
mm/damon/dbgfs.c +3 -0
+			goto fail;
+		}
+
  		pos += parsed;
  		scheme = damon_new_scheme(min_sz, max_sz, min_nr_a, max_nr_a,
  				min_age, max_age, action, &quota, &wmarks);
Signature · 1 line
2.31.0
Signature · 2 lines
Best Regards!
Xin Hao