From: Andrew Morton <akpm@linux-foundation.org>
To: SeongJae Park <sj@kernel.org>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>,
damon@lists.linux.dev, kernel-team@meta.com,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 1/6] mm/damon/core: reset age if nr_accesses changes between non-zero and zero
Date: Mon, 15 Sep 2025 20:52:24 -0700 [thread overview]
Message-ID: <20250915205224.aa2de8de6dad1bb4c048cec8@linux-foundation.org> (raw)
In-Reply-To: <20250915182652.110173-1-sj@kernel.org>
On Mon, 15 Sep 2025 11:26:51 -0700 SeongJae Park <sj@kernel.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.
next prev parent reply other threads:[~2025-09-16 3:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-15 1:58 [PATCH 0/6] mm/damon: misc fixups and improvements for 6.18 SeongJae Park
2025-09-15 1:58 ` [PATCH 1/6] mm/damon/core: reset age if nr_accesses changes between non-zero and zero SeongJae Park
2025-09-15 14:51 ` Joshua Hahn
2025-09-15 18:26 ` SeongJae Park
2025-09-16 3:52 ` Andrew Morton [this message]
2025-09-15 1:58 ` [PATCH 2/6] mm/damon/core: set effective quota on first charge window SeongJae Park
2025-09-15 1:58 ` [PATCH 3/6] mm/damon/lru_sort: use param_ctx correctly SeongJae Park
2025-09-15 15:05 ` Joshua Hahn
2025-09-15 18:43 ` SeongJae Park
2025-09-16 3:04 ` SeongJae Park
2025-09-15 1:58 ` [PATCH 4/6] Docs/mm/damon/maintainer-profile: update community meetup for reservation requirements SeongJae Park
2025-09-15 15:07 ` Joshua Hahn
2025-09-15 18:44 ` SeongJae Park
2025-09-15 1:58 ` [PATCH 5/6] Docs/admin-guide/mm/damon/start: add --target_pid to DAMOS example command SeongJae Park
2025-09-15 15:08 ` [PATCH 0/6] mm/damon: misc fixups and improvements for 6.18 Joshua Hahn
2025-09-15 15:25 ` Joanne Koong
2025-09-15 15:28 ` Joshua Hahn
2025-09-15 18:06 ` 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=20250915205224.aa2de8de6dad1bb4c048cec8@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=joshua.hahnjy@gmail.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sj@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