Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH] sched/clock: Provide !HAVE_UNSTABLE_SCHED_CLOCK stub for sched_clock_stable()
@ 2026-05-14 16:05 Yiyang Chen
  2026-05-14 19:36 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Yiyang Chen @ 2026-05-14 16:05 UTC (permalink / raw)
  To: peterz, rostedt
  Cc: mingo, vincent.guittot, mhiramat, mathieu.desnoyers, linux-kernel,
	linux-trace-kernel, Yiyang Chen

When CONFIG_HAVE_UNSTABLE_SCHED_CLOCK is disabled, sched_clock() is
already assumed to provide stable semantics, but the public header
doesn't provide a sched_clock_stable() stub for that case.

Add a header stub that always returns true and clean up the duplicate
local stub in ring_buffer.c, so callers can use sched_clock_stable()
unconditionally.

Signed-off-by: Yiyang Chen <cyyzero16@gmail.com>
---
 include/linux/sched/clock.h | 5 +++++
 kernel/trace/ring_buffer.c  | 7 -------
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/include/linux/sched/clock.h b/include/linux/sched/clock.h
index 196f0ca351a2..39f0a7f94bfc 100644
--- a/include/linux/sched/clock.h
+++ b/include/linux/sched/clock.h
@@ -33,6 +33,11 @@ extern u64 sched_clock_cpu(int cpu);
 extern void sched_clock_init(void);
 
 #ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
+static inline int sched_clock_stable(void)
+{
+	return 1;
+}
+
 static inline void sched_clock_tick(void)
 {
 }
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 5326924615a4..02691c3c6dd6 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -3769,13 +3769,6 @@ rb_add_time_stamp(struct ring_buffer_per_cpu *cpu_buffer,
 	return skip_time_extend(event);
 }
 
-#ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
-static inline bool sched_clock_stable(void)
-{
-	return true;
-}
-#endif
-
 static void
 rb_check_timestamp(struct ring_buffer_per_cpu *cpu_buffer,
 		   struct rb_event_info *info)
-- 
2.43.0


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

* Re: [PATCH] sched/clock: Provide !HAVE_UNSTABLE_SCHED_CLOCK stub for sched_clock_stable()
  2026-05-14 16:05 [PATCH] sched/clock: Provide !HAVE_UNSTABLE_SCHED_CLOCK stub for sched_clock_stable() Yiyang Chen
@ 2026-05-14 19:36 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2026-05-14 19:36 UTC (permalink / raw)
  To: Yiyang Chen
  Cc: peterz, mingo, vincent.guittot, mhiramat, mathieu.desnoyers,
	linux-kernel, linux-trace-kernel

On Fri, 15 May 2026 00:05:05 +0800
Yiyang Chen <cyyzero16@gmail.com> wrote:

> When CONFIG_HAVE_UNSTABLE_SCHED_CLOCK is disabled, sched_clock() is
> already assumed to provide stable semantics, but the public header
> doesn't provide a sched_clock_stable() stub for that case.
> 
> Add a header stub that always returns true and clean up the duplicate
> local stub in ring_buffer.c, so callers can use sched_clock_stable()
> unconditionally.
> 
> Signed-off-by: Yiyang Chen <cyyzero16@gmail.com>
> ---
>  include/linux/sched/clock.h | 5 +++++
>  kernel/trace/ring_buffer.c  | 7 -------
>  2 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/sched/clock.h b/include/linux/sched/clock.h
> index 196f0ca351a2..39f0a7f94bfc 100644
> --- a/include/linux/sched/clock.h
> +++ b/include/linux/sched/clock.h
> @@ -33,6 +33,11 @@ extern u64 sched_clock_cpu(int cpu);
>  extern void sched_clock_init(void);
>  
>  #ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
> +static inline int sched_clock_stable(void)
> +{
> +	return 1;
> +}
> +
>  static inline void sched_clock_tick(void)
>  {
>  }
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index 5326924615a4..02691c3c6dd6 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -3769,13 +3769,6 @@ rb_add_time_stamp(struct ring_buffer_per_cpu *cpu_buffer,
>  	return skip_time_extend(event);
>  }
>  
> -#ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
> -static inline bool sched_clock_stable(void)
> -{
> -	return true;
> -}
> -#endif
> -
>  static void
>  rb_check_timestamp(struct ring_buffer_per_cpu *cpu_buffer,
>  		   struct rb_event_info *info)


Thanks for moving this out of the ring buffer code.

Acked-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

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

end of thread, other threads:[~2026-05-14 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-14 16:05 [PATCH] sched/clock: Provide !HAVE_UNSTABLE_SCHED_CLOCK stub for sched_clock_stable() Yiyang Chen
2026-05-14 19:36 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox