linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V1] mm/damon/schemes: Add the validity judgment of thresholds
@ 2021-11-18  4:16 Xin Hao
  2021-11-18 11:51 ` SeongJae Park
  0 siblings, 1 reply; 3+ messages in thread
From: Xin Hao @ 2021-11-18  4:16 UTC (permalink / raw)
  To: sjpark; +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 threshold values.

Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
---
 mm/damon/dbgfs.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
index befb27a29aab..a4c94d563d3d 100644
--- a/mm/damon/dbgfs.c
+++ b/mm/damon/dbgfs.c
@@ -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);
-- 
2.31.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V1] mm/damon/schemes: Add the validity judgment of thresholds
  2021-11-18  4:16 [PATCH V1] mm/damon/schemes: Add the validity judgment of thresholds Xin Hao
@ 2021-11-18 11:51 ` SeongJae Park
  2021-11-18 12:00   ` Xin Hao
  0 siblings, 1 reply; 3+ messages in thread
From: SeongJae Park @ 2021-11-18 11:51 UTC (permalink / raw)
  To: Xin Hao; +Cc: sjpark, sj, akpm, linux-mm, linux-kernel

Hi Xin,


Thank you for this patch.

From next time, please send patches for DAMON to sj@kernel.org instead of
sjpark@amazon.de.

On Thu, 18 Nov 2021 12:16:02 +0800 Xin Hao <xhao@linux.alibaba.com> 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.
> 
> Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
> ---
>  mm/damon/dbgfs.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
> index befb27a29aab..a4c94d563d3d 100644
> --- a/mm/damon/dbgfs.c
> +++ b/mm/damon/dbgfs.c
> @@ -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.

> +			goto fail;
> +		}
> +
> +		if (wmarks.high < wmarks.mid || wmarks.high < wmarks.low ||
> +		    wmarks.mid <  wmarks.low) {
> +			pr_err("wrong wmarks\n");

Ditto.


Thanks,
SJ

> +			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);
> -- 
> 2.31.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V1] mm/damon/schemes: Add the validity judgment of thresholds
  2021-11-18 11:51 ` SeongJae Park
@ 2021-11-18 12:00   ` Xin Hao
  0 siblings, 0 replies; 3+ messages in thread
From: Xin Hao @ 2021-11-18 12:00 UTC (permalink / raw)
  To: SeongJae Park; +Cc: sjpark, akpm, linux-mm, linux-kernel


On 11/18/21 7:51 PM, SeongJae Park wrote:
> Hi Xin,
>
>
> Thank you for this patch.
>
>  From next time, please send patches for DAMON to sj@kernel.org instead of
> sjpark@amazon.de.
>
> On Thu, 18 Nov 2021 12:16:02 +0800 Xin Hao <xhao@linux.alibaba.com> wrote:
Oh,l will.
>> 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.
>>
>> Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
>> ---
>>   mm/damon/dbgfs.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
>> index befb27a29aab..a4c94d563d3d 100644
>> --- a/mm/damon/dbgfs.c
>> +++ b/mm/damon/dbgfs.c
>> @@ -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.
Ok, i will remove it, i add this message is aim to better find where is 
wrong, because there have so many variables
>
>> +			goto fail;
>> +		}
>> +
>> +		if (wmarks.high < wmarks.mid || wmarks.high < wmarks.low ||
>> +		    wmarks.mid <  wmarks.low) {
>> +			pr_err("wrong wmarks\n");
> Ditto.
>
>
> Thanks,
> SJ
>
>> +			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);
>> -- 
>> 2.31.0

-- 
Best Regards!
Xin Hao


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-18 12:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18  4:16 [PATCH V1] mm/damon/schemes: Add the validity judgment of thresholds Xin Hao
2021-11-18 11:51 ` SeongJae Park
2021-11-18 12:00   ` 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).