[PATCH] tracing: always provide a prototype for tracing_alloc_snapshot()

Bartosz Golaszewski posted 1 patch 1 day, 2 hours ago
kernel/trace/trace.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] tracing: always provide a prototype for tracing_alloc_snapshot()
Posted by Bartosz Golaszewski 1 day, 2 hours ago
The tracing_alloc_snapshot() symbol is always exported even with
!CONFIG_TRACER_SNAPSHOT so the prototype too must be always visible or
we'll see the following warning:

kernel/trace/trace.c:820:5: warning: no previous prototype for ‘tracing_alloc_snapshot’ [-Wmissing-prototypes]
  820 | int tracing_alloc_snapshot(void)
      |     ^~~~~~~~~~~~~~~~~~~~~~

Fixes: bade44fe5462 ("tracing: Move snapshot code out of trace.c and into trace_snapshot.c")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 kernel/trace/trace.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 6abd9e16ef21..e8612b8b0a34 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -2275,6 +2275,8 @@ static inline void __init trace_event_init(void) { }
 static inline void trace_event_update_all(struct trace_eval_map **map, int len) { }
 #endif
 
+int tracing_alloc_snapshot(void);
+
 #ifdef CONFIG_TRACER_SNAPSHOT
 extern const struct file_operations snapshot_fops;
 extern const struct file_operations snapshot_raw_fops;
@@ -2282,7 +2284,6 @@ extern const struct file_operations snapshot_raw_fops;
 /* Used when creating instances */
 int trace_allocate_snapshot(struct trace_array *tr, int size);
 
-int tracing_alloc_snapshot(void);
 void tracing_snapshot_cond(struct trace_array *tr, void *cond_data);
 int tracing_snapshot_cond_enable(struct trace_array *tr, void *cond_data, cond_update_fn_t update);
 int tracing_snapshot_cond_disable(struct trace_array *tr);
-- 
2.47.3

Re: [PATCH] tracing: always provide a prototype for tracing_alloc_snapshot()
Posted by Masami Hiramatsu (Google) 1 day, 1 hour ago
On Tue, 31 Mar 2026 10:20:01 +0200
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> wrote:

> The tracing_alloc_snapshot() symbol is always exported even with
> !CONFIG_TRACER_SNAPSHOT so the prototype too must be always visible or
> we'll see the following warning:
> 
> kernel/trace/trace.c:820:5: warning: no previous prototype for ‘tracing_alloc_snapshot’ [-Wmissing-prototypes]
>   820 | int tracing_alloc_snapshot(void)
>       |     ^~~~~~~~~~~~~~~~~~~~~~
> 
> Fixes: bade44fe5462 ("tracing: Move snapshot code out of trace.c and into trace_snapshot.c")
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

Good catch!

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Thanks!

> ---
>  kernel/trace/trace.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index 6abd9e16ef21..e8612b8b0a34 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -2275,6 +2275,8 @@ static inline void __init trace_event_init(void) { }
>  static inline void trace_event_update_all(struct trace_eval_map **map, int len) { }
>  #endif
>  
> +int tracing_alloc_snapshot(void);
> +
>  #ifdef CONFIG_TRACER_SNAPSHOT
>  extern const struct file_operations snapshot_fops;
>  extern const struct file_operations snapshot_raw_fops;
> @@ -2282,7 +2284,6 @@ extern const struct file_operations snapshot_raw_fops;
>  /* Used when creating instances */
>  int trace_allocate_snapshot(struct trace_array *tr, int size);
>  
> -int tracing_alloc_snapshot(void);
>  void tracing_snapshot_cond(struct trace_array *tr, void *cond_data);
>  int tracing_snapshot_cond_enable(struct trace_array *tr, void *cond_data, cond_update_fn_t update);
>  int tracing_snapshot_cond_disable(struct trace_array *tr);
> -- 
> 2.47.3
> 


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>
Re: [PATCH] tracing: always provide a prototype for tracing_alloc_snapshot()
Posted by Steven Rostedt 18 hours ago
On Tue, 31 Mar 2026 18:20:36 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> On Tue, 31 Mar 2026 10:20:01 +0200
> Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> wrote:
> 
> > The tracing_alloc_snapshot() symbol is always exported even with
> > !CONFIG_TRACER_SNAPSHOT so the prototype too must be always visible or
> > we'll see the following warning:
> > 
> > kernel/trace/trace.c:820:5: warning: no previous prototype for ‘tracing_alloc_snapshot’ [-Wmissing-prototypes]
> >   820 | int tracing_alloc_snapshot(void)
> >       |     ^~~~~~~~~~~~~~~~~~~~~~
> > 
> > Fixes: bade44fe5462 ("tracing: Move snapshot code out of trace.c and into trace_snapshot.c")
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>  
> 
> Good catch!
> 
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

But is the wrong fix. I already fixed it properly:

  https://patch.msgid.link/20260328101946.2c4ef4a5@robin

It's still in the testing phase but will be going to linux-next this week.

-- Steve