mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SJ Park <sj@kernel.org>
To: "Adrian Huang (Lenovo)" <adrianhuang0701@gmail.com>
Cc: SJ Park <sj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	damon@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, ahuang12@lenovo.com
Subject: Re: [PATCH 1/1] mm/damon/core: simplify minimum watermark wait time calculation
Date: Tue, 10 Nov 2026 07:39:06 -0800	[thread overview]
Message-ID: <20261110153907.158338-1-sj@kernel.org> (raw)
In-Reply-To: <20261110085132.1023-1-adrianhuang0701@gmail.com>

Hello Adrian,

On Tue, 10 Nov 2026 16:51:32 +0800 "Adrian Huang (Lenovo)" <adrianhuang0701@gmail.com> wrote:

> The minimum watermark wait time calculation uses an additional boolean
> variable, init_wait_time, to determine whether min_wait_time has been
> initialized.
> 
> Simplify the logic by using list_is_first() to identify the first
> scheme and initialize min_wait_time accordingly. Subsequent schemes
> update min_wait_time only when their waiting intervals are shorter.
> 
> This removes the unnecessary boolean variable while preserving the
> existing behavior, including the case where no schemes are configured.
> 
> Signed-off-by: Adrian Huang (Lenovo) <adrianhuang0701@gmail.com>
> ---
>  mm/damon/core.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index d36823f4d092..93ec684a113c 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -3985,14 +3985,12 @@ static int kdamond_wait_activation(struct damon_ctx *ctx)
>  
>  	while (!kdamond_need_stop(ctx)) {
>  		unsigned long min_wait_time = 0;
> -		bool init_wait_time = false;
>  
>  		damon_for_each_scheme(s, ctx) {
>  			wait_time = damos_wmark_wait_us(s);
> -			if (!init_wait_time || wait_time < min_wait_time) {
> -				init_wait_time = true;
> +			if (list_is_first(&s->list, &ctx->schemes) ||
> +			    wait_time < min_wait_time)
>  				min_wait_time = wait_time;
> -			}

I implemented and used list handling wrappers like damon_for_each_scheme(), to
hide implementation details of data structures.  This change exposes some of
such details.  If we agree we have to remove init_wait_time, I'd prefer adding
a sort of damon_first_scheme() like wrapper.

But, init_wait_time really need to be removed?  I cannot show clear benefit of
removing it that justifies adding a new wrapper.  To someone or on some
evironments, init_wait_time might making the code too difficult to read or
inefficient (system having so small amount of memory?), though.  If not, I'd
suggest dropping this.

What do you think, Adrian?


Thanks,
SJ

[...]

      reply	other threads:[~2026-11-10 15:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10  8:51 Adrian Huang (Lenovo)
2026-11-10 15:39 ` SJ Park [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=20261110153907.158338-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=adrianhuang0701@gmail.com \
    --cc=ahuang12@lenovo.com \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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

all inboxes | Powered by JetHome®