From: "tip-bot2 for Thomas Weißschuh" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: thomas.weissschuh@linutronix.de,
Thomas Gleixner <tglx@linutronix.de>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] hrtimer: Remove hrtimer_clock_base::get_time
Date: Tue, 09 Sep 2025 08:56:35 -0000 [thread overview]
Message-ID: <175740819618.1920.2252980357348613724.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20250812-hrtimer-cleanup-get_time-v1-8-b962cd9d9385@linutronix.de>
The following commit has been merged into the timers/core branch of tip:
Commit-ID: c37fc72e2662a01662cc9f7bbcbb91fd387f4b4b
Gitweb: https://git.kernel.org/tip/c37fc72e2662a01662cc9f7bbcbb91fd387f4b4b
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
AuthorDate: Tue, 12 Aug 2025 08:08:16 +02:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Tue, 09 Sep 2025 10:53:30 +02:00
hrtimer: Remove hrtimer_clock_base::get_time
The get_time() callbacks always need to match the bases clockid.
Instead of maintaining that association twice in hrtimer_bases,
use a helper.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250812-hrtimer-cleanup-get_time-v1-8-b962cd9d9385@linutronix.de
---
include/linux/hrtimer.h | 5 +----
include/linux/hrtimer_defs.h | 2 +--
kernel/time/hrtimer.c | 34 ++++++++++++++++++++++++---------
kernel/time/timer_list.c | 2 +--
scripts/gdb/linux/timerlist.py | 2 +--
5 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index e655502..2cf1bf6 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -154,10 +154,7 @@ static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
return ktime_to_ns(timer->node.expires);
}
-static inline ktime_t hrtimer_cb_get_time(const struct hrtimer *timer)
-{
- return timer->base->get_time();
-}
+ktime_t hrtimer_cb_get_time(const struct hrtimer *timer);
static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
{
diff --git a/include/linux/hrtimer_defs.h b/include/linux/hrtimer_defs.h
index 84a5045..aa49ffa 100644
--- a/include/linux/hrtimer_defs.h
+++ b/include/linux/hrtimer_defs.h
@@ -41,7 +41,6 @@
* @seq: seqcount around __run_hrtimer
* @running: pointer to the currently running hrtimer
* @active: red black tree root node for the active timers
- * @get_time: function to retrieve the current time of the clock
* @offset: offset of this clock to the monotonic base
*/
struct hrtimer_clock_base {
@@ -51,7 +50,6 @@ struct hrtimer_clock_base {
seqcount_raw_spinlock_t seq;
struct hrtimer *running;
struct timerqueue_head active;
- ktime_t (*get_time)(void);
ktime_t offset;
} __hrtimer_clock_base_align;
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 30899a8..4ce754a 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -59,6 +59,7 @@
#define HRTIMER_ACTIVE_ALL (HRTIMER_ACTIVE_SOFT | HRTIMER_ACTIVE_HARD)
static void retrigger_next_event(void *arg);
+static ktime_t __hrtimer_cb_get_time(clockid_t clock_id);
/*
* The timer bases:
@@ -76,42 +77,34 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
{
.index = HRTIMER_BASE_MONOTONIC,
.clockid = CLOCK_MONOTONIC,
- .get_time = &ktime_get,
},
{
.index = HRTIMER_BASE_REALTIME,
.clockid = CLOCK_REALTIME,
- .get_time = &ktime_get_real,
},
{
.index = HRTIMER_BASE_BOOTTIME,
.clockid = CLOCK_BOOTTIME,
- .get_time = &ktime_get_boottime,
},
{
.index = HRTIMER_BASE_TAI,
.clockid = CLOCK_TAI,
- .get_time = &ktime_get_clocktai,
},
{
.index = HRTIMER_BASE_MONOTONIC_SOFT,
.clockid = CLOCK_MONOTONIC,
- .get_time = &ktime_get,
},
{
.index = HRTIMER_BASE_REALTIME_SOFT,
.clockid = CLOCK_REALTIME,
- .get_time = &ktime_get_real,
},
{
.index = HRTIMER_BASE_BOOTTIME_SOFT,
.clockid = CLOCK_BOOTTIME,
- .get_time = &ktime_get_boottime,
},
{
.index = HRTIMER_BASE_TAI_SOFT,
.clockid = CLOCK_TAI,
- .get_time = &ktime_get_clocktai,
},
},
.csd = CSD_INIT(retrigger_next_event, NULL)
@@ -1253,7 +1246,7 @@ static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
remove_hrtimer(timer, base, true, force_local);
if (mode & HRTIMER_MODE_REL)
- tim = ktime_add_safe(tim, base->get_time());
+ tim = ktime_add_safe(tim, __hrtimer_cb_get_time(base->clockid));
tim = hrtimer_update_lowres(timer, tim, mode);
@@ -1588,6 +1581,29 @@ static inline int hrtimer_clockid_to_base(clockid_t clock_id)
}
}
+static ktime_t __hrtimer_cb_get_time(clockid_t clock_id)
+{
+ switch (clock_id) {
+ case CLOCK_REALTIME:
+ return ktime_get_real();
+ case CLOCK_MONOTONIC:
+ return ktime_get();
+ case CLOCK_BOOTTIME:
+ return ktime_get_boottime();
+ case CLOCK_TAI:
+ return ktime_get_clocktai();
+ default:
+ WARN(1, "Invalid clockid %d. Using MONOTONIC\n", clock_id);
+ return ktime_get();
+ }
+}
+
+ktime_t hrtimer_cb_get_time(const struct hrtimer *timer)
+{
+ return __hrtimer_cb_get_time(timer->base->clockid);
+}
+EXPORT_SYMBOL_GPL(hrtimer_cb_get_time);
+
static void __hrtimer_setup(struct hrtimer *timer,
enum hrtimer_restart (*function)(struct hrtimer *),
clockid_t clock_id, enum hrtimer_mode mode)
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index b03d0ad..488e47e 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -102,8 +102,6 @@ print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
SEQ_printf(m, " .index: %d\n", base->index);
SEQ_printf(m, " .resolution: %u nsecs\n", hrtimer_resolution);
-
- SEQ_printf(m, " .get_time: %ps\n", base->get_time);
#ifdef CONFIG_HIGH_RES_TIMERS
SEQ_printf(m, " .offset: %Lu nsecs\n",
(unsigned long long) ktime_to_ns(base->offset));
diff --git a/scripts/gdb/linux/timerlist.py b/scripts/gdb/linux/timerlist.py
index 9844567..ccc24d3 100644
--- a/scripts/gdb/linux/timerlist.py
+++ b/scripts/gdb/linux/timerlist.py
@@ -56,8 +56,6 @@ def print_base(base):
text += " .index: {}\n".format(base['index'])
text += " .resolution: {} nsecs\n".format(constants.LX_hrtimer_resolution)
-
- text += " .get_time: {}\n".format(base['get_time'])
if constants.LX_CONFIG_HIGH_RES_TIMERS:
text += " .offset: {} nsecs\n".format(base['offset'])
text += "active timers:\n"
next prev parent reply other threads:[~2025-09-09 8:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 6:08 [PATCH 0/8] " Thomas Weißschuh
2025-08-12 6:08 ` [PATCH 1/8] posix-timers: Avoid direct access to hrtimer clockbase Thomas Weißschuh
2025-09-09 8:56 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh
2025-08-12 6:08 ` [PATCH 2/8] timers/itimer: " Thomas Weißschuh
2025-09-09 8:56 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh
2025-08-12 6:08 ` [PATCH 3/8] sched/core: " Thomas Weißschuh
2025-09-09 8:56 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh
2025-08-12 6:08 ` [PATCH 4/8] lib: test_objpool: " Thomas Weißschuh
2025-09-09 8:56 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh
2025-08-12 6:08 ` [PATCH 5/8] ALSA: hrtimer: " Thomas Weißschuh
2025-08-12 11:07 ` Takashi Iwai
2025-09-09 8:56 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh
2025-08-12 6:08 ` [PATCH 6/8] media: pwm-ir-tx: " Thomas Weißschuh
2025-08-12 12:06 ` Sean Young
2025-09-09 8:56 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh
2025-08-12 6:08 ` [PATCH 7/8] hrtimer: Use hrtimer_cb_get_time() helper Thomas Weißschuh
2025-09-09 8:56 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh
2025-08-12 6:08 ` [PATCH 8/8] hrtimer: Remove hrtimer_clock_base::get_time Thomas Weißschuh
2025-08-12 7:42 ` Peter Zijlstra
2025-08-12 7:51 ` Thomas Weißschuh
2025-09-09 8:56 ` tip-bot2 for Thomas Weißschuh [this message]
2025-08-12 7:43 ` [PATCH 0/8] " Peter Zijlstra
2025-08-21 13:28 [PATCH v2 8/9] " Thomas Weißschuh
2025-09-09 10:31 ` [tip: timers/core] hrtimer: Remove hrtimer_clock_base:: Get_time tip-bot2 for Thomas Weißschuh
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=175740819618.1920.2252980357348613724.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=tglx@linutronix.de \
--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®