[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5dm7qshgxenr6urnd4mdis75r6zpk2rlzcey4svjsp6m4jvnqw@iq4myzyiwm6u>
Date: Thu, 15 Jan 2026 12:13:46 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Chris Mason <clm@...a.com>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Andrew Morton <akpm@...ux-foundation.org>, Minchan Kim <minchan@...nel.org>,
Brian Geffon <bgeffon@...gle.com>, David Stevens <stevensd@...gle.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org, linux-block@...r.kernel.org
Subject: Re: [PATCH 1/3] zram: use u32 for entry ac_time tracking
On (26/01/14 04:45), Chris Mason wrote:
> > @@ -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".
Good catch.
I think it simply should be like this now (I don't think anyone uses
this function tho):
---
drivers/block/zram/zram_drv.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index cc51aa8b6181..912711faa4e4 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1579,11 +1579,9 @@ static ssize_t read_block_state(struct file *file, char __user *buf,
if (!slot_allocated(zram, index))
goto next;
- 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,
+ "%12zd %12u.%06lu %c%c%c%c%c%c\n",
+ index, zram->table[index].attr.ac_time, 0,
test_slot_flag(zram, index, ZRAM_SAME) ? 's' : '.',
test_slot_flag(zram, index, ZRAM_WB) ? 'w' : '.',
test_slot_flag(zram, index, ZRAM_HUGE) ? 'h' : '.',
--
2.52.0.457.g6b5491de43-goog
Powered by blists - more mailing lists