Re: [RFC PATCH 14/19] mm/damon/sysfs: setup probes on DAMON core API parameters

Gutierrez Asier
2026-04-28T13:08:13Z

On 4/28/2026 3:48 AM, SeongJae Park wrote:
> Thank you for review, Asier!
>
> On Mon, 27 Apr 2026 16:25:12 +0300 Gutierrez Asier <gutierrez.asier@huawei-partners.com> wrote:
>
>>
>>
>> On 4/26/2026 11:52 PM, SeongJae Park wrote:
>>> Add user-installed data probes to DAMON core API parameters, so that
>>> user inputs for data probes are passed to DAMON core.
>>>
>>> Signed-off-by: SeongJae Park <sj@kernel.org>
>>> ---
>>> mm/damon/sysfs.c | 37 +++++++++++++++++++++++++++++++++++++
>>> 1 file changed, 37 insertions(+)
>>>
>>> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
>>> index 2e0b7eca6bcbf..8007961295d3d 100644
>>> --- a/mm/damon/sysfs.c
>>> +++ b/mm/damon/sysfs.c
>>> @@ -1855,6 +1855,40 @@ static int damon_sysfs_set_attrs(struct damon_ctx *ctx,
>>> return damon_set_attrs(ctx, &attrs);
>>> }
>>>
>>> +static int damon_sysfs_set_probes(struct damon_ctx *ctx,
>>> + struct damon_sysfs_probes *sys_probes)
>>> +{
>>> + int i;
>>> +
>>> + for (i = 0; i < sys_probes->nr; i++) {
>>> + struct damon_sysfs_filters *sys_filters =
>>> + sys_probes->probes_arr[i]->filters;
>>> + struct damon_probe *c;
>>> + int j;
>>> +
>>> + if (!sys_filters)
>>> + continue;
>>> + c = damon_new_probe();
>>> + if (!c)
>>> + return -ENOMEM;
>>> + damon_add_probe(ctx, c);
>>> +
>>> + for (j = 0; j < sys_filters->nr; j++) {
>>> + struct damon_sysfs_filter *sys_filter =
>>> + sys_filters->filters_arr[j];
>>> + struct damon_filter *t;
>> Move the declaration of these two variables to the top of the
>> function.
>
> I have no strong preference, but because this function is not very short, I
> think having declaration here makes reading the code easier. Also, this style
> is used in multiple places of sysfs.c including damon_sysfs_add_targets().
>
> So if I'm not missing something and you don't mind, I'd like to keep the
> current style.

Thanks fine. I just got used to declare the variables at the beginning
of the function to help the compiler optimize the code. But modern
compilers may be smart enough to figure it out and optimize the code
anyway.

>
> Thanks,
> SJ
>
> [...]
>

--
Asier Gutierrez
Huawei