[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250915205224.aa2de8de6dad1bb4c048cec8@linux-foundation.org>
Date: Mon, 15 Sep 2025 20:52:24 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: SeongJae Park <sj@...nel.org>
Cc: Joshua Hahn <joshua.hahnjy@...il.com>, damon@...ts.linux.dev,
kernel-team@...a.com, linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH 1/6] mm/damon/core: reset age if nr_accesses changes
between non-zero and zero
On Mon, 15 Sep 2025 11:26:51 -0700 SeongJae Park <sj@...nel.org> wrote:
> > Thank you for the patch, I think the goal of the patch makes sesne to me.
> > I have a small nit / idea which I think makes the code a bit clearer, at least
> > for me. It seems that we basically want to XOR the two values's zero-ness, so
> > maybe something like
> >
> > (!!r->nr_accesses) ^ (!!r->last_nr_access) or
> > (r->nr_accesses == 0) ^ (r->last_nr_access == 0)
> >
> > Can achieve the goal?
>
> Thank you for the idea, this makes sense!
>
> > I know bitwise operations are sometimes harder to
> > understand, so I am just throwing the idea out there : -)
>
> To be honest I'm one of people who are not familiar with XOR. I had to spend a
> minute to understand the above. Maybe we can replace '^' with '!=', and it is
> easier to read for me. If you don't mind, I will use below in the next
> version:
>
> else if ((r->nr_accesses == 0) != (r->last_nr_accesses == 0))
>
> Please let me know if I'm missing something or you have other opinions.
I have to say, using xor as a shorthand for what-was-really-intended
always bursts my brain. I have to stop, think about it and mentally
turn the implementation back into what-was-really-intended. Maybe
that's just me.
Ditto less-than-utterly-trivial :? expressions. Perhaps it's because
if-then-else best suits how our minds work.
Powered by blists - more mailing lists