From: "tip-bot2 for Thomas Weißschuh (Schneider Electric)" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: thomas.weissschuh@linutronix.de,
Thomas Gleixner <tglx@kernel.org>,
Cassio Neri <cassio.neri@gmail.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] time: test: Avoid unnecessary divisions in time64_to_tm() test
Date: Mon, 30 Nov 2026 15:12:09 -0000 [thread overview]
Message-ID: <179605152937.1190409.12336921388218092124.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20261130-time-time64-to-tm-v3-2-f68748ad4118@linutronix.de>
The following commit has been merged into the timers/core branch of tip:
Commit-ID: ca365417bd492e605e21820730b63bc77dc8c7dc
Gitweb: https://git.kernel.org/tip/ca365417bd492e605e21820730b63bc77dc8c7dc
Author: Thomas Weißschuh (Schneider Electric) <thomas.weissschuh@linutronix.de>
AuthorDate: Mon, 30 Nov 2026 15:20:48 +01:00
Committer: Thomas Gleixner <tglx@kernel.org>
CommitterDate: Mon, 30 Nov 2026 16:08:42 +01:00
time: test: Avoid unnecessary divisions in time64_to_tm() test
The time64_to_tm_test_date_range() test case is slow.
One big part of this slowness is the division done in the test loop to
calculate the current day from the current seconds. As each test loop
advances the time by one day, that division can be avoided.
Remove the division and instead increment the 'days' variable directly.
This brings the test's runtime from 30 seconds down to 15 seconds in an
emulated 32-bit ARM machine.
Signed-off-by: Thomas Weißschuh (Schneider Electric) <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Cassio Neri <cassio.neri@gmail.com>
Link: https://patch.msgid.link/20261130-time-time64-to-tm-v3-2-f68748ad4118@linutronix.de
---
kernel/time/time_test.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/time/time_test.c b/kernel/time/time_test.c
index 8b71876..41e504a 100644
--- a/kernel/time/time_test.c
+++ b/kernel/time/time_test.c
@@ -69,12 +69,12 @@ static void time64_to_tm_test_date_range(struct kunit *test)
time64_t secs;
s64 days;
- for (secs = -total_secs; secs <= total_secs; secs += 86400) {
+ for (secs = -total_secs, days = div_s64(secs, 86400);
+ secs <= total_secs;
+ secs += 86400, days++) {
time64_to_tm(secs, 0, &result);
- days = div_s64(secs, 86400);
-
#define FAIL_MSG "%05ld/%02d/%02d (%2d) : %lld", \
year, month, mdday, yday, days
next prev parent reply other threads:[~2026-11-30 15:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 14:20 [PATCH v3 0/4] time: time64_to_tm() cleanups Thomas Weißschuh (Schneider Electric)
2026-11-30 14:20 ` [PATCH v3 1/4] time: Avoid 64-bit by 64-bit division in time64_to_tm() Thomas Weißschuh (Schneider Electric)
2026-11-30 15:12 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-11-30 14:20 ` [PATCH v3 2/4] time: test: Avoid unnecessary divisions in time64_to_tm() test Thomas Weißschuh (Schneider Electric)
2026-11-30 15:12 ` tip-bot2 for Thomas Weißschuh (Schneider Electric) [this message]
2026-11-30 14:20 ` [PATCH v3 3/4] rtc: lib: Implement rtc_time64_to_tm() in terms of time64_to_tm() Thomas Weißschuh (Schneider Electric)
2026-11-30 15:12 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
2026-11-30 20:22 ` [PATCH v3 3/4] " Alexandre Belloni
2026-11-30 14:20 ` [PATCH v3 4/4] rtc: test: Remove test_rtc_lib.c Thomas Weißschuh (Schneider Electric)
2026-11-30 15:12 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh (Schneider Electric)
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=179605152937.1190409.12336921388218092124.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=cassio.neri@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=x86@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®