From: Chris Mason <clm@meta.com>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Chris Mason <clm@meta.com>,
Andrew Morton <akpm@linux-foundation.org>,
Minchan Kim <minchan@kernel.org>,
Brian Geffon <bgeffon@google.com>,
"David Stevens" <stevensd@google.com>,
<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
<linux-block@vger.kernel.org>
Subject: Re: [PATCH 2/3] zram: rename internal slot API
Date: Wed, 14 Jan 2026 04:36:54 -0800 [thread overview]
Message-ID: <20260114123658.1231407-1-clm@meta.com> (raw)
In-Reply-To: <775a0b1a0ace5caf1f05965d8bc637c1192820fa.1765775954.git.senozhatsky@chromium.org>
On Mon, 15 Dec 2025 14:47:12 +0900 Sergey Senozhatsky <senozhatsky@chromium.org> wrote:
> We have a somewhat confusing internal API naming. E.g.
> the following code:
>
> zram_slot_lock()
> if (zram_allocated())
> zram_set_flag()
> zram_slot_unlock()
>
> may look like it does something on zram device level, but in
> fact it tests and sets slot entry flags, not the device ones.
>
> Rename API to explicitly distinguish functions that operate on
> the slot level from functions that operate on the zram device
> level.
>
> While at it, fixup some coding styles.
Hi everyone,
I ran mm-new through the AI patch review prompts and this one was flagged.
It uses a lot of words here to suggest a copy/paste error, but it does look
right to me:
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 65f99ff3e2e54..f00f3d22d5e32 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
[ ... ]
> +static void mark_slot_accessed(struct zram *zram, u32 index)
> +{
> + clear_slot_flag(zram, index, ZRAM_IDLE);
> + clear_slot_flag(zram, index, ZRAM_PP_SLOT);
> +#ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME
> + zram->table[index].attr.ac_time = ktime_get_boottime();
^^^^^^^^^^^^^^^^^^^^
The previous commit (472f3f208d78e "zram: use u32 for entry ac_time
tracking") changed this from ktime_get_boottime() to
(u32)ktime_get_boottime_seconds() because ac_time was changed from
ktime_t to u32.
This patch appears to revert that change, storing the result of
ktime_get_boottime() (which returns a 64-bit nanosecond value) into
the u32 ac_time field. This truncates to the lower 32 bits, which
wraps every ~4.29 seconds.
The result is that mark_idle() will compare ktime_after(cutoff, ac_time)
using a truncated nanosecond value, causing pages to be incorrectly
marked as IDLE almost immediately after being accessed.
Was this change intentional, or was it accidentally reverted during
the rename refactoring?
> +#endif
> +}
[ ... ]
> -static void zram_accessed(struct zram *zram, u32 index)
> -{
> - zram_clear_flag(zram, index, ZRAM_IDLE);
> - zram_clear_flag(zram, index, ZRAM_PP_SLOT);
> -#ifdef CONFIG_ZRAM_TRACK_ENTRY_ACTIME
> - zram->table[index].attr.ac_time = (u32)ktime_get_boottime_seconds();
> -#endif
> -}
This is the original code that was correctly using
ktime_get_boottime_seconds() with the u32 cast. The new
mark_slot_accessed() function above should preserve this behavior.
next prev parent reply other threads:[~2026-01-14 12:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 5:47 [PATCH 1/3] zram: use u32 for entry ac_time tracking Sergey Senozhatsky
2025-12-15 5:47 ` [PATCH 2/3] zram: rename internal slot API Sergey Senozhatsky
2026-01-14 12:36 ` Chris Mason [this message]
2025-12-15 5:47 ` [PATCH 3/3] zram: trivial fix of recompress_slot() coding styles Sergey Senozhatsky
2025-12-15 22:31 ` [PATCH 1/3] zram: use u32 for entry ac_time tracking Brian Geffon
2025-12-16 0:59 ` Sergey Senozhatsky
2025-12-16 1:17 ` Brian Geffon
2026-01-14 12:45 ` Chris Mason
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=20260114123658.1231407-1-clm@meta.com \
--to=clm@meta.com \
--cc=akpm@linux-foundation.org \
--cc=bgeffon@google.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=senozhatsky@chromium.org \
--cc=stevensd@google.com \
/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