public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "kernel test robot" <lkp@intel.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Linux trace kernel" <linux-trace-kernel@vger.kernel.org>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>
Subject: Re: [PATCH] tracing: Move snapshot code out of trace.c and into trace_snapshot.c
Date: Mon, 30 Mar 2026 16:06:44 +0200	[thread overview]
Message-ID: <8580f943-4c37-4c66-937d-adee13b72201@app.fastmail.com> (raw)
In-Reply-To: <202603070230.Zz4BBLtb-lkp@intel.com>

On Fri, Mar 6, 2026, at 20:07, kernel test robot wrote:
>>> kernel/trace/trace.c:820:5: warning: no previous prototype for function 'tracing_alloc_snapshot' [-Wmissing-prototypes]
>      820 | int tracing_alloc_snapshot(void)
>          |     ^
>    kernel/trace/trace.c:820:1: note: declare 'static' if the function 
> is not intended to be used outside of this translation unit
>      820 | int tracing_alloc_snapshot(void)
>          | ^
>          | static 
>    1 warning generated.

I saw the same thing and worked around it by removing the function.
I then noticed that a bunch of code surrounding it is also unused
and I removed that as well (see below). This version passes
my randconfig build tests, but I suspect it is still wrong,
since the code never had any callers and I don't understand
why.

       Arnd


diff --git a/include/linux/trace_printk.h b/include/linux/trace_printk.h
index 2670ec7f4262..87466d8df147 100644
--- a/include/linux/trace_printk.h
+++ b/include/linux/trace_printk.h
@@ -38,8 +38,6 @@ enum ftrace_dump_mode {
 void tracing_on(void);
 void tracing_off(void);
 int tracing_is_on(void);
-void tracing_snapshot(void);
-void tracing_snapshot_alloc(void);
 
 extern void tracing_start(void);
 extern void tracing_stop(void);
@@ -184,8 +182,6 @@ static inline void trace_dump_stack(int skip) { }
 static inline void tracing_on(void) { }
 static inline void tracing_off(void) { }
 static inline int tracing_is_on(void) { return 0; }
-static inline void tracing_snapshot(void) { }
-static inline void tracing_snapshot_alloc(void) { }
 
 static inline __printf(1, 2)
 int trace_printk(const char *fmt, ...)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index ec2b926436a7..76fe2c758734 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -767,70 +767,6 @@ void tracing_on(void)
 }
 EXPORT_SYMBOL_GPL(tracing_on);
 
-#ifdef CONFIG_TRACER_SNAPSHOT
-/**
- * tracing_snapshot - take a snapshot of the current buffer.
- *
- * This causes a swap between the snapshot buffer and the current live
- * tracing buffer. You can use this to take snapshots of the live
- * trace when some condition is triggered, but continue to trace.
- *
- * Note, make sure to allocate the snapshot with either
- * a tracing_snapshot_alloc(), or by doing it manually
- * with: echo 1 > /sys/kernel/tracing/snapshot
- *
- * If the snapshot buffer is not allocated, it will stop tracing.
- * Basically making a permanent snapshot.
- */
-void tracing_snapshot(void)
-{
-	struct trace_array *tr = &global_trace;
-
-	tracing_snapshot_instance(tr);
-}
-EXPORT_SYMBOL_GPL(tracing_snapshot);
-
-/**
- * tracing_alloc_snapshot - allocate snapshot buffer.
- *
- * This only allocates the snapshot buffer if it isn't already
- * allocated - it doesn't also take a snapshot.
- *
- * This is meant to be used in cases where the snapshot buffer needs
- * to be set up for events that can't sleep but need to be able to
- * trigger a snapshot.
- */
-int tracing_alloc_snapshot(void)
-{
-	struct trace_array *tr = &global_trace;
-	int ret;
-
-	ret = tracing_alloc_snapshot_instance(tr);
-	WARN_ON(ret < 0);
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(tracing_alloc_snapshot);
-#else
-void tracing_snapshot(void)
-{
-	WARN_ONCE(1, "Snapshot feature not enabled, but internal snapshot used");
-}
-EXPORT_SYMBOL_GPL(tracing_snapshot);
-int tracing_alloc_snapshot(void)
-{
-	WARN_ONCE(1, "Snapshot feature not enabled, but snapshot allocation used");
-	return -ENODEV;
-}
-EXPORT_SYMBOL_GPL(tracing_alloc_snapshot);
-void tracing_snapshot_alloc(void)
-{
-	/* Give warning */
-	tracing_snapshot();
-}
-EXPORT_SYMBOL_GPL(tracing_snapshot_alloc);
-#endif /* CONFIG_TRACER_SNAPSHOT */
-
 void tracer_tracing_off(struct trace_array *tr)
 {
 	if (tr->array_buffer.buffer)
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index e4cf6703b301..6abd9e16ef21 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -2306,7 +2306,6 @@ static inline int register_snapshot_cmd(void) { return 0; }
 # endif
 #else /* !CONFIG_TRACER_SNAPSHOT */
 static inline int trace_allocate_snapshot(struct trace_array *tr, int size) { return 0; }
-static inline int tracing_alloc_snapshot(void) { return 0; }
 static inline void tracing_snapshot_instance(struct trace_array *tr) { }
 static inline int tracing_alloc_snapshot_instance(struct trace_array *tr)
 {
diff --git a/kernel/trace/trace_snapshot.c b/kernel/trace/trace_snapshot.c
index 8865b2ef2264..926f395e5af4 100644
--- a/kernel/trace/trace_snapshot.c
+++ b/kernel/trace/trace_snapshot.c
@@ -237,29 +237,6 @@ void tracing_disarm_snapshot(struct trace_array *tr)
 	spin_unlock(&tr->snapshot_trigger_lock);
 }
 
-/**
- * tracing_snapshot_alloc - allocate and take a snapshot of the current buffer.
- *
- * This is similar to tracing_snapshot(), but it will allocate the
- * snapshot buffer if it isn't already allocated. Use this only
- * where it is safe to sleep, as the allocation may sleep.
- *
- * This causes a swap between the snapshot buffer and the current live
- * tracing buffer. You can use this to take snapshots of the live
- * trace when some condition is triggered, but continue to trace.
- */
-void tracing_snapshot_alloc(void)
-{
-	int ret;
-
-	ret = tracing_alloc_snapshot();
-	if (ret < 0)
-		return;
-
-	tracing_snapshot();
-}
-EXPORT_SYMBOL_GPL(tracing_snapshot_alloc);
-
 /**
  * tracing_snapshot_cond_enable - enable conditional snapshot for an instance
  * @tr:		The tracing instance
@@ -391,8 +368,6 @@ void latency_fsnotify(struct trace_array *tr)
 	 */
 	irq_work_queue(&tr->fsnotify_irqwork);
 }
-#else
-static inline void latency_fsnotify(struct trace_array *tr) { }
 #endif /* LATENCY_FS_NOTIFY */
 static const struct file_operations tracing_max_lat_fops;
 

  reply	other threads:[~2026-03-30 14:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06  2:18 [PATCH] tracing: Move snapshot code out of trace.c and into trace_snapshot.c Steven Rostedt
2026-03-06 18:55 ` kernel test robot
2026-03-06 18:55 ` kernel test robot
2026-03-06 19:07 ` kernel test robot
2026-03-30 14:06   ` Arnd Bergmann [this message]
2026-03-30 16:05     ` Steven Rostedt
2026-03-31 10:53       ` Arnd Bergmann
2026-03-31 12:34         ` Steven Rostedt

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=8580f943-4c37-4c66-937d-adee13b72201@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=rostedt@goodmis.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