mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/8] hrtimer: Remove hrtimer_clock_base::get_time
@ 2025-08-12  6:08 Thomas Weißschuh
  2025-08-12  6:08 ` [PATCH 1/8] posix-timers: Avoid direct access to hrtimer clockbase Thomas Weißschuh
                   ` (8 more replies)
  0 siblings, 9 replies; 23+ messages in thread
From: Thomas Weißschuh @ 2025-08-12  6:08 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, Matt Wu, Andrew Morton, Jaroslav Kysela,
	Takashi Iwai, Sean Young, Mauro Carvalho Chehab, Jan Kiszka,
	Kieran Bingham
  Cc: linux-kernel, linux-sound, linux-media, Thomas Weißschuh

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>
---
Thomas Weißschuh (8):
      posix-timers: Avoid direct access to hrtimer clockbase
      timers/itimer: Avoid direct access to hrtimer clockbase
      sched/core: Avoid direct access to hrtimer clockbase
      lib: test_objpool: Avoid direct access to hrtimer clockbase
      ALSA: hrtimer: Avoid direct access to hrtimer clockbase
      media: pwm-ir-tx: Avoid direct access to hrtimer clockbase
      hrtimer: Use hrtimer_cb_get_time() helper
      hrtimer: Remove hrtimer_clock_base::get_time

 drivers/media/rc/pwm-ir-tx.c   |  5 +----
 include/linux/hrtimer.h        | 14 +++++---------
 include/linux/hrtimer_defs.h   |  2 --
 kernel/sched/core.c            |  2 +-
 kernel/time/hrtimer.c          | 34 +++++++++++++++++++++++++---------
 kernel/time/itimer.c           |  3 +--
 kernel/time/posix-timers.c     |  5 ++---
 kernel/time/timer_list.c       |  2 --
 lib/test_objpool.c             |  2 +-
 scripts/gdb/linux/timerlist.py |  2 --
 sound/core/hrtimer.c           |  2 +-
 11 files changed, 37 insertions(+), 36 deletions(-)
---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250728-hrtimer-cleanup-get_time-8ac9d797a685

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh@linutronix.de>


^ permalink raw reply	[flat|nested] 23+ messages in thread
* [PATCH v2 7/9] hrtimer: Use hrtimer_cb_get_time() helper
@ 2025-08-21 13:28 Thomas Weißschuh
  2025-09-09 10:31 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh
  0 siblings, 1 reply; 23+ messages in thread
From: Thomas Weißschuh @ 2025-08-21 13:28 UTC (permalink / raw)
  To: Anna-Maria Behnsen, Frederic Weisbecker, Thomas Gleixner,
	Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, Matt Wu, Andrew Morton, Jaroslav Kysela,
	Takashi Iwai, Sean Young, Mauro Carvalho Chehab, Jan Kiszka,
	Kieran Bingham
  Cc: linux-kernel, linux-sound, linux-media, Thomas Weißschuh

Various other helpers contain open-coded implementations of
hrtimer_cb_get_time(). This prevents refactoring the implementation.

Reuse the existing helper.

For this to work, move hrtimer_cb_get_time() a bit up in the file and also
make its argument 'const'.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 include/linux/hrtimer.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 1ef867bb8c44b06812d8552441d4092922bfe170..e655502b14e6c4b1a69b67c997132d628bd1470f 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -154,14 +154,14 @@ static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
 	return ktime_to_ns(timer->node.expires);
 }
 
-static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
+static inline ktime_t hrtimer_cb_get_time(const struct hrtimer *timer)
 {
-	return ktime_sub(timer->node.expires, timer->base->get_time());
+	return timer->base->get_time();
 }
 
-static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer)
+static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
 {
-	return timer->base->get_time();
+	return ktime_sub(timer->node.expires, hrtimer_cb_get_time(timer));
 }
 
 static inline int hrtimer_is_hres_active(struct hrtimer *timer)
@@ -200,8 +200,7 @@ __hrtimer_expires_remaining_adjusted(const struct hrtimer *timer, ktime_t now)
 static inline ktime_t
 hrtimer_expires_remaining_adjusted(const struct hrtimer *timer)
 {
-	return __hrtimer_expires_remaining_adjusted(timer,
-						    timer->base->get_time());
+	return __hrtimer_expires_remaining_adjusted(timer, hrtimer_cb_get_time(timer));
 }
 
 #ifdef CONFIG_TIMERFD
@@ -363,7 +362,7 @@ hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval);
 static inline u64 hrtimer_forward_now(struct hrtimer *timer,
 				      ktime_t interval)
 {
-	return hrtimer_forward(timer, timer->base->get_time(), interval);
+	return hrtimer_forward(timer, hrtimer_cb_get_time(timer), interval);
 }
 
 /* Precise sleep: */

-- 
2.50.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2025-09-09 10:31 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-12  6:08 [PATCH 0/8] hrtimer: Remove hrtimer_clock_base::get_time 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: timers/core] " tip-bot2 for Thomas Weißschuh
2025-08-12  7:43 ` [PATCH 0/8] " Peter Zijlstra
2025-08-21 13:28 [PATCH v2 7/9] hrtimer: Use hrtimer_cb_get_time() helper Thomas Weißschuh
2025-09-09 10:31 ` [tip: timers/core] " tip-bot2 for Thomas Weißschuh

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®