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 1/3] zram: use u32 for entry ac_time tracking
Date: Wed, 14 Jan 2026 04:45:07 -0800 [thread overview]
Message-ID: <20260114124522.1326519-1-clm@meta.com> (raw)
In-Reply-To: <d7c0b48450c70eeb5fd8acd6ecd23593f30dbf1f.1765775954.git.senozhatsky@chromium.org>
On Mon, 15 Dec 2025 14:47:11 +0900 Sergey Senozhatsky <senozhatsky@chromium.org> wrote:
> We can reduce sizeof(zram_table_entry) on 64-bit systems
> by converting flags and ac_time to u32. Entry flags fit
> into u32, and for ac_time u32 gives us over a century of
> entry lifespan (approx 136 years) which is plenty (zram
> uses system boot time (seconds)).
>
> In struct zram_table_entry we use bytes aliasing, because
> bit-wait API (for slot lock) requires a whole unsigned
> long word.
Hi everyone,
I ran mm-new through the AI patch review prompts, and this one was flagged:
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
[ ... ]
> @@ -222,7 +221,7 @@ 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].ac_time = ktime_get_boottime();
> + zram->table[index].attr.ac_time = (u32)ktime_get_boottime_seconds();
> #endif
> }
This stores seconds in ac_time.
[ ... ]
> @@ -1588,7 +1588,7 @@ static ssize_t read_block_state(struct file *file, char __user *buf,
> if (!zram_allocated(zram, index))
> goto next;
>
> - ts = ktime_to_timespec64(zram->table[index].ac_time);
> + ts = ktime_to_timespec64(zram->table[index].attr.ac_time);
> copied = snprintf(kbuf + written, count,
> "%12zd %12lld.%06lu %c%c%c%c%c%c\n",
> index, (s64)ts.tv_sec,
> ts.tv_nsec / NSEC_PER_USEC,
ktime_to_timespec64() is defined as ns_to_timespec64(), which expects
nanoseconds. Since ac_time now stores seconds, will this produce
incorrect output?
For example, if ac_time is 3600 (representing 1 hour of uptime),
ns_to_timespec64(3600) would compute ts.tv_sec = 3600 / 1000000000 = 0
and ts.tv_nsec = 3600, resulting in "0.000003" instead of "3600.000000".
prev parent reply other threads:[~2026-01-14 12:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 5:47 Sergey Senozhatsky
2025-12-15 5:47 ` [PATCH 2/3] zram: rename internal slot API Sergey Senozhatsky
2026-01-14 12:36 ` Chris Mason
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 [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=20260114124522.1326519-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