linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Chris Mason <clm@meta.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
	 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: Thu, 15 Jan 2026 12:13:46 +0900	[thread overview]
Message-ID: <5dm7qshgxenr6urnd4mdis75r6zpk2rlzcey4svjsp6m4jvnqw@iq4myzyiwm6u> (raw)
In-Reply-To: <20260114124522.1326519-1-clm@meta.com>

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



      reply	other threads:[~2026-01-15  3:13 UTC|newest]

Thread overview: 10+ 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
2026-01-15  3:01     ` Sergey Senozhatsky
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
2026-01-15  3:13   ` Sergey Senozhatsky [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=5dm7qshgxenr6urnd4mdis75r6zpk2rlzcey4svjsp6m4jvnqw@iq4myzyiwm6u \
    --to=senozhatsky@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=bgeffon@google.com \
    --cc=clm@meta.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.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