linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Bijan Tabatabai <bijan311@gmail.com>
Cc: SeongJae Park <sj@kernel.org>,
	damon@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Bijan Tabatabai <bijantabatab@micron.com>
Subject: Re: [PATCH] mm/damon/core: skip needless update of next_{aggregation,ops_update}_sis
Date: Wed,  6 Aug 2025 14:42:37 -0700	[thread overview]
Message-ID: <20250806214237.51484-1-sj@kernel.org> (raw)
In-Reply-To: <CAMvvPS7Anh4qZu-VewZ61_QqfU9PDCaUpGjxZWeCdioTWkr5vA@mail.gmail.com>

On Wed, 6 Aug 2025 14:49:21 -0500 Bijan Tabatabai <bijan311@gmail.com> wrote:

> On Wed, Aug 6, 2025 at 2:09 PM SeongJae Park <sj@kernel.org> wrote:
> >
> > Hi Bijan,
> >
> > On Wed,  6 Aug 2025 11:43:16 -0500 Bijan Tabatabai <bijan311@gmail.com> wrote:
> >
> > > From: Bijan Tabatabai <bijantabatab@micron.com>
> > >
> > > In damon_set_attrs(), ctx->next_{aggregation,ops_update}_sis would be
> > > reset, even if the sample interval, aggregation interval, or ops update
> > > interval were not changed. If damon_set_attrs() is called relatively
> > > frequently, such as by frequent "commit" operations, aggregation and ops
> > > update operations could be needlessly delayed.
> > >
> > > This patch avoids this by only updating next_{aggregation,ops_update}_sis
> > > if the relevant intervals were changed.
[...]
> > What about modifying damon_commit_ctx() to check if new and old
> > damon_ctx->attrs are entirely same, and skip calling damon_set_attrs() in the
> > case?  Doing the entire damon_attrs comparison might be suboptimum, but would
> > make the change simpler.  I assume the suboptimum comparison is not a real
> > problem for your use case, so I think that could be a good tradeoff?
> 
> I can definitely do this. Checking a few extra fields is no big deal.
> 
> Silly question, but think it's best to get it out of the way before
> sending another patch: do you think there's a more elegant way of just
> having a dumb comparison function like
> 
> bool damon_attrs_equal(struct damon_attrs *a, struct damon_attrs *b)
> {
>         return a->sample_interval == b->sample_interval &&
>             a->aggr_interval == b->aggr_interval &&
>             ...
> }
> 
> And I assume I shouldn't compare the aggr_samples field because it's
> private, is that right?

Ah, you're right, thank you for asking this!

Maybe we can copy src->attrs to a local damon_attrs variable, overwrite
aggr_samples of the copy and dst, and memcmp() the copy and dst?

I wouldn't mind the dumb comparison function, though, if you prefer.  I'll
defer the decision to you!


Thanks,
SJ

[...]


      reply	other threads:[~2025-08-06 21:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06 16:43 Bijan Tabatabai
2025-08-06 19:09 ` SeongJae Park
2025-08-06 19:49   ` Bijan Tabatabai
2025-08-06 21:42     ` SeongJae 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=20250806214237.51484-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bijan311@gmail.com \
    --cc=bijantabatab@micron.com \
    --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