From: Andrew Morton <akpm@linux-foundation.org>
To: Hungyu Lin <dennylin0707@gmail.com>
Cc: arnd@arndb.de, tglx@kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] compat: Avoid double rounding in times()
Date: Tue, 20 Oct 2026 14:35:42 -0700 [thread overview]
Message-ID: <20261020143542.37b34a0f8f43ed3655647343@linux-foundation.org> (raw)
In-Reply-To: <20261020210157.52057-1-dennylin0707@gmail.com>
On Tue, 20 Oct 2026 21:01:57 +0000 Hungyu Lin <dennylin0707@gmail.com> wrote:
> do_sys_times() already converts CPU time to USER_HZ ticks. The compat
> path converts each value back to jiffies before converting it to
> COMPAT_USER_HZ. This round trip can lose precision even when the two
> userspace rates match.
>
> With HZ=250 and USER_HZ=COMPAT_USER_HZ=100, one user tick becomes two
> jiffies and then zero compat ticks. Every odd tick count loses one
> tick, so any of the four tms fields can underreport CPU time by an
> additional 10 ms.
>
> Return the value directly when the native and compat units match. Keep
> the existing conversion for differing rates.
The fix looks correct. The compat times() path unnecessarily converts
CPU time from USER_HZ ticks to jiffies and back, losing precision.
I had $LLM model the userspace-visible results for tick counts 0 through
10,000. With HZ=250 and USER_HZ=COMPAT_USER_HZ=100, 5,000 values
underreport CPU time by 10 ms. The patch eliminates these errors
without changing the differing-rate case.
Thanks.
next prev parent reply other threads:[~2026-10-20 21:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 21:01 Hungyu Lin
2026-10-20 21:35 ` Andrew Morton [this message]
2026-10-20 21:36 ` Arnd Bergmann
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=20261020143542.37b34a0f8f43ed3655647343@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=dennylin0707@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@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
all inboxes | Powered by JetHome®