Skip to contentSkip to conversation

tracing: Updates for 7.1

PATCH New Steven Rostedt 1 participant 14 messages Mar 26

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

cover tracing: Updates for 7.1

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/for-next

Head SHA1: bade44fe546212e142befb69ba22f34944030a99

Arnd Bergmann (1):
tracing: move __printf() attribute on __ftrace_vbprintk()

Donglin Peng (1):
tracing: Pretty-print enum parameters in function arguments

Petr Pavlu (3):
tracing: Remove unnecessary check for EVENT_FILE_FL_FREED
tracing: Clean up access to trace_event_file from a file pointer
tracing: Free up file->private_data for use by individual events

Randy Dunlap (1):
tracing: trace_mmap.h: fix a kernel-doc warning

Steven Rostedt (1):
tracing: Move snapshot code out of trace.c and into trace_snapshot.c

Vineeth Pillai (Google) (6):
tracepoint: Add trace_call__##name() API
kernel: Use trace_call__##name() at guarded tracepoint call sites
i2c: Use trace_call__##name() at guarded tracepoint call sites
spi: Use trace_call__##name() at guarded tracepoint call sites
btrfs: Use trace_call__##name() at guarded tracepoint call sites
mm: damon: Use trace_call__##name() at guarded tracepoint call sites

----

 drivers/i2c/i2c-core-slave.c     |    2 +-
 drivers/spi/spi-axi-spi-engine.c |    4 +-
 fs/btrfs/extent_map.c            |    4 +-
 fs/btrfs/raid56.c                |    4 +-
 include/linux/ftrace.h           |    2 +-
 include/linux/trace_printk.h     |    1 -
 include/linux/tracepoint.h       |   11 +
 include/uapi/linux/trace_mmap.h  |    1 +
 kernel/irq_work.c                |    2 +-
 kernel/sched/ext.c               |    2 +-
 kernel/smp.c                     |    2 +-
 kernel/trace/Makefile            |    1 +
 kernel/trace/trace.c             | 1276 ++------------------------------------
 kernel/trace/trace.h             |  122 +++-
 kernel/trace/trace_events.c      |   14 +-
 kernel/trace/trace_events_hist.c |    4 -
 kernel/trace/trace_output.c      |   12 +-
 kernel/trace/trace_printk.c      |    1 +
 kernel/trace/trace_snapshot.c    | 1067 +++++++++++++++++++++++++++++++
 mm/damon/core.c                  |    2 +-
 20 files changed, 1281 insertions(+), 1253 deletions(-)
 create mode 100644 kernel/trace/trace_snapshot.c
#1 lore raw

PATCH 1/13 tracing: move __printf() attribute on __ftrace_vbprintk()

From: Arnd Bergmann <[email protected]>

The sunrpc change to use trace_printk() for debugging caused a new warning for every instance of dprintk() in some configurations, when -Wformat-security is enabled:

fs/nfs/getroot.c: In function 'nfs_get_root':
fs/nfs/getroot.c:90:17: error: format not a string literal and no format arguments [-Werror=format-security]
90 | nfs_errorf(fc, "NFS: Couldn't getattr on root");

I've been slowly chipping away at those warnings over time with the intention of enabling them by default in the future. While I could not figure out why this only happens for this one instance, I see that the __trace_bprintk() function is always called with a local variable as the format string, rather than a literal.

Move the __printf(2,3) annotation on this function from the declaration to the caller. As this is can only be validated for literals, the attribute on the declaration causes the warnings every time, but removing it entirely introduces a new warning on the __ftrace_vbprintk() definition.

The format strings still get checked because the underlying literal keeps getting passed into __trace_printk() in the "else" branch, which is not taken but still evaluated for compile-time warnings.

