From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Hao Jia <jiahao.kernel@gmail.com>,
Brian Geffon <bgeffon@google.com>,
minchan@kernel.org, axboe@kernel.dk, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
Hao Jia <jiahao1@lixiang.com>
Subject: Re: [PATCH] zram: fix idle age_sec underflow in idle_store()
Date: Fri, 28 Aug 2026 13:30:43 +0900 [thread overview]
Message-ID: <apEOgZEaDXntmbKn@google.com> (raw)
In-Reply-To: <apEK-yRTQR8VdT3e@google.com>
On (26/08/28 13:23), Sergey Senozhatsky wrote:
> Can we instead just reject such cases? It should be an error to
> request writeback of pages that are 2y old on a system that has
> uptime of 2d.
>
> Maybe something like this:
>
> + time64_t uptime;
>
> - if (IS_ENABLED(CONFIG_ZRAM_TRACK_ENTRY_ACTIME) &&
> - !kstrtouint(buf, 0, &age_sec))
> - cutoff = ktime_sub((u32)ktime_get_boottime_seconds(),
> - age_sec);
> - else
> + if (!IS_ENABLED(CONFIG_ZRAM_TRACK_ENTRY_ACTIME) ||
> + kstrtouint(buf, 0, &age_sec))
> return -EINVAL;
> +
> + /* No slot can be older than the system uptime */
> + uptime = ktime_get_boottime_seconds();
> + if (age_sec >= uptime)
> + return -ERANGE;
> +
> + cutoff = uptime - age_sec;
> }
>
> We are probably fine doing just basic arithmetics operations on those two.
> One is u32 the other one is s64: we should be fine just doing >= and sub.
> I guess we also can use plain comparison
> cutoff > zram->table[index].attr.ac_time
> in mark_idle(). Or am I hallucinating?
That implies that cutoff becomes time64_t both in idle_store() and in
mark_idle().
next prev parent reply other threads:[~2026-08-28 4:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 9:23 [PATCH] zram: fix idle age_sec underflow in idle_store() Hao Jia
2026-08-28 3:26 ` Andrew Morton
2026-08-28 4:23 ` Sergey Senozhatsky
2026-08-28 4:30 ` Sergey Senozhatsky [this message]
2026-08-28 6:02 ` Sergey Senozhatsky
2026-08-28 8:38 ` Hao Jia
2026-08-28 9:22 ` Sergey Senozhatsky
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=apEOgZEaDXntmbKn@google.com \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bgeffon@google.com \
--cc=jiahao.kernel@gmail.com \
--cc=jiahao1@lixiang.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@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