All of lore.kernel.org
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Xin Hao <xhao@linux.alibaba.com>
Cc: sjpark@amazon.de, akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2] mm/damon/dbgfs: Optimize target_ids interface write operation
Date: Thu, 21 Oct 2021 17:30:18 +0000	[thread overview]
Message-ID: <20211021173018.15994-1-sj@kernel.org> (raw)
In-Reply-To: <bc341f48b5558f6816dcef22eca4f4a590efdc67.1634834628.git.xhao@linux.alibaba.com>

Hello Xin,

On Fri, 22 Oct 2021 00:44:16 +0800 Xin Hao <xhao@linux.alibaba.com> wrote:

> When we want to clear previously set target ids,
> For example, it works as below now:
>     # echo 42 > target_ids
>     # cat target_ids
>     42
>     # echo > target_ids
>     # cat target_ids
> 
> But in 'dbgfs_target_ids_write', there is no need to
> execute other codes, except call 'damon_set_targets'
> to clear previously set target ids. So there adds
> the 'nr_targets' judgment, if the value is 0, just
> call 'damon_set_targets', and then return.

It's true that it executes some unnecessary code.  However, I unsure if that is
a problem, as the code that will be additionally executed in this case are
quite simple ones, and therefore not supposed to incur viewable overhead.
After all, this is not a performance critical path.

Thanks,
SJ

> 
> Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
> ---
>  mm/damon/dbgfs.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
> index a02cf6bee8e8..1d83f4138fad 100644
> --- a/mm/damon/dbgfs.c
> +++ b/mm/damon/dbgfs.c
> @@ -362,6 +362,12 @@ static ssize_t dbgfs_target_ids_write(struct file *file,
>  		goto out;
>  	}
> 
> +	if (!nr_targets) {
> +		/* remove targets with previously-set primitive */
> +		damon_set_targets(ctx, NULL, 0);
> +		goto free_targets_out;
> +	}
> +
>  	if (id_is_pid) {
>  		for (i = 0; i < nr_targets; i++) {
>  			targets[i] = (unsigned long)find_get_pid(
> --
> 2.31.0


  reply	other threads:[~2021-10-21 17:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 16:44 [PATCH V2] mm/damon/dbgfs: Optimize target_ids interface write operation Xin Hao
2021-10-21 17:30 ` SeongJae Park [this message]
2021-10-22  2:43   ` Xin Hao
2021-10-22  9:43     ` 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=20211021173018.15994-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=sjpark@amazon.de \
    --cc=xhao@linux.alibaba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.