Cc Masami Hiramatsu <[email protected]>
Cc Anna Schumaker <[email protected]>
Cc Chuck Lever <[email protected]>
Cc Simon Horman <[email protected]>
Cc Mathieu Desnoyers <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Yury Norov <[email protected]>
Cc Randy Dunlap <[email protected]>
Fixes ec7d8e68ef0e ("sunrpc: add a Kconfig option to redirect dfprintk() output to trace buffer")
---
 include/linux/trace_printk.h | 1 -
 kernel/trace/trace_printk.c  | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
include/linux/trace_printk.h +0 -1
index bb5874097f24..2670ec7f4262 100644
@@ -107,7 +107,6 @@ do {									\
 		__trace_printk(_THIS_IP_, fmt, ##args);			\
 } while (0)
 
-extern __printf(2, 3)
 int __trace_bprintk(unsigned long ip, const char *fmt, ...);
 
 extern __printf(2, 3)
kernel/trace/trace_printk.c +1 -0
index 5ea5e0d76f00..3ea17af60169 100644
@@ -197,6 +197,7 @@ struct notifier_block module_trace_bprintk_format_nb = {
 	.notifier_call = module_trace_bprintk_format_notify,
 };
 
+__printf(2, 3)
 int __trace_bprintk(unsigned long ip, const char *fmt, ...)
 {
 	int ret;
Signature · 1 line
2.51.0
#2 lore raw

PATCH 2/13 tracing: Remove unnecessary check for EVENT_FILE_FL_FREED

In reply to Steven Rostedt

From: Petr Pavlu <[email protected]>

The event_filter_write() function calls event_file_file() to retrieve a trace_event_file associated with a given file struct. If a non-NULL pointer is returned, the function then checks whether the trace_event_file instance has the EVENT_FILE_FL_FREED flag set. This check is redundant because event_file_file() already performs this validation and returns NULL if the flag is set. The err value is also already initialized to -ENODEV.

Remove the unnecessary check for EVENT_FILE_FL_FREED in event_filter_write().

---
 kernel/trace/trace_events.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/trace/trace_events.c +2 -6
index 249d1cba72c0..26d1e95a55d1 100644
@@ -2247,12 +2247,8 @@ event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
 
 	mutex_lock(&event_mutex);
 	file = event_file_file(filp);
-	if (file) {
-		if (file->flags & EVENT_FILE_FL_FREED)
-			err = -ENODEV;
-		else
-			err = apply_event_filter(file, buf);
-	}
+	if (file)
+		err = apply_event_filter(file, buf);
 	mutex_unlock(&event_mutex);
 
 	kfree(buf);
Signature · 1 line
2.51.0
#3 lore raw

PATCH 3/13 tracing: Clean up access to trace_event_file from a file pointer

In reply to Steven Rostedt

From: Petr Pavlu <[email protected]>

The tracing code provides two functions event_file_file() and event_file_data() to obtain a trace_event_file pointer from a file struct. The primary method to use is event_file_file(), as it checks for the EVENT_FILE_FL_FREED flag to determine whether the event is being removed. The second function event_file_data() is an optimization for retrieving the same data when the event_mutex is still held.

In the past, when removing an event directory in remove_event_file_dir(), the code set i_private to NULL for all event files and readers were expected to check for this state to recognize that the event is being removed. In the case of event_id_read(), the value was read using event_file_data() without acquiring the event_mutex. This required event_file_data() to use READ_ONCE() when retrieving the i_private data.

With the introduction of eventfs, i_private is assigned when an eventfs inode is allocated and remains set throughout its lifetime.

Remove the now unnecessary READ_ONCE() access to i_private in both event_file_file() and event_file_data(). Inline the access to i_private in remove_event_file_dir(), which allows event_file_data() to handle i_private solely as a trace_event_file pointer. Add a check in event_file_data() to ensure that the event_mutex is held and that file->flags doesn't have the EVENT_FILE_FL_FREED flag set. Finally, move event_file_data() immediately after event_file_code() since the latter provides a comment explaining how both functions should be used together.

---
 kernel/trace/trace.h        | 17 +++++++++++------
 kernel/trace/trace_events.c |  6 +++---
 2 files changed, 14 insertions(+), 9 deletions(-)
kernel/trace/trace.h +11 -6
index b8f3804586a0..7db78a62f786 100644
@@ -1802,11 +1802,6 @@ extern struct trace_event_file *find_event_file(struct trace_array *tr,
 						const char *system,
 						const char *event);
 
-static inline void *event_file_data(struct file *filp)
-{
-	return READ_ONCE(file_inode(filp)->i_private);
-}
-
 extern struct mutex event_mutex;
 extern struct list_head ftrace_events;
 
@@ -1827,12 +1822,22 @@ static inline struct trace_event_file *event_file_file(struct file *filp)
 	struct trace_event_file *file;
 
 	lockdep_assert_held(&event_mutex);
-	file = READ_ONCE(file_inode(filp)->i_private);
+	file = file_inode(filp)->i_private;
 	if (!file || file->flags & EVENT_FILE_FL_FREED)
 		return NULL;
 	return file;
 }
 
+static inline void *event_file_data(struct file *filp)
+{
+	struct trace_event_file *file;
+
+	lockdep_assert_held(&event_mutex);
+	file = file_inode(filp)->i_private;
+	WARN_ON(!file || file->flags & EVENT_FILE_FL_FREED);
+	return file;
+}
+
 extern const struct file_operations event_trigger_fops;
 extern const struct file_operations event_hist_fops;
 extern const struct file_operations event_hist_debug_fops;
kernel/trace/trace_events.c +3 -3
index 26d1e95a55d1..6523c873689a 100644
@@ -2184,12 +2184,12 @@ static int trace_format_open(struct inode *inode, struct file *file)
 static ssize_t
 event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
 {
-	int id = (long)event_file_data(filp);
+	/* id is directly in i_private and available for inode's lifetime. */
+	int id = (long)file_inode(filp)->i_private;
 	char buf[32];
 	int len;
 
-	if (unlikely(!id))
-		return -ENODEV;
+	WARN_ON(!id);
 
 	len = sprintf(buf, "%d\n", id);
 
Signature · 1 line
2.51.0
#4 lore raw

PATCH 4/13 tracing: Free up file->private_data for use by individual events

In reply to Steven Rostedt

From: Petr Pavlu <[email protected]>

The tracing_open_file_tr() function currently copies the trace_event_file pointer from inode->i_private to file->private_data when the file is successfully opened. This duplication is not particularly useful, as all event code should utilize event_file_file() or event_file_data() to retrieve a trace_event_file pointer from a file struct and these access functions read file->f_inode->i_private. Moreover, this setup requires the code for opening hist files to explicitly clear file->private_data before calling single_open(), since this function expects the private_data member to be set to NULL and uses it to store a pointer to a seq_file.

Remove the unnecessary setting of file->private_data in tracing_open_file_tr() and simplify the hist code.

---
 kernel/trace/trace.c             | 2 --
 kernel/trace/trace_events_hist.c | 4 ----
 2 files changed, 6 deletions(-)
kernel/trace/trace.c +0 -2
index a626211ceb9a..cf48fe23e71f 100644
@@ -4050,8 +4050,6 @@ int tracing_open_file_tr(struct inode *inode, struct file *filp)
 		event_file_get(file);
 	}
 
-	filp->private_data = inode->i_private;
-
 	return 0;
 }
 
