From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: SeongJae Park <sj@kernel.org>
Cc: syzbot <syzbot+841a46899768ec7bec67@syzkaller.appspotmail.com>,
<akpm@linux-foundation.org>, <damon@lists.linux.dev>,
<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
<syzkaller-bugs@googlegroups.com>
Subject: Re: [syzbot] [damon?] divide error in damon_set_attrs
Date: Sat, 27 May 2023 10:02:38 +0800 [thread overview]
Message-ID: <81956ca8-8228-1210-c855-e652e2f263dc@huawei.com> (raw)
In-Reply-To: <20230527014635.7380-1-sj@kernel.org>
On 2023/5/27 9:46, SeongJae Park wrote:
> Hi Kefeng,
>
> On Sat, 27 May 2023 09:15:01 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
> [...]
>>>
>>> Nice and effective fix! Nevertheless, I think aggregation interval smaller
>>> than sample interval is just a wrong input. How about adding the check in
>>> damon_set_attrs()'s already existing attributes validation, like below?
>>
>> Yes, move the check into damon_set_attrs() is better
>
> Thank you for this kind comment!
>
>> , and it seems that
>> we could move all the check into it, and drop the old_attrs check in
>> damon_update_monitoring_results(), what's you option?
>>
>>
>> diff --git a/mm/damon/core.c b/mm/damon/core.c
>> index d9ef62047bf5..1647f7f1f708 100644
>> --- a/mm/damon/core.c
>> +++ b/mm/damon/core.c
>> @@ -523,12 +523,6 @@ static void damon_update_monitoring_results(struct
>> damon_ctx *ctx,
>> struct damon_target *t;
>> struct damon_region *r;
>>
>> - /* if any interval is zero, simply forgive conversion */
>> - if (!old_attrs->sample_interval || !old_attrs->aggr_interval ||
>> - !new_attrs->sample_interval ||
>> - !new_attrs->aggr_interval)
>> - return;
>> -
>> damon_for_each_target(t, ctx)
>> damon_for_each_region(r, t)
>> damon_update_monitoring_result(
>> @@ -551,6 +545,10 @@ int damon_set_attrs(struct damon_ctx *ctx, struct
>> damon_attrs *attrs)
>> return -EINVAL;
>> if (attrs->min_nr_regions > attrs->max_nr_regions)
>> return -EINVAL;
>> + if (attrs->sample_interval > attrs->aggr_interval)
>> + return -EINVAL;
>> + if (!attrs->sample_interval || !attrs->aggr_interval)
>> + return -EINVAL;
>
> In my humble opinion, the validation for monitoring results and for general
> monitoring could be different. For example, zero aggreation/sampling intervals
> might make sense for fixed granularity working set size monitoring. Hence, I'd
> prefer keeping those checks in the damon_update_monitoring_results().
ok, will keep that, I check the damon_set_attrs() called by
lru_sort/reclaim monitor and sysfs/dbgfs, the above changes should be
ok, maybe missing something, the working set size monitoring is not
public for now?
>
>
> Thanks,
> SJ
>
> [...]
next prev parent reply other threads:[~2023-05-27 2:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 11:51 syzbot
2023-05-26 12:59 ` Kefeng Wang
2023-05-26 18:54 ` SeongJae Park
2023-05-26 19:35 ` SeongJae Park
2023-05-27 1:15 ` Kefeng Wang
2023-05-27 1:46 ` SeongJae Park
2023-05-27 2:02 ` Kefeng Wang [this message]
2023-05-27 2:08 ` SeongJae Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=81956ca8-8228-1210-c855-e652e2f263dc@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sj@kernel.org \
--cc=syzbot+841a46899768ec7bec67@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox