linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sang-Heon Jeon <ekffu200098@gmail.com>
To: SeongJae Park <sj@kernel.org>
Cc: honggyu.kim@sk.com, damon@lists.linux.dev, linux-mm@kvack.org,
	 stable@vger.kernel.org
Subject: Re: [PATCH v2] mm/damon/core: set quota->charged_from to jiffies at first charge window
Date: Thu, 21 Aug 2025 10:08:03 +0900	[thread overview]
Message-ID: <CABFDxMGmVgswVoZFgBz=7xqA59M7fMt0jw2QHqWjm-W9tZktWg@mail.gmail.com> (raw)
In-Reply-To: <20250820182736.84941-1-sj@kernel.org>

On Thu, Aug 21, 2025 at 3:27 AM SeongJae Park <sj@kernel.org> wrote:
>
> On Wed, 20 Aug 2025 22:18:53 +0900 Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
>
> > Hello, SeongJae
> >
> > On Wed, Aug 20, 2025 at 2:27 AM SeongJae Park <sj@kernel.org> wrote:
> > >
> > > On Wed, 20 Aug 2025 00:01:23 +0900 Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
> > >
> > > > Kernel initialize "jiffies" timer as 5 minutes below zero, as shown in
> > > > include/linux/jiffies.h
> > > >
> > > > /*
> > > >  * Have the 32 bit jiffies value wrap 5 minutes after boot
> > > >  * so jiffies wrap bugs show up earlier.
> > > >  */
> > > >  #define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
> > > >
> > > > And they cast unsigned value to signed to cover wraparound
> > >
> > > "they" sounds bit vague.  I think "jiffies comparison helper functions" would
> > > be better.
> >
> > I agree, I will change it.
> >
> > > >
> > > >  #define time_after_eq(a,b) \
> > > >   (typecheck(unsigned long, a) && \
> > > >   typecheck(unsigned long, b) && \
> > > >   ((long)((a) - (b)) >= 0))
> > > >
> > > > In 64bit system, these might not be a problem because wrapround occurs
> > > > 300 million years after the boot, assuming HZ value is 1000.
> > > >
> > > > With same assuming, In 32bit system, wraparound occurs 5 minutues after
> > > > the initial boot and every 49 days after the first wraparound. And about
> > > > 25 days after first wraparound, it continues quota charging window up to
> > > > next 25 days.
> > >
> > > It would be nice if you can further explain what real user impacts that could
> > > make.  To my understanding the impact is that, when the unexpected extension of
> > > the charging window is happened, the scheme will work until the quota is full,
> > > but then stops working until the unexpectedly extended window is over.
> > >
> > > The after-boot issue is really bad since there is no way to work around other
> > > than reboot the machine.
> >
> > I agree with your point that user impact should be added to commit
> > messages. Before modifying the commit message, I want to check that my
> > understanding of "user impact" is correct.
>
> I think you should make clear at least you believe you understand the
> consequences of your patches including user impacts before sending your patches
> without RFC tag.  I'd suggest you to take more time on making such
> preparational confidences and/or discussions _before_ sending non-RFC patches.
> You're nver lagging.  Take your time.

I think that I checked about user impact already but it should be
insufficient. As you said, I should discuss it first. Anyway, the
whole thing is my mistake. I'm really so sorry.

So, Would it be better to send an RFC patch even now, instead of
asking on this email thread? (I'll make next v3 patch with RFC tag,
it's not question of v3 direction and just about remained question on
this email thread)

> >
> > In the logic before this patch is applied, I think
> > time_after_eq(jiffies, ...) should only evaluate to false when the MSB
> > of jiffies is 1 and charged_from is 0. because if charging has
> > occurred, it changes charge_from to jiffies at that time.
>
> It is not the only case that time_after_eq() can be evaluated to false.  Maybe
> you're saying only about the just-after-boot running case?  If so, please
> clarify.  You and I know the context, but others may not.  I hope the commit
> message be nicer for them.

I think it is not just-after-boot running case also whole and only
case, because charging changes charged_from to jiffies. if it is not
the only case, could you please describe the specific case?

> > Therefore,
> > esz should also be zero because it is initialized with charged_from.
> > So I think the real user impact is that "quota is not applied", rather
> > than "stops working". If my understanding is wrong, please let me know
> > what point is wrong.
>
> Thank you for clarifying your view.  The code is behaving in the way you
> described above.  It is because damon_set_effective_quota(), which sets the
> esz, is called only when the time_after_eq() call returns true.
>
> However, this is a bug rather than an intended behavior.  The current behavior
> is making the first charging window just be wasted without doing nothing.
>
> Probably the bug was introduced by the commit that introduced esz.

Thanks for your explanation. I'll try to cover this point in the next
patch as well.

> >
> > > >
> > > > Example 1: initial boot
> > > > jiffies=0xFFFB6C20, charged_from+interval=0x000003E8
> > > > time_after_eq(jiffies, charged_from+interval)=(long)0xFFFB6838; In
> > > > signed values, it is considered negative so it is false.
> > >
> > > The above part is using hex numbers and look like psuedo-code.  This is
> > > unnecessarily difficult to read.  To me, this feels like your personal note
> > > rather than a nice commit message that written for others.  I think you could
> > > write this in a much better way.
> > >
> > > >
> > > > Example 2: after about 25 days first wraparound
> > > > jiffies=0x800004E8, charged_from+interval=0x000003E8
> > > > time_after_eq(jiffies, charged_from+interval)=(long)0x80000100; In
> > > > signed values, it is considered negative so it is false
> > >
> > > Ditto.
> >
> > Okay, I think I can fix these sections with explanation using MSB.
>
> Also please make it easier to read for more human people.

I see.

> >
> > > >
> > > > So, change quota->charged_from to jiffies at damos_adjust_quota() when
> > > > it is consider first charge window.
> > > >
> > > > In theory; but almost impossible; quota->total_charged_sz and
> > > > qutoa->charged_from should be both zero even if it is not in first
> > >
> > > s/should/could/ ?
> >
> > Sorry for my poor english.
> >
> > > Also, explaining when that "could" happen will be nice.
> >
> > I want to confirm this situation as well. I think the situation below
> > is the only case.
>
> Again, if there is anything unclear, let's do discussions before sending
> non-RFC patches.
>
> >
> > 1. jiffies overflows to exactly 0
> > 2. And quota is configured but never actually applied, so total_charged_sz is 0
>
> Or, total_charged_sz is also overflows and bcome 0.

Thanks for clarifying me.

> > 3. And charging occurs at that exact moment.
>
> It's not necessarily when charging occurs but when damon_adjust_quota() is
> called.  More technically speaking once per the scheme's apply interval.

Ditto.

> >
> > Is that right? If right, I think this situation is almost impossible
> > and uncommon. I feel like It's unnecessary to describe it. I'm not
> > trying to ignore your valuable opinion, but do you still think it's
> > better to add a description?
>
> I'm ok to completely drop the explanation.  But if you are gonna mention it
> partially, please clarify.

I see, your opinion is reasonable. I'll keep that in my mind.

> >
> > > > charge window. But It will only delay one reset_interval, So it is not
> > > > big problem.
> > > >
> > > > Fixes: 2b8a248d5873 ("mm/damon/schemes: implement size quota for schemes application speed control") # 5.16
> > > > Cc: stable@vger.kernel.org
> > > > Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
> > >
> > > I think the commit message could be much be improved, but the code change seems
> > > right.
> >
> > Once again, Sorry for my poor english. I'm doing my best on my own.
>
> This is not about English skill but the commit "message".  Your English skill
> is good and probably betetr than mine.  But I ad a difficult time at reviewing
> your patch, and feeling it could been easier if the message was nicer.
>
> So what I'm saying is that I tink this patch's commit message can be more nice
> to readers.

You're right. I'll try to make the commit message more clear. I'm
really sorry for bothering you.

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

Best Regards
Sang-Heon Jeon


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

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-19 15:01 Sang-Heon Jeon
2025-08-19 17:27 ` SeongJae Park
2025-08-19 18:03   ` SeongJae Park
2025-08-20 13:18   ` Sang-Heon Jeon
2025-08-20 18:27     ` SeongJae Park
2025-08-21  1:08       ` Sang-Heon Jeon [this message]
2025-08-21  2:54         ` SeongJae Park
2025-08-21  4:29           ` Sang-Heon Jeon
2025-08-21  4:43             ` Sang-Heon Jeon
2025-08-21  5:41             ` SeongJae Park
2025-08-21  5:43               ` SeongJae Park
2025-08-21 11:06               ` Sang-Heon Jeon
2025-08-21 15:58                 ` SeongJae Park
2025-08-21 16:18                   ` Sang-Heon Jeon

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='CABFDxMGmVgswVoZFgBz=7xqA59M7fMt0jw2QHqWjm-W9tZktWg@mail.gmail.com' \
    --to=ekffu200098@gmail.com \
    --cc=damon@lists.linux.dev \
    --cc=honggyu.kim@sk.com \
    --cc=linux-mm@kvack.org \
    --cc=sj@kernel.org \
    --cc=stable@vger.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