kernel/trace/trace_events_hist.c +0 -4
index 73ea180cad55..67cb92310864 100644
@@ -5836,8 +5836,6 @@ static int event_hist_open(struct inode *inode, struct file *file)
 	hist_file->file = file;
 	hist_file->last_act = get_hist_hit_count(event_file);
 
-	/* Clear private_data to avoid warning in single_open() */
-	file->private_data = NULL;
 	ret = single_open(file, hist_show, hist_file);
 	if (ret) {
 		kfree(hist_file);
@@ -6126,8 +6124,6 @@ static int event_hist_debug_open(struct inode *inode, struct file *file)
 	if (ret)
 		return ret;
 
-	/* Clear private_data to avoid warning in single_open() */
-	file->private_data = NULL;
 	ret = single_open(file, hist_debug_show, file);
 	if (ret)
 		tracing_release_file_tr(inode, file);
Signature · 1 line
2.51.0
#5 lore raw

PATCH 5/13 tracing: Pretty-print enum parameters in function arguments

In reply to Steven Rostedt

From: Donglin Peng <[email protected]>

Currently, print_function_args() prints enum parameter values in decimal format, reducing trace log readability.

Use BTF information to resolve enum parameters and print their symbolic names (where available). This improves readability by showing meaningful identifiers instead of raw numbers.

Before:
mod_memcg_lruvec_state(lruvec=0xffff..., idx=5, val=320)

After:
mod_memcg_lruvec_state(lruvec=0xffff..., idx=5 [NR_SLAB_RECLAIMABLE_B], val=320)

---
 kernel/trace/trace_output.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
kernel/trace/trace_output.c +11 -1
index 1996d7aba038..be0755400f9b 100644
@@ -719,12 +719,13 @@ void print_function_args(struct trace_seq *s, unsigned long *args,
 {
 	const struct btf_param *param;
 	const struct btf_type *t;
+	const struct btf_enum *enums;
 	const char *param_name;
 	char name[KSYM_NAME_LEN];
 	unsigned long arg;
 	struct btf *btf;
 	s32 tid, nr = 0;
-	int a, p, x;
+	int a, p, x, i;
 	u16 encode;
 
 	trace_seq_printf(s, "(");
@@ -778,6 +779,15 @@ void print_function_args(struct trace_seq *s, unsigned long *args,
 			break;
 		case BTF_KIND_ENUM:
 			trace_seq_printf(s, "%ld", arg);
+			enums = btf_enum(t);
+			for (i = 0; i < btf_vlen(t); i++) {
+				if (arg == enums[i].val) {
+					trace_seq_printf(s, " [%s]",
+							 btf_name_by_offset(btf,
+							 enums[i].name_off));
+					break;
+				}
+			}
 			break;
 		default:
 			/* This does not handle complex arguments */
Signature · 1 line
2.51.0
#6 lore raw

PATCH 6/13 tracing: trace_mmap.h: fix a kernel-doc warning

In reply to Steven Rostedt

From: Randy Dunlap <[email protected]>

Add a description of struct reader to resolve a kernel-doc warning:

Warning: include/uapi/linux/trace_mmap.h:43 struct member 'reader' not described in 'trace_buffer_meta'

---
 include/uapi/linux/trace_mmap.h | 1 +
 1 file changed, 1 insertion(+)
include/uapi/linux/trace_mmap.h +1 -0
index c102ef35d11e..99653f259a7a 100644
@@ -10,6 +10,7 @@
  * @meta_struct_len:	Size of this structure.
  * @subbuf_size:	Size of each sub-buffer.
  * @nr_subbufs:		Number of subbfs in the ring-buffer, including the reader.
+ * @reader:		The reader composite info structure
  * @reader.lost_events:	Number of events lost at the time of the reader swap.
  * @reader.id:		subbuf ID of the current reader. ID range [0 : @nr_subbufs - 1]
  * @reader.read:	Number of bytes read on the reader subbuf.
Signature · 1 line
2.51.0
#7 lore raw

PATCH 7/13 tracepoint: Add trace_call__##name() API

In reply to Steven Rostedt

From: "Vineeth Pillai (Google)" <[email protected]>

Add trace_call__##name() as a companion to trace_##name(). When a caller already guards a tracepoint with an explicit enabled check:

  if (trace_foo_enabled() && cond)
      trace_foo(args);

trace_foo() internally repeats the static_branch_unlikely() test, which the compiler cannot fold since static branches are patched binary instructions. This results in two static-branch evaluations for every guarded call site.

trace_call__##name() calls __do_trace_##name() directly, skipping the redundant static-branch re-check. This avoids leaking the internal __do_trace_##name() symbol into call sites while still eliminating the double evaluation:

  if (trace_foo_enabled() && cond)
      trace_invoke_foo(args);   /* calls __do_trace_foo() directly */

Three locations are updated:
- __DECLARE_TRACE: invoke form omits static_branch_unlikely, retains the LOCKDEP RCU-watching assertion.
- __DECLARE_TRACE_SYSCALL: same, plus retains might_fault().
- !TRACEPOINTS_ENABLED stub: empty no-op so callers compile cleanly when tracepoints are compiled out.

Cc Dmitry Ilvokhin <[email protected]>
Cc Mathieu Desnoyers <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jens Axboe <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Marcelo Ricardo Leitner <[email protected]>
Cc Xin Long <[email protected]>
Cc Jon Maloy <[email protected]>
Cc Aaron Conole <[email protected]>
Cc Eelco Chaudron <[email protected]>
Cc Ilya Maximets <[email protected]>
Cc Jiri Pirko <[email protected]>
Cc Oded Gabbay <[email protected]>
Cc Koby Elbaz <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Viresh Kumar <[email protected]>
Cc "Gautham R. Shenoy" <[email protected]>
Cc Huang Rui <[email protected]>
Cc Mario Limonciello <[email protected]>
Cc Len Brown <[email protected]>
Cc Srinivas Pandruvada <[email protected]>
Cc MyungJoo Ham <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Chanwoo Choi <[email protected]>
Cc Christian König <[email protected]>
Cc Sumit Semwal <[email protected]>
Cc Eddie James <[email protected]>
Cc Andrew Jeffery <[email protected]>
Cc Joel Stanley <[email protected]>
Cc David Airlie <[email protected]>
Cc Simona Vetter <[email protected]>
Cc Alex Deucher <[email protected]>
Cc Danilo Krummrich <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Philipp Stanner <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Leo Li <[email protected]>
Cc Jiri Kosina <[email protected]>
Cc Benjamin Tissoires <[email protected]>
Cc Wolfram Sang <[email protected]>
Cc Mark Brown <[email protected]>
Cc Michael Hennerich <[email protected]>
Cc Nuno Sá <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc "Martin K. Petersen" <[email protected]>
Cc Chris Mason <[email protected]>
Cc David Sterba <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Andrew Morton <[email protected]>
Cc SeongJae Park <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Assisted-by Claude:claude-sonnet-4-6
---
 include/linux/tracepoint.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
include/linux/tracepoint.h +11 -0
index 22ca1c8b54f3..ed969705341f 100644
@@ -294,6 +294,10 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
 			WARN_ONCE(!rcu_is_watching(),			\
 				  "RCU not watching for tracepoint");	\
 		}							\
+	}								\
+	static inline void trace_call__##name(proto)			\
+	{								\
+		__do_trace_##name(args);				\
 	}
 
 #define __DECLARE_TRACE_SYSCALL(name, proto, args, data_proto)		\
@@ -313,6 +317,11 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
 			WARN_ONCE(!rcu_is_watching(),			\
 				  "RCU not watching for tracepoint");	\
 		}							\
+	}								\
+	static inline void trace_call__##name(proto)			\
+	{								\
+		might_fault();						\
+		__do_trace_##name(args);				\
 	}
 
 /*
@@ -398,6 +407,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
 #define __DECLARE_TRACE_COMMON(name, proto, args, data_proto)		\
 	static inline void trace_##name(proto)				\
 	{ }								\
+	static inline void trace_call__##name(proto)			\
+	{ }								\
 	static inline int						\
 	register_trace_##name(void (*probe)(data_proto),		\
 			      void *data)				\
Signature · 1 line
2.51.0
#8 lore raw

PATCH 8/13 kernel: Use trace_call__##name() at guarded tracepoint call sites

In reply to Steven Rostedt

From: "Vineeth Pillai (Google)" <[email protected]>

Replace trace_foo() with the new trace_call__foo() at sites already guarded by trace_foo_enabled(), avoiding a redundant static_branch_unlikely() re-evaluation inside the tracepoint. trace_call__foo() calls the tracepoint callbacks directly without utilizing the static branch again.

Cc David Vernet <[email protected]>
Cc Andrea Righi <[email protected]>
Cc Changwoo Min <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Juri Lelli <[email protected]>
Cc Vincent Guittot <[email protected]>
Cc Dietmar Eggemann <[email protected]>
Cc Ben Segall <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Valentin Schneider <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc "Yury Norov [NVIDIA]" <[email protected]>
Cc "Paul E. McKenney" <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Roman Kisel <[email protected]>
Cc Joel Fernandes <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Ulf Hansson <[email protected]>
Assisted-by Claude:claude-sonnet-4-6
---
 kernel/irq_work.c  | 2 +-
 kernel/sched/ext.c | 2 +-
 kernel/smp.c       | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
kernel/irq_work.c +1 -1
index 73f7e1fd4ab4..120fd7365fbe 100644
@@ -79,7 +79,7 @@ void __weak arch_irq_work_raise(void)
 static __always_inline void irq_work_raise(struct irq_work *work)
 {
 	if (trace_ipi_send_cpu_enabled() && arch_irq_work_has_interrupt())
-		trace_ipi_send_cpu(smp_processor_id(), _RET_IP_, work->func);
+		trace_call__ipi_send_cpu(smp_processor_id(), _RET_IP_, work->func);
 
 	arch_irq_work_raise();
 }
kernel/sched/ext.c +1 -1
index 26a6ac2f8826..7da8be1b0f26 100644
@@ -4493,7 +4493,7 @@ static __printf(2, 3) void dump_line(struct seq_buf *s, const char *fmt, ...)
 		vscnprintf(line_buf, sizeof(line_buf), fmt, args);
 		va_end(args);
 
-		trace_sched_ext_dump(line_buf);
+		trace_call__sched_ext_dump(line_buf);
 	}
 #endif
 	/* @s may be zero sized and seq_buf triggers WARN if so */
