From: haoxin <xhao@linux.alibaba.com>
To: SeongJae Park <sj@kernel.org>
Cc: akpm@linux-foundation.org, damon@lists.linux.dev,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V1 1/2] mm/damon/sysfs: avoid call damon_target_has_pid() repeatedly
Date: Fri, 16 Sep 2022 16:57:27 +0800 [thread overview]
Message-ID: <11a3021e-860b-e00e-8289-45831feed2e4@linux.alibaba.com> (raw)
In-Reply-To: <20220916084251.105360-1-sj@kernel.org>
在 2022/9/16 下午4:42, SeongJae Park 写道:
> On Thu, 15 Sep 2022 22:22:36 +0800 Xin Hao <xhao@linux.alibaba.com> wrote:
>
>> In damon_sysfs_destroy_targets(), we call damon_target_has_pid() to
>> check whether the 'ctx' include a valid pid, but there no need to call
>> damon_target_has_pid() to check repeatedly, just need call it once.
> Good eyes, nice finding!
>
>> Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
>> ---
>> mm/damon/sysfs.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
>> index 1fa0023f136e..966ea7892ccf 100644
>> --- a/mm/damon/sysfs.c
>> +++ b/mm/damon/sysfs.c
>> @@ -2143,9 +2143,13 @@ static int damon_sysfs_set_attrs(struct damon_ctx *ctx,
>> static void damon_sysfs_destroy_targets(struct damon_ctx *ctx)
>> {
>> struct damon_target *t, *next;
>> + bool has_pid = false;
>> +
>> + if (damon_target_has_pid(ctx))
>> + has_pid = true;
> How about doing more simple and short like below?
>
> bool has_pid = damon_target_has_pid(ctx)
Yes, Do like this, make code look more clean. but this patch has been
merged into, i send a new one to fix it ?
>
> Other than this,
>
> Reviewed-by: SeongJae Park <sj@kernel.org>
>
>
> Thanks,
> SJ
>
>> damon_for_each_target_safe(t, next, ctx) {
>> - if (damon_target_has_pid(ctx))
>> + if (has_pid)
>> put_pid(t->pid);
>> damon_destroy_target(t);
>> }
>> --
>> 2.31.0
prev parent reply other threads:[~2022-09-16 8:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-15 14:22 Xin Hao
2022-09-15 14:22 ` [PATCH V1 2/2] mm/damon/core: remove duplicate check about THP Xin Hao
2022-09-15 21:54 ` kernel test robot
2022-09-15 22:26 ` Andrew Morton
2022-09-16 1:37 ` haoxin
2022-09-15 22:16 ` kernel test robot
2022-09-16 8:42 ` [PATCH V1 1/2] mm/damon/sysfs: avoid call damon_target_has_pid() repeatedly SeongJae Park
2022-09-16 8:57 ` haoxin [this message]
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=11a3021e-860b-e00e-8289-45831feed2e4@linux.alibaba.com \
--to=xhao@linux.alibaba.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 \
/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