kernel/smp.c +1 -1
index f349960f79ca..537cf1f461d7 100644
@@ -394,7 +394,7 @@ void __smp_call_single_queue(int cpu, struct llist_node *node)
 		func = CSD_TYPE(csd) == CSD_TYPE_TTWU ?
 			sched_ttwu_pending : csd->func;
 
-		trace_csd_queue_cpu(cpu, _RET_IP_, func, csd);
+		trace_call__csd_queue_cpu(cpu, _RET_IP_, func, csd);
 	}
 
 	/*
Signature · 1 line
2.51.0
#9 lore raw

PATCH 9/13 i2c: Use trace_call__##name() at guarded tracepoint call sites

In reply to Steven Rostedt

From: "Vineeth Pillai (Google)" <[email protected]>

Replace trace_foo() with the new trace_call__foo() at sites already guarded by trace_foo_enabled(), avoiding a redundant static_branch_unlikely() re-evaluation inside the tracepoint. trace_call__foo() calls the tracepoint callbacks directly without utilizing the static branch again.

---
 drivers/i2c/i2c-core-slave.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core-slave.c +1 -1
index 02ca55c2246b..bebb7ba67e30 100644
@@ -89,7 +89,7 @@ int i2c_slave_event(struct i2c_client *client,
 	int ret = client->slave_cb(client, event, val);
 
 	if (trace_i2c_slave_enabled())
-		trace_i2c_slave(client, event, val, ret);
+		trace_call__i2c_slave(client, event, val, ret);
 
 	return ret;
 }
Signature · 1 line
2.51.0
#10 lore raw

PATCH 10/13 spi: Use trace_call__##name() at guarded tracepoint call sites

In reply to Steven Rostedt

From: "Vineeth Pillai (Google)" <[email protected]>

Replace trace_foo() with the new trace_call__foo() at sites already guarded by trace_foo_enabled(), avoiding a redundant static_branch_unlikely() re-evaluation inside the tracepoint. trace_call__foo() calls the tracepoint callbacks directly without utilizing the static branch again.

---
 drivers/spi/spi-axi-spi-engine.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-axi-spi-engine.c +2 -2
index 48ee5bf48173..02bbc5d0cfc5 100644
@@ -953,7 +953,7 @@ static int spi_engine_transfer_one_message(struct spi_controller *host,
 		struct spi_transfer *xfer;
 
 		list_for_each_entry(xfer, &msg->transfers, transfer_list)
-			trace_spi_transfer_start(msg, xfer);
+			trace_call__spi_transfer_start(msg, xfer);
 	}
 
 	spin_lock_irqsave(&spi_engine->lock, flags);
@@ -987,7 +987,7 @@ static int spi_engine_transfer_one_message(struct spi_controller *host,
 		struct spi_transfer *xfer;
 
 		list_for_each_entry(xfer, &msg->transfers, transfer_list)
-			trace_spi_transfer_stop(msg, xfer);
+			trace_call__spi_transfer_stop(msg, xfer);
 	}
 
 out:
Signature · 1 line
2.51.0
#11 lore raw

PATCH 11/13 btrfs: Use trace_call__##name() at guarded tracepoint call sites

In reply to Steven Rostedt

From: "Vineeth Pillai (Google)" <[email protected]>

Replace trace_foo() with the new trace_call__foo() at sites already guarded by trace_foo_enabled(), avoiding a redundant static_branch_unlikely() re-evaluation inside the tracepoint. trace_call__foo() calls the tracepoint callbacks directly without utilizing the static branch again.

---
 fs/btrfs/extent_map.c | 4 ++--
 fs/btrfs/raid56.c     | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/extent_map.c +2 -2
index 095a561d733f..9284c0a81bef 100644
@@ -1318,7 +1318,7 @@ static void btrfs_extent_map_shrinker_worker(struct work_struct *work)
 	if (trace_btrfs_extent_map_shrinker_scan_enter_enabled()) {
 		s64 nr = percpu_counter_sum_positive(&fs_info->evictable_extent_maps);
 
-		trace_btrfs_extent_map_shrinker_scan_enter(fs_info, nr);
+		trace_call__btrfs_extent_map_shrinker_scan_enter(fs_info, nr);
 	}
 
 	while (ctx.scanned < ctx.nr_to_scan && !btrfs_fs_closing(fs_info)) {
@@ -1358,7 +1358,7 @@ static void btrfs_extent_map_shrinker_worker(struct work_struct *work)
 	if (trace_btrfs_extent_map_shrinker_scan_exit_enabled()) {
 		s64 nr = percpu_counter_sum_positive(&fs_info->evictable_extent_maps);
 
-		trace_btrfs_extent_map_shrinker_scan_exit(fs_info, nr_dropped, nr);
+		trace_call__btrfs_extent_map_shrinker_scan_exit(fs_info, nr_dropped, nr);
 	}
 
 	atomic64_set(&fs_info->em_shrinker_nr_to_scan, 0);
fs/btrfs/raid56.c +2 -2
index 02105d68accb..30bd6c0fdd1f 100644
@@ -1743,7 +1743,7 @@ static void submit_read_wait_bio_list(struct btrfs_raid_bio *rbio,
 			struct raid56_bio_trace_info trace_info = { 0 };
 
 			bio_get_trace_info(rbio, bio, &trace_info);
-			trace_raid56_read(rbio, bio, &trace_info);
+			trace_call__raid56_read(rbio, bio, &trace_info);
 		}
 		submit_bio(bio);
 	}
@@ -2428,7 +2428,7 @@ static void submit_write_bios(struct btrfs_raid_bio *rbio,
 			struct raid56_bio_trace_info trace_info = { 0 };
 
 			bio_get_trace_info(rbio, bio, &trace_info);
-			trace_raid56_write(rbio, bio, &trace_info);
+			trace_call__raid56_write(rbio, bio, &trace_info);
 		}
 		submit_bio(bio);
 	}
Signature · 1 line
2.51.0
#12 lore raw

PATCH 12/13 mm: damon: Use trace_call__##name() at guarded tracepoint call sites

In reply to Steven Rostedt

From: "Vineeth Pillai (Google)" <[email protected]>

Replace trace_damos_stat_after_apply_interval() with trace_call__damos_stat_after_apply_interval() at a site already guarded by an early return when !trace_damos_stat_after_apply_interval_enabled(), avoiding a redundant static_branch_unlikely() re-evaluation inside the tracepoint.

---
 mm/damon/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/core.c +1 -1
index c1d1091d307e..6ed6ad240ed9 100644
@@ -2347,7 +2347,7 @@ static void damos_trace_stat(struct damon_ctx *c, struct damos *s)
 			break;
 		sidx++;
 	}
-	trace_damos_stat_after_apply_interval(cidx, sidx, &s->stat);
+	trace_call__damos_stat_after_apply_interval(cidx, sidx, &s->stat);
 }
 
 static void kdamond_apply_schemes(struct damon_ctx *c)
Signature · 1 line
2.51.0
#13 lore raw

PATCH 13/13 tracing: Move snapshot code out of trace.c and into trace_snapshot.c

In reply to Steven Rostedt

From: Steven Rostedt <[email protected]>

The trace.c file was a dumping ground for most tracing code. Start organizing it better by moving various functions out into their own files. Move all the snapshot code, including the max trace code into its own trace_snapshot.c file.

---
 include/linux/ftrace.h        |    2 +-
 kernel/trace/Makefile         |    1 +
 kernel/trace/trace.c          | 1274 ++-------------------------------
 kernel/trace/trace.h          |  105 ++-
 kernel/trace/trace_snapshot.c | 1067 +++++++++++++++++++++++++++
 5 files changed, 1230 insertions(+), 1219 deletions(-)
 create mode 100644 kernel/trace/trace_snapshot.c
include/linux/ftrace.h +1 -1
index c242fe49af4c..28b30c6f1031 100644
@@ -31,7 +31,7 @@
 #define ARCH_SUPPORTS_FTRACE_OPS 0
 #endif
 
-#ifdef CONFIG_TRACING
+#ifdef CONFIG_TRACER_SNAPSHOT
 extern void ftrace_boot_snapshot(void);
 #else
 static inline void ftrace_boot_snapshot(void) { }
kernel/trace/Makefile +1 -0
index 04096c21d06b..83aeb5c77008 100644
@@ -69,6 +69,7 @@ obj-$(CONFIG_TRACING) += trace_seq.o
 obj-$(CONFIG_TRACING) += trace_stat.o
 obj-$(CONFIG_TRACING) += trace_printk.o
 obj-$(CONFIG_TRACING) += trace_pid.o
+obj-$(CONFIG_TRACER_SNAPSHOT) += trace_snapshot.o
 obj-$(CONFIG_TRACING) += 	pid_list.o
 obj-$(CONFIG_TRACING_MAP) += tracing_map.o
 obj-$(CONFIG_PREEMPTIRQ_DELAY_TEST) += preemptirq_delay_test.o
kernel/trace/trace.c +64 -1210

1,519 lines not on this page · raw message

kernel/trace/trace.h +97 -8

169 lines not on this page · raw message

kernel/trace/trace_snapshot.c new file +1067 -0

1,067 lines not on this page · raw message

Signature · 1 line
2.51.0