Skip to contentSkip to conversation

tracing: Updates for 5.20

PATCH In review Steven Rostedt 4 participants 36 messages Jul 14, 2022 – Jul 24, 2022

Subsystems (22)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: Updates for 5.20

Linyu Yuan (4):
tracing: eprobe: Add missing log index
tracing: eprobe: Remove duplicate is_good_name() operation
tracing: Auto generate event name when creating a group of events selftests/ftrace: Add test case for GRP/ only input

Steven Rostedt (Google) (17):
tracing: devlink: Use static array for string in devlink_trap_report even tracing/ipv4/ipv6: Use static array for name field in fib*_lookup_table event
neighbor: tracing: Have neigh_create event use __string() tracing/events: Add __vstring() and __assign_vstr() helper macros tracing/IB/hfi1: Use the new __vstring() helper
tracing/ath: Use the new __vstring() helper
tracing/brcm: Use the new __vstring() helper
tracing/iwlwifi: Use the new __vstring() helper
usb: chipidea: tracing: Use the new __vstring() helper
xhci: tracing: Use the new __vstring() helper
USB: mtu3: tracing: Use the new __vstring() helper
usb: musb: tracing: Use the new __vstring() helper
scsi: iscsi: tracing: Use the new __vstring() helper
scsi: qla2xxx: tracing: Use the new __vstring() helper
batman-adv: tracing: Use the new __vstring() helper
mac80211: tracing: Use the new __vstring() helper selftests/kprobe: Do not test for GRP/ without event failures

Xiang wangx (1):
tracing/user_events: Fix syntax errors in comments

Zheng Yejian (1):
tracing/histograms: Simplify create_hist_fields()

----

 Documentation/trace/kprobetrace.rst                |  8 +++----
 Documentation/trace/uprobetracer.rst               |  8 +++----
 drivers/infiniband/hw/hfi1/trace_dbg.h             |  8 ++-----
 drivers/net/wireless/ath/ath10k/trace.h            | 14 ++++-------
 drivers/net/wireless/ath/ath11k/trace.h            |  7 ++----
 drivers/net/wireless/ath/ath6kl/trace.h            | 14 ++++-------
 drivers/net/wireless/ath/trace.h                   |  7 ++----
 drivers/net/wireless/ath/wil6210/trace.h           |  7 ++----
 .../broadcom/brcm80211/brcmfmac/tracepoint.h       | 12 ++++------
 .../brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h  | 12 ++++------
 .../net/wireless/intel/iwlwifi/iwl-devtrace-msg.h  | 12 ++++------
 drivers/usb/chipidea/trace.h                       |  4 ++--
 drivers/usb/host/xhci-trace.h                      |  4 ++--
 drivers/usb/mtu3/mtu3_trace.h                      |  4 ++--
 drivers/usb/musb/musb_trace.h                      |  4 ++--
 include/linux/trace_events.h                       | 18 ++++++++++++++
 include/trace/events/devlink.h                     |  7 +++---
 include/trace/events/fib.h                         |  6 ++---
 include/trace/events/fib6.h                        |  8 +++----
 include/trace/events/iscsi.h                       |  4 ++--
 include/trace/events/neigh.h                       |  2 +-
 include/trace/events/qla.h                         |  4 ++--
 include/trace/stages/stage1_struct_define.h        |  3 +++
 include/trace/stages/stage2_data_offsets.h         |  3 +++
 include/trace/stages/stage4_event_fields.h         |  3 +++
 include/trace/stages/stage5_get_offsets.h          |  4 ++++
 include/trace/stages/stage6_event_callback.h       |  7 ++++++
 kernel/trace/trace.c                               |  8 +++----
 kernel/trace/trace_dynevent.c                      |  2 +-
 kernel/trace/trace_eprobe.c                        | 28 +++++++++++-----------
 kernel/trace/trace_events_hist.c                   |  5 ++--
 kernel/trace/trace_events_user.c                   |  2 +-
 kernel/trace/trace_kprobe.c                        | 16 ++++++++-----
 kernel/trace/trace_probe.c                         |  4 ++++
 kernel/trace/trace_uprobe.c                        | 12 ++++++----
 net/batman-adv/trace.h                             |  7 ++----
 net/mac80211/trace_msg.h                           |  6 ++---
 .../ftrace/test.d/dynevent/add_remove_eprobe.tc    |  9 ++++++-
 .../ftrace/test.d/dynevent/add_remove_kprobe.tc    |  7 ++++++
 .../ftrace/test.d/kprobe/kprobe_syntax_errors.tc   |  1 -
 40 files changed, 160 insertions(+), 141 deletions(-)
author maintainer
#1 lore raw

PATCH 1/23 tracing/user_events: Fix syntax errors in comments

From: Xiang wangx <[email protected]>

Delete the redundant word 'have'.

---
 kernel/trace/trace_events_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_user.c +1 -1
index 706e1686b5eb..a6621c52ce45 100644
@@ -567,7 +567,7 @@ static int user_event_set_call_visible(struct user_event *user, bool visible)
 	 * to allow user_event files to be less locked down. The extreme case
 	 * being "other" has read/write access to user_events_data/status.
 	 *
-	 * When not locked down, processes may not have have permissions to
+	 * When not locked down, processes may not have permissions to
 	 * add/remove calls themselves to tracefs. We need to temporarily
 	 * switch to root file permission to allow for this scenario.
 	 */
Signature · 1 line
2.35.1
author maintainer
#2 lore raw

PATCH 2/23 tracing/histograms: Simplify create_hist_fields()

In reply to Steven Rostedt

From: Zheng Yejian <[email protected]>

When I look into implements of create_hist_fields(), I think there can be following two simplifications:
1. If something wrong happened in parse_var_defs(), free_var_defs() would

     have been called in it, so no need goto free again after calling it;

2. After calling create_key_fields(), regardless of the value of 'ret', it then always runs into 'out: ', so the judge of 'ret' is redundant.

---
 kernel/trace/trace_events_hist.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/trace/trace_events_hist.c +2 -3
index e87a46794079..fdf784620c28 100644
@@ -4455,7 +4455,7 @@ static int create_hist_fields(struct hist_trigger_data *hist_data,
 
 	ret = parse_var_defs(hist_data);
 	if (ret)
-		goto out;
+		return ret;
 
 	ret = create_val_fields(hist_data, file);
 	if (ret)
@@ -4466,8 +4466,7 @@ static int create_hist_fields(struct hist_trigger_data *hist_data,
 		goto out;
 
 	ret = create_key_fields(hist_data, file);
-	if (ret)
-		goto out;
+
  out:
 	free_var_defs(hist_data);
 
Signature · 1 line
2.35.1
author maintainer
#3 lore raw

PATCH 3/23 tracing: devlink: Use static array for string in devlink_trap_report even

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

The trace event devlink_trap_report uses the __dynamic_array() macro to determine the size of the input_dev_name field. This is because it needs to test the dev field for NULL, and will use "NULL" if it is. But it also has the size of the dynamic array as a fixed IFNAMSIZ bytes. This defeats the purpose of the dynamic array, as this will reserve that amount of bytes on the ring buffer, and to make matters worse, it will even save that size in the event as the event expects it to be dynamic (for which it is not).

Since IFNAMSIZ is just 16 bytes, just make it a static array and this will remove the meta data from the event that records the size.

---
 include/trace/events/devlink.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
include/trace/events/devlink.h +3 -4
index 2814f188d98c..24969184c534 100644
@@ -186,7 +186,7 @@ TRACE_EVENT(devlink_trap_report,
 		__string(driver_name, devlink_to_dev(devlink)->driver->name)
 		__string(trap_name, metadata->trap_name)
 		__string(trap_group_name, metadata->trap_group_name)
-		__dynamic_array(char, input_dev_name, IFNAMSIZ)
+		__array(char, input_dev_name, IFNAMSIZ)
 	),
 
 	TP_fast_assign(
@@ -197,15 +197,14 @@ TRACE_EVENT(devlink_trap_report,
 		__assign_str(driver_name, devlink_to_dev(devlink)->driver->name);
 		__assign_str(trap_name, metadata->trap_name);
 		__assign_str(trap_group_name, metadata->trap_group_name);
-		__assign_str(input_dev_name,
-			     (input_dev ? input_dev->name : "NULL"));
+		strscpy(__entry->input_dev_name, input_dev ? input_dev->name : "NULL", IFNAMSIZ);
 	),
 
 	TP_printk("bus_name=%s dev_name=%s driver_name=%s trap_name=%s "
 		  "trap_group_name=%s input_dev_name=%s", __get_str(bus_name),
 		  __get_str(dev_name), __get_str(driver_name),
 		  __get_str(trap_name), __get_str(trap_group_name),
-		  __get_str(input_dev_name))
+		  __entry->input_dev_name)
 );
 
 #endif /* _TRACE_DEVLINK_H */
Signature · 1 line
2.35.1
Reviewed-by Tested-by on v1 3/23
#4 lore raw

Re: [for-next][PATCH 03/23] tracing: devlink: Use static array for string in devlink_trap_report even

Quoted 16 lines · Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

The trace event devlink_trap_report uses the __dynamic_array() macro to determine the size of the input_dev_name field. This is because it needs to test the dev field for NULL, and will use "NULL" if it is. But it also has the size of the dynamic array as a fixed IFNAMSIZ bytes. This defeats the purpose of the dynamic array, as this will reserve that amount of bytes on the ring buffer, and to make matters worse, it will even save that size in the event as the event expects it to be dynamic (for which it is not).

Since IFNAMSIZ is just 16 bytes, just make it a static array and this will remove the meta data from the event that records the size.

Quoted 8 lines

On the off chance that my tags weren't omitted on purpose:

s/even/event/ in subject

author maintainer
#5 lore raw

Re: [for-next][PATCH 03/23] tracing: devlink: Use static array for string in devlink_trap_report even

Quoted 1 line · On Thu, 14 Jul 2022 21:40:40 +0300 Ido Schimmel <[email protected]> wrote:

On the off chance that my tags weren't omitted on purpose:

Ah, I probably pulled it in from my patchwork before you sent the tags. I usually let my internal patchwork add them for me. So, it was not on purpose.

It's also a reason I post to the mailing list before I push to linux-next. In case I missed anything.

Quoted 3 lines

Will add. Thanks!

Quoted 2 lines

s/even/event/ in subject

I'll fix that too.

-- Steve

author maintainer
#6 lore raw

PATCH 4/23 tracing/ipv4/ipv6: Use static array for name field in fib*_lookup_table event

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

The fib_lookup_table and fib6_lookup_table events declare name as a dynamic_array, but also give it a fixed size, which defeats the purpose of the dynamic array, especially since the dynamic array also includes meta data in the event to specify its size.

Since the size of the name is at most 16 bytes (defined by IFNAMSIZ), it is not worth spending the effort to determine the size of the string.

Just use a fixed size array and copy into it. This will save 4 bytes that are used for the meta data that saves the size and position of a dynamic array, and even slightly speed up the event processing.

---
 include/trace/events/fib.h  | 6 +++---
 include/trace/events/fib6.h | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
include/trace/events/fib.h +3 -3
index 6f2a4dc35e37..c2300c407f58 100644
@@ -32,7 +32,7 @@ TRACE_EVENT(fib_table_lookup,
 		__array(	__u8,	gw6,	16	)
 		__field(	u16,	sport		)
 		__field(	u16,	dport		)
-		__dynamic_array(char,  name,   IFNAMSIZ )
+		__array(char,  name,   IFNAMSIZ )
 	),
 
 	TP_fast_assign(
@@ -66,7 +66,7 @@ TRACE_EVENT(fib_table_lookup,
 		}
 
 		dev = nhc ? nhc->nhc_dev : NULL;
-		__assign_str(name, dev ? dev->name : "-");
+		strlcpy(__entry->name, dev ? dev->name : "-", IFNAMSIZ);
 
 		if (nhc) {
 			if (nhc->nhc_gw_family == AF_INET) {
@@ -95,7 +95,7 @@ TRACE_EVENT(fib_table_lookup,
 		  __entry->tb_id, __entry->oif, __entry->iif, __entry->proto,
 		  __entry->src, __entry->sport, __entry->dst, __entry->dport,
 		  __entry->tos, __entry->scope, __entry->flags,
-		  __get_str(name), __entry->gw4, __entry->gw6, __entry->err)
+		  __entry->name, __entry->gw4, __entry->gw6, __entry->err)
 );
 #endif /* _TRACE_FIB_H */
 
include/trace/events/fib6.h +4 -4
index c6abdcc77c12..6e821eb79450 100644
@@ -31,7 +31,7 @@ TRACE_EVENT(fib6_table_lookup,
 		__field(        u16,	dport		)
 		__field(        u8,	proto		)
 		__field(        u8,	rt_type		)
-		__dynamic_array(	char,	name,	IFNAMSIZ )
+		__array(		char,	name,	IFNAMSIZ )
 		__array(		__u8,	gw,	16	 )
 	),
 
@@ -63,9 +63,9 @@ TRACE_EVENT(fib6_table_lookup,
 		}
 
 		if (res->nh && res->nh->fib_nh_dev) {
-			__assign_str(name, res->nh->fib_nh_dev);
+			strlcpy(__entry->name, res->nh->fib_nh_dev->name, IFNAMSIZ);
 		} else {
-			__assign_str(name, "-");
+			strcpy(__entry->name, "-");
 		}
 		if (res->f6i == net->ipv6.fib6_null_entry) {
 			struct in6_addr in6_zero = {};
@@ -83,7 +83,7 @@ TRACE_EVENT(fib6_table_lookup,
 		  __entry->tb_id, __entry->oif, __entry->iif, __entry->proto,
 		  __entry->src, __entry->sport, __entry->dst, __entry->dport,
 		  __entry->tos, __entry->scope, __entry->flags,
-		  __get_str(name), __entry->gw, __entry->err)
+		  __entry->name, __entry->gw, __entry->err)
 );
 
 #endif /* _TRACE_FIB6_H */
Signature · 1 line
2.35.1
author maintainer
#7 lore raw

PATCH 5/23 neighbor: tracing: Have neigh_create event use __string()

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

The dev field of the neigh_create event uses __dynamic_array() with a fixed size, which defeats the purpose of __dynamic_array(). Looking at the logic, as it already uses __assign_str(), just use the same logic in __string to create the size needed. It appears that because "dev" can be NULL, it needs the check. But __string() can have the same checks as __assign_str() so use them there too.

---
 include/trace/events/neigh.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/events/neigh.h +1 -1
index 62bb17516713..5eaa1fa99171 100644
@@ -30,7 +30,7 @@ TRACE_EVENT(neigh_create,
 
 	TP_STRUCT__entry(
 		__field(u32, family)
-		__dynamic_array(char,  dev,   IFNAMSIZ )
+		__string(dev, dev ? dev->name : "NULL")
 		__field(int, entries)
 		__field(u8, created)
 		__field(u8, gc_exempt)
Signature · 1 line
2.35.1
author maintainer
#8 lore raw

PATCH 6/23 tracing/events: Add __vstring() and __assign_vstr() helper macros

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

There's several places that open code the following logic:

TP_STRUCT__entry(__dynamic_array(char, msg, MSG_MAX)), TP_fast_assign(vsnprintf(__get_str(msg), MSG_MAX, vaf->fmt, *vaf->va);)

To load a string created by variable array va_list.

The main issue with this approach is that "MSG_MAX" usage in the __dynamic_array() portion. That actually just reserves the MSG_MAX in the event, and even wastes space because there's dynamic meta data also saved in the event to denote the offset and size of the dynamic array. It would have been better to just use a static __array() field.

Instead, create __vstring() and __assign_vstr() that work like __string and __assign_str() but instead of taking a destination string to copy, take a format string and a va_list pointer and fill in the values.

It uses the helper:

#define __trace_event_vstr_len(fmt, va) \

 ({						\
	va_list __ap;				\
	int __ret;				\
						\
	va_copy(__ap, *(va));			\
	__ret = vsnprintf(NULL, 0, fmt, __ap);	\
	va_end(__ap);				\
						\
	min(__ret, TRACE_EVENT_STR_MAX);	\

})

To figure out the length to store the string. It may be slightly slower as it needs to run the vsnprintf() twice, but it now saves space on the ring buffer.

Cc Dennis Dalessandro <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Leon Romanovsky <[email protected]>
Cc Kalle Valo <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Arend van Spriel <[email protected]>
Cc Franky Lin <[email protected]>
Cc Hante Meuleman <[email protected]>
Cc Gregory Greenman <[email protected]>
Cc Peter Chen <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Mathias Nyman <[email protected]>
Cc Chunfeng Yun <[email protected]>
Cc Bin Liu <[email protected]>
Cc Marek Lindner <[email protected]>
Cc Simon Wunderlich <[email protected]>
Cc Antonio Quartulli <[email protected]>
Cc Sven Eckelmann <[email protected]>
Cc Johannes Berg <[email protected]>
Cc Jim Cromie <[email protected]>
---
 include/linux/trace_events.h                 | 18 ++++++++++++++++++
 include/trace/stages/stage1_struct_define.h  |  3 +++
 include/trace/stages/stage2_data_offsets.h   |  3 +++
 include/trace/stages/stage4_event_fields.h   |  3 +++
 include/trace/stages/stage5_get_offsets.h    |  4 ++++
 include/trace/stages/stage6_event_callback.h |  7 +++++++
 6 files changed, 38 insertions(+)
include/linux/trace_events.h +18 -0
index e6e95a9f07a5..e6f8ba52a958 100644
@@ -916,6 +916,24 @@ perf_trace_buf_submit(void *raw_data, int size, int rctx, u16 type,
 
 #endif
 
+#define TRACE_EVENT_STR_MAX	512
+
+/*
+ * gcc warns that you can not use a va_list in an inlined
+ * function. But lets me make it into a macro :-/
+ */
+#define __trace_event_vstr_len(fmt, va)		\
+({						\
+	va_list __ap;				\
+	int __ret;				\
+						\
+	va_copy(__ap, *(va));			\
+	__ret = vsnprintf(NULL, 0, fmt, __ap);	\
+	va_end(__ap);				\
+						\
+	min(__ret, TRACE_EVENT_STR_MAX);	\
+})
+
 #endif /* _LINUX_TRACE_EVENT_H */
 
 /*
include/trace/stages/stage1_struct_define.h +3 -0
index a16783419687..1b7bab60434c 100644
@@ -26,6 +26,9 @@
 #undef __string_len
 #define __string_len(item, src, len) __dynamic_array(char, item, -1)
 
+#undef __vstring
+#define __vstring(item, fmt, ap) __dynamic_array(char, item, -1)
+
 #undef __bitmask
 #define __bitmask(item, nr_bits) __dynamic_array(char, item, -1)
 
include/trace/stages/stage2_data_offsets.h +3 -0
index 42fd1e8813ec..1b7a8f764fdd 100644
@@ -32,6 +32,9 @@
 #undef __string_len
 #define __string_len(item, src, len) __dynamic_array(char, item, -1)
 
+#undef __vstring
+#define __vstring(item, fmt, ap) __dynamic_array(char, item, -1)
+
 #undef __bitmask
 #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
 
include/trace/stages/stage4_event_fields.h +3 -0
index e80cdc397a43..c3790ec7a453 100644
@@ -38,6 +38,9 @@
 #undef __string_len
 #define __string_len(item, src, len) __dynamic_array(char, item, -1)
 
+#undef __vstring
+#define __vstring(item, fmt, ap) __dynamic_array(char, item, -1)
+
 #undef __bitmask
 #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
 
include/trace/stages/stage5_get_offsets.h +4 -0
index 7ee5931300e6..fba4c24ed9e6 100644
@@ -39,6 +39,10 @@
 #undef __string_len
 #define __string_len(item, src, len) __dynamic_array(char, item, (len) + 1)
 
+#undef __vstring
+#define __vstring(item, fmt, ap) __dynamic_array(char, item,		\
+		      __trace_event_vstr_len(fmt, ap))
+
 #undef __rel_dynamic_array
 #define __rel_dynamic_array(type, item, len)				\
 	__item_length = (len) * sizeof(type);				\
include/trace/stages/stage6_event_callback.h +7 -0
index e1724f73594b..0f51f6b3ab70 100644
@@ -24,6 +24,9 @@
 #undef __string_len
 #define __string_len(item, src, len) __dynamic_array(char, item, -1)
 
+#undef __vstring
+#define __vstring(item, fmt, ap) __dynamic_array(char, item, -1)
+
 #undef __assign_str
 #define __assign_str(dst, src)						\
 	strcpy(__get_str(dst), (src) ? (const char *)(src) : "(null)");
@@ -35,6 +38,10 @@
 		__get_str(dst)[len] = '\0';				\
 	} while(0)
 
+#undef __assign_vstr
+#define __assign_vstr(dst, fmt, va)					\
+	vsnprintf(__get_str(dst), TRACE_EVENT_STR_MAX, fmt, *(va))
+
 #undef __bitmask
 #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1)
 
Signature · 1 line
2.35.1
author maintainer
#9 lore raw

PATCH 7/23 tracing/IB/hfi1: Use the new __vstring() helper

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.

Cc Dennis Dalessandro <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc Leon Romanovsky <[email protected]>
---
 drivers/infiniband/hw/hfi1/trace_dbg.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/infiniband/hw/hfi1/trace_dbg.h +2 -6
index 707f1053f0b7..582b6f68df3d 100644
@@ -26,14 +26,10 @@ DECLARE_EVENT_CLASS(hfi1_trace_template,
 		    TP_PROTO(const char *function, struct va_format *vaf),
 		    TP_ARGS(function, vaf),
 		    TP_STRUCT__entry(__string(function, function)
-				     __dynamic_array(char, msg, MAX_MSG_LEN)
+				     __vstring(msg, vaf->fmt, vaf->va)
 				     ),
 		    TP_fast_assign(__assign_str(function, function);
-				   WARN_ON_ONCE(vsnprintf
-						(__get_dynamic_array(msg),
-						 MAX_MSG_LEN, vaf->fmt,
-						 *vaf->va) >=
-						MAX_MSG_LEN);
+				   __assign_vstr(msg, vaf->fmt, vaf->va);
 				   ),
 		    TP_printk("(%s) %s",
 			      __get_str(function),
Signature · 1 line
2.35.1
author maintainer
#10 lore raw

PATCH 8/23 tracing/ath: Use the new __vstring() helper

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.

---
 drivers/net/wireless/ath/ath10k/trace.h  | 14 ++++----------
 drivers/net/wireless/ath/ath11k/trace.h  |  7 ++-----
 drivers/net/wireless/ath/ath6kl/trace.h  | 14 ++++----------
 drivers/net/wireless/ath/trace.h         |  7 ++-----
 drivers/net/wireless/ath/wil6210/trace.h |  7 ++-----
 5 files changed, 14 insertions(+), 35 deletions(-)
drivers/net/wireless/ath/ath10k/trace.h +4 -10
index 4714c86bb501..64e7a767d963 100644
@@ -52,15 +52,12 @@ DECLARE_EVENT_CLASS(ath10k_log_event,
 	TP_STRUCT__entry(
 		__string(device, dev_name(ar->dev))
 		__string(driver, dev_driver_string(ar->dev))
-		__dynamic_array(char, msg, ATH10K_MSG_MAX)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__assign_str(device, dev_name(ar->dev));
 		__assign_str(driver, dev_driver_string(ar->dev));
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       ATH10K_MSG_MAX,
-				       vaf->fmt,
-				       *vaf->va) >= ATH10K_MSG_MAX);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk(
 		"%s %s %s",
@@ -92,16 +89,13 @@ TRACE_EVENT(ath10k_log_dbg,
 		__string(device, dev_name(ar->dev))
 		__string(driver, dev_driver_string(ar->dev))
 		__field(unsigned int, level)
-		__dynamic_array(char, msg, ATH10K_MSG_MAX)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__assign_str(device, dev_name(ar->dev));
 		__assign_str(driver, dev_driver_string(ar->dev));
 		__entry->level = level;
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       ATH10K_MSG_MAX,
-				       vaf->fmt,
-				       *vaf->va) >= ATH10K_MSG_MAX);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk(
 		"%s %s %s",
drivers/net/wireless/ath/ath11k/trace.h +2 -5
index a02e54735e88..76560587bea0 100644
@@ -126,15 +126,12 @@ DECLARE_EVENT_CLASS(ath11k_log_event,
 	TP_STRUCT__entry(
 		__string(device, dev_name(ab->dev))
 		__string(driver, dev_driver_string(ab->dev))
-		__dynamic_array(char, msg, ATH11K_MSG_MAX)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__assign_str(device, dev_name(ab->dev));
 		__assign_str(driver, dev_driver_string(ab->dev));
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       ATH11K_MSG_MAX,
-				       vaf->fmt,
-				       *vaf->va) >= ATH11K_MSG_MAX);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk(
 		"%s %s %s",
drivers/net/wireless/ath/ath6kl/trace.h +4 -10
index a3d3740419eb..231a94769ddb 100644
@@ -253,13 +253,10 @@ DECLARE_EVENT_CLASS(ath6kl_log_event,
 	TP_PROTO(struct va_format *vaf),
 	TP_ARGS(vaf),
 	TP_STRUCT__entry(
-		__dynamic_array(char, msg, ATH6KL_MSG_MAX)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       ATH6KL_MSG_MAX,
-				       vaf->fmt,
-				       *vaf->va) >= ATH6KL_MSG_MAX);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s", __get_str(msg))
 );
@@ -284,14 +281,11 @@ TRACE_EVENT(ath6kl_log_dbg,
 	TP_ARGS(level, vaf),
 	TP_STRUCT__entry(
 		__field(unsigned int, level)
-		__dynamic_array(char, msg, ATH6KL_MSG_MAX)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__entry->level = level;
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       ATH6KL_MSG_MAX,
-				       vaf->fmt,
-				       *vaf->va) >= ATH6KL_MSG_MAX);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s", __get_str(msg))
 );
drivers/net/wireless/ath/trace.h +2 -5
index ba711644d27e..9935cf475b6d 100644
@@ -40,16 +40,13 @@ TRACE_EVENT(ath_log,
 	    TP_STRUCT__entry(
 		    __string(device, wiphy_name(wiphy))
 		    __string(driver, KBUILD_MODNAME)
-		    __dynamic_array(char, msg, ATH_DBG_MAX_LEN)
+		    __vstring(msg, vaf->fmt, vaf->va)
 	    ),
 
 	    TP_fast_assign(
 		    __assign_str(device, wiphy_name(wiphy));
 		    __assign_str(driver, KBUILD_MODNAME);
-		    WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-					   ATH_DBG_MAX_LEN,
-					   vaf->fmt,
-					   *vaf->va) >= ATH_DBG_MAX_LEN);
+		    __assign_vstr(msg, vaf->fmt, vaf->va);
 	    ),
 
 	    TP_printk(
drivers/net/wireless/ath/wil6210/trace.h +2 -5
index 11c989e95880..201f44612c31 100644
@@ -70,13 +70,10 @@ DECLARE_EVENT_CLASS(wil6210_log_event,
 	TP_PROTO(struct va_format *vaf),
 	TP_ARGS(vaf),
 	TP_STRUCT__entry(
-		__dynamic_array(char, msg, WIL6210_MSG_MAX)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       WIL6210_MSG_MAX,
-				       vaf->fmt,
-				       *vaf->va) >= WIL6210_MSG_MAX);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s", __get_str(msg))
 );
Signature · 1 line
2.35.1
author maintainer
#11 lore raw

PATCH 9/23 tracing/brcm: Use the new __vstring() helper

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.

Cc Arend van Spriel <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Franky Lin <[email protected]>
Cc Hante Meuleman <[email protected]>
Cc Kalle Valo <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
---
 .../broadcom/brcm80211/brcmfmac/tracepoint.h         | 12 ++++--------
 .../brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h    | 12 ++++--------
 2 files changed, 8 insertions(+), 16 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.h +4 -8
index 338c66d0c5f8..5a139d7ed47a 100644
@@ -33,13 +33,11 @@ TRACE_EVENT(brcmf_err,
 	TP_ARGS(func, vaf),
 	TP_STRUCT__entry(
 		__string(func, func)
-		__dynamic_array(char, msg, MAX_MSG_LEN)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__assign_str(func, func);
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       MAX_MSG_LEN, vaf->fmt,
-				       *vaf->va) >= MAX_MSG_LEN);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s: %s", __get_str(func), __get_str(msg))
 );
@@ -50,14 +48,12 @@ TRACE_EVENT(brcmf_dbg,
 	TP_STRUCT__entry(
 		__field(u32, level)
 		__string(func, func)
-		__dynamic_array(char, msg, MAX_MSG_LEN)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__entry->level = level;
 		__assign_str(func, func);
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       MAX_MSG_LEN, vaf->fmt,
-				       *vaf->va) >= MAX_MSG_LEN);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s: %s", __get_str(func), __get_str(msg))
 );
drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h +4 -8
index 0e8a69ab909f..488456420353 100644
@@ -28,12 +28,10 @@ DECLARE_EVENT_CLASS(brcms_msg_event,
 	TP_PROTO(struct va_format *vaf),
 	TP_ARGS(vaf),
 	TP_STRUCT__entry(
-		__dynamic_array(char, msg, MAX_MSG_LEN)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       MAX_MSG_LEN, vaf->fmt,
-				       *vaf->va) >= MAX_MSG_LEN);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s", __get_str(msg))
 );
@@ -64,14 +62,12 @@ TRACE_EVENT(brcms_dbg,
 	TP_STRUCT__entry(
 		__field(u32, level)
 		__string(func, func)
-		__dynamic_array(char, msg, MAX_MSG_LEN)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__entry->level = level;
 		__assign_str(func, func);
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       MAX_MSG_LEN, vaf->fmt,
-				       *vaf->va) >= MAX_MSG_LEN);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s: %s", __get_str(func), __get_str(msg))
 );
Signature · 1 line
2.35.1
author maintainer
#12 lore raw

PATCH 10/23 tracing/iwlwifi: Use the new __vstring() helper

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.

Cc Gregory Greenman <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Kalle Valo <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
---
 .../net/wireless/intel/iwlwifi/iwl-devtrace-msg.h    | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/net/wireless/intel/iwlwifi/iwl-devtrace-msg.h +4 -8
index 7dd70011fd1e..1d6c292cf545 100644
@@ -18,12 +18,10 @@ DECLARE_EVENT_CLASS(iwlwifi_msg_event,
 	TP_PROTO(struct va_format *vaf),
 	TP_ARGS(vaf),
 	TP_STRUCT__entry(
-		__dynamic_array(char, msg, MAX_MSG_LEN)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       MAX_MSG_LEN, vaf->fmt,
-				       *vaf->va) >= MAX_MSG_LEN);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s", __get_str(msg))
 );
@@ -55,14 +53,12 @@ TRACE_EVENT(iwlwifi_dbg,
 	TP_STRUCT__entry(
 		__field(u32, level)
 		__string(function, function)
-		__dynamic_array(char, msg, MAX_MSG_LEN)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__entry->level = level;
 		__assign_str(function, function);
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       MAX_MSG_LEN, vaf->fmt,
-				       *vaf->va) >= MAX_MSG_LEN);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s", __get_str(msg))
 );
Signature · 1 line
2.35.1
author maintainer
#13 lore raw

PATCH 11/23 usb: chipidea: tracing: Use the new __vstring() helper

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.

Cc Peter Chen <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/usb/chipidea/trace.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/chipidea/trace.h +2 -2
index 1601fd86c4c1..ca0e65b48f0a 100644
@@ -28,11 +28,11 @@ TRACE_EVENT(ci_log,
 	TP_ARGS(ci, vaf),
 	TP_STRUCT__entry(
 		__string(name, dev_name(ci->dev))
-		__dynamic_array(char, msg, CHIPIDEA_MSG_MAX)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__assign_str(name, dev_name(ci->dev));
-		vsnprintf(__get_str(msg), CHIPIDEA_MSG_MAX, vaf->fmt, *vaf->va);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s: %s", __get_str(name), __get_str(msg))
 );
Signature · 1 line
2.35.1
author maintainer
#14 lore raw

PATCH 12/23 xhci: tracing: Use the new __vstring() helper

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.

Cc Mathias Nyman <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/usb/host/xhci-trace.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-trace.h +2 -2
index a5da02077297..61e93a3540a7 100644
@@ -28,9 +28,9 @@
 DECLARE_EVENT_CLASS(xhci_log_msg,
 	TP_PROTO(struct va_format *vaf),
 	TP_ARGS(vaf),
-	TP_STRUCT__entry(__dynamic_array(char, msg, XHCI_MSG_MAX)),
+	TP_STRUCT__entry(__vstring(msg, vaf->fmt, vaf->va)),
 	TP_fast_assign(
-		vsnprintf(__get_str(msg), XHCI_MSG_MAX, vaf->fmt, *vaf->va);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s", __get_str(msg))
 );
Signature · 1 line
2.35.1
author maintainer
#15 lore raw

PATCH 13/23 USB: mtu3: tracing: Use the new __vstring() helper

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.

---
 drivers/usb/mtu3/mtu3_trace.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/mtu3/mtu3_trace.h +2 -2
index 1b897636daf2..ef3c17e2f8a6 100644
@@ -25,11 +25,11 @@ TRACE_EVENT(mtu3_log,
 	TP_ARGS(dev, vaf),
 	TP_STRUCT__entry(
 		__string(name, dev_name(dev))
-		__dynamic_array(char, msg, MTU3_MSG_MAX)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__assign_str(name, dev_name(dev));
-		vsnprintf(__get_str(msg), MTU3_MSG_MAX, vaf->fmt, *vaf->va);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s: %s", __get_str(name), __get_str(msg))
 );
Signature · 1 line
2.35.1
maintainer
#16 lore raw

Re: [for-next][PATCH 13/23] USB: mtu3: tracing: Use the new __vstring() helper

Hi Steven,

Quoted 44 lines · Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new
__vstring() helper that will use a va_list and only write enough of the
string into the ring buffer that is needed.

Link:
https://urldefense.com/v3/__https://lkml.kernel.org/r/[email protected]__;!!CTRNKA9wMg0ARbw!w8nx66BKDTtyusp5i2pyzOGNb-QyxIAWjoZwmSQY0zzor_rqvBgUm5__vKK98ApKcDic$

---
 drivers/usb/mtu3/mtu3_trace.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/mtu3/mtu3_trace.h +2 -2
index 1b897636daf2..ef3c17e2f8a6 100644
@@ -25,11 +25,11 @@ TRACE_EVENT(mtu3_log,
 	TP_ARGS(dev, vaf),
 	TP_STRUCT__entry(
 		__string(name, dev_name(dev))
-		__dynamic_array(char, msg, MTU3_MSG_MAX)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__assign_str(name, dev_name(dev));
-		vsnprintf(__get_str(msg), MTU3_MSG_MAX, vaf->fmt, *vaf-
 >va);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s: %s", __get_str(name), __get_str(msg))
Quoted 1 line

);

Can you help to remove macro "MTU3_MSG_MAX" and one blank line after it in this file, this macro is not used anymore after apply this patch.

Thanks a lot

author maintainer
#17 lore raw

Re: [for-next][PATCH 13/23] USB: mtu3: tracing: Use the new __vstring() helper

Quoted 2 lines · On Fri, 15 Jul 2022 14:32:05 +0800 Chunfeng Yun <[email protected]>…

Can you help to remove macro "MTU3_MSG_MAX" and one blank line after it in this file, this macro is not used anymore after apply this patch.

Care to send me a patch, and I'll just include it in my series?

-- Steve

maintainer
#18 lore raw

Re: [for-next][PATCH 13/23] USB: mtu3: tracing: Use the new __vstring() helper

Quoted 9 lines · Steven Rostedt
Quoted 4 lines · On Fri, 15 Jul 2022 14:32:05 +0800 Chunfeng Yun <[email protected]>…

Can you help to remove macro "MTU3_MSG_MAX" and one blank line after it
in this file, this macro is not used anymore after apply this patch.

Care to send me a patch, and I'll just include it in my series?

Seems no need add another patch, just modify this patch as below:

(quoted diff) +0 -0

b/drivers/usb/mtu3/mtu3_trace.h
index a09deae1146f..03d2a9bac27e 100644

drivers/usb/mtu3/mtu3_trace.h +1 -4
@@ -18,18 +18,16 @@
 
 #include "mtu3.h"
 
-#define MTU3_MSG_MAX   256
-
 TRACE_EVENT(mtu3_log,
        TP_PROTO(struct device *dev, struct va_format *vaf),
        TP_ARGS(dev, vaf),
        TP_STRUCT__entry(
                __string(name, dev_name(dev))
-               __dynamic_array(char, msg, MTU3_MSG_MAX)
+               __vstring(msg, vaf->fmt, vaf->va)
        ),
        TP_fast_assign(
                __assign_str(name, dev_name(dev));
-               vsnprintf(__get_str(msg), MTU3_MSG_MAX, vaf->fmt, *vaf-
Quoted 1 line

va);

+               __assign_vstr(msg, vaf->fmt, vaf->va);
        ),
        TP_printk("%s: %s", __get_str(name), __get_str(msg))

);

Quoted 1 line

remove below two lines
"
-#define MTU3_MSG_MAX 256
-
"
Thanks

Quoted 1 line

-- Steve

author maintainer
#19 lore raw

Re: [for-next][PATCH 13/23] USB: mtu3: tracing: Use the new __vstring() helper

Quoted 34 lines · On Tue, 19 Jul 2022 13:23:06 +0800 Chunfeng Yun <[email protected]>…
Quoted 1 line

Care to send me a patch, and I'll just include it in my series?

Seems no need add another patch, just modify this patch as below:

drivers/usb/mtu3/mtu3_trace.h +2 -4
index a09deae1146f..03d2a9bac27e 100644
@@ -18,18 +18,16 @@
 
 #include "mtu3.h"
 
-#define MTU3_MSG_MAX   256
-
 TRACE_EVENT(mtu3_log,
        TP_PROTO(struct device *dev, struct va_format *vaf),
        TP_ARGS(dev, vaf),
        TP_STRUCT__entry(
                __string(name, dev_name(dev))
-               __dynamic_array(char, msg, MTU3_MSG_MAX)
+               __vstring(msg, vaf->fmt, vaf->va)
        ),
        TP_fast_assign(
                __assign_str(name, dev_name(dev));
-               vsnprintf(__get_str(msg), MTU3_MSG_MAX, vaf->fmt, *vaf-
 >va);  
+               __assign_vstr(msg, vaf->fmt, vaf->va);
        ),
        TP_printk("%s: %s", __get_str(name), __get_str(msg))

);

Quoted 1 line

remove below two lines
"

drivers/usb/mtu3/mtu3_trace.h line 22

Quoted 2 lines
drivers/usb/mtu3/mtu3_trace.h +0 -2
-#define MTU3_MSG_MAX   256
-

Fine.

Even though I already pushed to linux-next, I did something I seldom do. I rebased my for-next branch and removed this patch.

I'll send a v2.

-- Steve

maintainer
#20 lore raw

Re: [for-next][PATCH 13/23] USB: mtu3: tracing: Use the new __vstring() helper

In reply to Steven Rostedt
Quoted 44 lines · Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new
__vstring() helper that will use a va_list and only write enough of the
string into the ring buffer that is needed.

Link:
https://urldefense.com/v3/__https://lkml.kernel.org/r/[email protected]__;!!CTRNKA9wMg0ARbw!w8nx66BKDTtyusp5i2pyzOGNb-QyxIAWjoZwmSQY0zzor_rqvBgUm5__vKK98ApKcDic$

---
 drivers/usb/mtu3/mtu3_trace.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/mtu3/mtu3_trace.h +2 -2
index 1b897636daf2..ef3c17e2f8a6 100644
@@ -25,11 +25,11 @@ TRACE_EVENT(mtu3_log,
 	TP_ARGS(dev, vaf),
 	TP_STRUCT__entry(
 		__string(name, dev_name(dev))
-		__dynamic_array(char, msg, MTU3_MSG_MAX)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__assign_str(name, dev_name(dev));
-		vsnprintf(__get_str(msg), MTU3_MSG_MAX, vaf->fmt, *vaf-
 >va);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s: %s", __get_str(name), __get_str(msg))
Quoted 1 line

);

After apply this patch, encounter an issue, please check it

irq/254-1120100-137 [000] d..1. 266.549473: mtu3_u2_common_isr:
(00000004) RESET
irq/254-1120100-137 [000] d..1. 266.629399: mtu3_log:
11201000.usb: link speed super-speed
irq/254-1120100-137 [000] d..1. 266.629662: mtu3_log:
11201000.usb: ep0_state SETUPr-speed
irq/254-1120100-137 [000] d..1. 266.629668: mtu3_handle_setup:
setup - 00 05 001c 0000 0000
irq/254-1120100-137 [000] d..1. 266.629722: mtu3_log:
11201000.usb: ep0_state SETUPr-speed

without this patch:
irq/254-1120100-135 [000] d..1. 1407.425550: mtu3_u2_common_isr:
(00000004) RESET
irq/254-1120100-135 [000] d..1. 1407.475295: mtu3_log:
11201000.usb: link speed super-speed
irq/254-1120100-135 [000] d..1. 1407.477469: mtu3_log:
11201000.usb: ep0_state SETUP
irq/254-1120100-135 [000] d..1. 1407.477476: mtu3_handle_setup:
setup - 00 05 001f 0000 0000
irq/254-1120100-135 [000] d..1. 1407.477518: mtu3_log:
11201000.usb: ep0_state SETUP

the second and third lines with this patch:
irq/254-1120100-137 [000] d..1. 266.629399: mtu3_log:
11201000.usb: link speed super-speed

irq/254-1120100-137 [000] d..1. 266.629662: mtu3_log:
11201000.usb: ep0_state SETUPr-speed

"r-speed" seems the remain of last log;

author maintainer
#21 lore raw

Re: [for-next][PATCH 13/23] USB: mtu3: tracing: Use the new __vstring() helper

Quoted 8 lines · On Fri, 15 Jul 2022 18:01:44 +0800 Chunfeng Yun <[email protected]>…

the second and third lines with this patch:
irq/254-1120100-137 [000] d..1. 266.629399: mtu3_log:
11201000.usb: link speed super-speed

irq/254-1120100-137 [000] d..1. 266.629662: mtu3_log:
11201000.usb: ep0_state SETUPr-speed

"r-speed" seems the remain of last log;

Thanks for testing! I'll investigate. (Another reason I didn't push to linux-next yet).

-- Steve

author maintainer
#22 lore raw

Re: [for-next][PATCH 13/23] USB: mtu3: tracing: Use the new __vstring() helper

In reply to Chunfeng Yun
Quoted 4 lines · On Fri, 15 Jul 2022 18:01:44 +0800 Chunfeng Yun <[email protected]>…

irq/254-1120100-137 [000] d..1. 266.629662: mtu3_log:
11201000.usb: ep0_state SETUPr-speed

"r-speed" seems the remain of last log;

I found an off-by-one bug in the vstring patch. I'll rebase, test and try again.

In the mean time, care to add this on top to make sure it's fixed?

Thanks!

-- Steve

include/linux/trace_events.h +10 -10
index e6f8ba52a958..b18759a673c6 100644
@@ -922,16 +922,16 @@ perf_trace_buf_submit(void *raw_data, int size, int rctx, u16 type,
  * gcc warns that you can not use a va_list in an inlined
  * function. But lets me make it into a macro :-/
  */
-#define __trace_event_vstr_len(fmt, va)		\
-({						\
-	va_list __ap;				\
-	int __ret;				\
-						\
-	va_copy(__ap, *(va));			\
-	__ret = vsnprintf(NULL, 0, fmt, __ap);	\
-	va_end(__ap);				\
-						\
-	min(__ret, TRACE_EVENT_STR_MAX);	\
+#define __trace_event_vstr_len(fmt, va)			\
+({							\
+	va_list __ap;					\
+	int __ret;					\
+							\
+	va_copy(__ap, *(va));				\
+	__ret = vsnprintf(NULL, 0, fmt, __ap) + 1;	\
+	va_end(__ap);					\
+							\
+	min(__ret, TRACE_EVENT_STR_MAX);		\
 })
 
 #endif /* _LINUX_TRACE_EVENT_H */
maintainer
#23 lore raw

Re: [for-next][PATCH 13/23] USB: mtu3: tracing: Use the new __vstring() helper

Quoted 35 lines · Steven Rostedt
Quoted 4 lines · On Fri, 15 Jul 2022 18:01:44 +0800 Chunfeng Yun <[email protected]>…

irq/254-1120100-137 [000] d..1. 266.629662: mtu3_log:
11201000.usb: ep0_state SETUPr-speed

"r-speed" seems the remain of last log;

I found an off-by-one bug in the vstring patch. I'll rebase, test and try
again.

In the mean time, care to add this on top to make sure it's fixed?

Thanks!

-- Steve

include/linux/trace_events.h +0 -7
index e6f8ba52a958..b18759a673c6 100644
@@ -922,16 +922,16 @@ perf_trace_buf_submit(void *raw_data, int size,
 int rctx, u16 type,
  * gcc warns that you can not use a va_list in an inlined
  * function. But lets me make it into a macro :-/
  */
-#define __trace_event_vstr_len(fmt, va)		\
-({						\
-	va_list __ap;				\
-	int __ret;				\
-						\
-	va_copy(__ap, *(va));			\
-	__ret = vsnprintf(NULL, 0, fmt, __ap);	\

include/linux/trace_events.h perf_trace_buf_submit(void *raw_data, int size, · line 932

Quoted 10 lines
include/linux/trace_events.h +7 -3
-	va_end(__ap);				\
-						\
-	min(__ret, TRACE_EVENT_STR_MAX);	\
+#define __trace_event_vstr_len(fmt, va)			\
+({							\
+	va_list __ap;					\
+	int __ret;					\
+							\
+	va_copy(__ap, *(va));				\
+	__ret = vsnprintf(NULL, 0, fmt, __ap) + 1;	\

It works fine now, thanks a lot

Quoted 6 lines
include/linux/trace_events.h +3 -0
+	va_end(__ap);					\
+							\
+	min(__ret, TRACE_EVENT_STR_MAX);		\
 })
 

#endif /* _LINUX_TRACE_EVENT_H */

author maintainer
#24 lore raw

PATCH 14/23 usb: musb: tracing: Use the new __vstring() helper

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.

Cc Bin Liu <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/usb/musb/musb_trace.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/musb/musb_trace.h +2 -2
index ec28b5716796..f246b14394c4 100644
@@ -28,11 +28,11 @@ TRACE_EVENT(musb_log,
 	TP_ARGS(musb, vaf),
 	TP_STRUCT__entry(
 		__string(name, dev_name(musb->controller))
-		__dynamic_array(char, msg, MUSB_MSG_MAX)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__assign_str(name, dev_name(musb->controller));
-		vsnprintf(__get_str(msg), MUSB_MSG_MAX, vaf->fmt, *vaf->va);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 	TP_printk("%s: %s", __get_str(name), __get_str(msg))
 );
Signature · 1 line
2.35.1
author maintainer
#25 lore raw

PATCH 15/23 scsi: iscsi: tracing: Use the new __vstring() helper

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.

Cc Fred Herard <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Martin K. Petersen <[email protected]>
---
 include/trace/events/iscsi.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/trace/events/iscsi.h +2 -2
index 87408faf6e4e..8ff2a3ca5d75 100644
@@ -26,12 +26,12 @@ DECLARE_EVENT_CLASS(iscsi_log_msg,
 
 	TP_STRUCT__entry(
 		__string(dname, 	dev_name(dev)		)
-		__dynamic_array(char,	msg, ISCSI_MSG_MAX	)
+		__vstring(msg,		vaf->fmt, vaf->va)
 	),
 
 	TP_fast_assign(
 		__assign_str(dname, dev_name(dev));
-		vsnprintf(__get_str(msg), ISCSI_MSG_MAX, vaf->fmt, *vaf->va);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 
 	TP_printk("%s: %s",__get_str(dname),  __get_str(msg)
Signature · 1 line
2.35.1
author maintainer
#26 lore raw

PATCH 16/23 scsi: qla2xxx: tracing: Use the new __vstring() helper

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.

Cc Bart Van Assche <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Martin K. Petersen <[email protected]>
---
 include/trace/events/qla.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/trace/events/qla.h +2 -2
index 5857cf682ee7..e7fd55e7dc3d 100644
@@ -22,11 +22,11 @@ DECLARE_EVENT_CLASS(qla_log_event,
 
 	TP_STRUCT__entry(
 		__string(buf, buf)
-		__dynamic_array(char, msg, QLA_MSG_MAX)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 	TP_fast_assign(
 		__assign_str(buf, buf);
-		vsnprintf(__get_str(msg), QLA_MSG_MAX, vaf->fmt, *vaf->va);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 
 	TP_printk("%s %s", __get_str(buf), __get_str(msg))
Signature · 1 line
2.35.1
author maintainer
#27 lore raw

PATCH 17/23 batman-adv: tracing: Use the new __vstring() helper

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.

Cc Marek Lindner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Simon Wunderlich <[email protected]>
Cc Antonio Quartulli <[email protected]>
Cc Sven Eckelmann <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
---
 net/batman-adv/trace.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
net/batman-adv/trace.h +2 -5
index d673ebdd0426..67d2a8a0196c 100644
@@ -40,16 +40,13 @@ TRACE_EVENT(batadv_dbg,
 	    TP_STRUCT__entry(
 		    __string(device, bat_priv->soft_iface->name)
 		    __string(driver, KBUILD_MODNAME)
-		    __dynamic_array(char, msg, BATADV_MAX_MSG_LEN)
+		    __vstring(msg, vaf->fmt, vaf->va)
 	    ),
 
 	    TP_fast_assign(
 		    __assign_str(device, bat_priv->soft_iface->name);
 		    __assign_str(driver, KBUILD_MODNAME);
-		    WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-					   BATADV_MAX_MSG_LEN,
-					   vaf->fmt,
-					   *vaf->va) >= BATADV_MAX_MSG_LEN);
+		    __assign_vstr(msg, vaf->fmt, vaf->va);
 	    ),
 
 	    TP_printk(
Signature · 1 line
2.35.1
maintainer
#28 lore raw

Re: [for-next][PATCH 17/23] batman-adv: tracing: Use the new __vstring() helper

Quoted 4 lines · On Thursday, 14 July 2022 18:43:13 CEST Steven Rostedt wrote:

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place).

Please also make sure to remove the define of BATADV_MAX_MSG_LEN

Kind regards,
Sven

[...]

Quoted 22 lines
net/batman-adv/trace.h +2 -5
@@ -40,16 +40,13 @@ TRACE_EVENT(batadv_dbg,
 	    TP_STRUCT__entry(
 		    __string(device, bat_priv->soft_iface->name)
 		    __string(driver, KBUILD_MODNAME)
-		    __dynamic_array(char, msg, BATADV_MAX_MSG_LEN)
+		    __vstring(msg, vaf->fmt, vaf->va)
 	    ),
 
 	    TP_fast_assign(
 		    __assign_str(device, bat_priv->soft_iface->name);
 		    __assign_str(driver, KBUILD_MODNAME);
-		    WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-					   BATADV_MAX_MSG_LEN,
-					   vaf->fmt,
-					   *vaf->va) >= BATADV_MAX_MSG_LEN);
+		    __assign_vstr(msg, vaf->fmt, vaf->va);
 	    ),
 
 	    TP_printk(
author maintainer
#29 lore raw

Re: [for-next][PATCH 17/23] batman-adv: tracing: Use the new __vstring() helper

Quoted 7 lines · On Sun, 24 Jul 2022 23:31:01 +0200 Sven Eckelmann <[email protected]> wrote:
Quoted 4 lines · On Thursday, 14 July 2022 18:43:13 CEST Steven Rostedt wrote:

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place).

Please also make sure to remove the define of BATADV_MAX_MSG_LEN

I usually do not like to rebase my for-next and just add on a patch to do something like this, but for this series I'll make an exception.

-- Steve

author maintainer
#30 lore raw

PATCH 18/23 mac80211: tracing: Use the new __vstring() helper

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which defeats the purpose of the dynamic array in the first place). Use the new __vstring() helper that will use a va_list and only write enough of the string into the ring buffer that is needed.

Cc Johannes Berg <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
---
 net/mac80211/trace_msg.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
net/mac80211/trace_msg.h +2 -4
index 40141df09f25..c9dbe9aab7bd 100644
@@ -24,13 +24,11 @@ DECLARE_EVENT_CLASS(mac80211_msg_event,
 	TP_ARGS(vaf),
 
 	TP_STRUCT__entry(
-		__dynamic_array(char, msg, MAX_MSG_LEN)
+		__vstring(msg, vaf->fmt, vaf->va)
 	),
 
 	TP_fast_assign(
-		WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
-				       MAX_MSG_LEN, vaf->fmt,
-				       *vaf->va) >= MAX_MSG_LEN);
+		__assign_vstr(msg, vaf->fmt, vaf->va);
 	),
 
 	TP_printk("%s", __get_str(msg))
Signature · 1 line
2.35.1
author maintainer
#31 lore raw

PATCH 19/23 tracing: eprobe: Add missing log index

In reply to Steven Rostedt

From: Linyu Yuan <[email protected]>

Add trace_probe_log_set_index(1) to allow report correct error if user input wrong SYSTEM.EVENT format.

---
 kernel/trace/trace_eprobe.c | 1 +
 1 file changed, 1 insertion(+)
kernel/trace/trace_eprobe.c +1 -0
index 7d4478525c66..b805b570305f 100644
@@ -881,6 +881,7 @@ static int __trace_eprobe_create(int argc, const char *argv[])
 	if (!is_good_name(event) || !is_good_name(group))
 		goto parse_error;
 
+	trace_probe_log_set_index(1);
 	sys_event = argv[1];
 	ret = traceprobe_parse_event_name(&sys_event, &sys_name, buf2,
 					  sys_event - argv[1]);
Signature · 1 line
2.35.1
author maintainer
#32 lore raw

PATCH 20/23 tracing: eprobe: Remove duplicate is_good_name() operation

In reply to Steven Rostedt

From: Linyu Yuan <[email protected]>

traceprobe_parse_event_name() already validate SYSTEM and EVENT name, there is no need to call is_good_name() after it.

---
 kernel/trace/trace_eprobe.c | 2 --
 1 file changed, 2 deletions(-)
kernel/trace/trace_eprobe.c +0 -2
index b805b570305f..8979cb9ec37a 100644
@@ -887,8 +887,6 @@ static int __trace_eprobe_create(int argc, const char *argv[])
 					  sys_event - argv[1]);
 	if (ret || !sys_name)
 		goto parse_error;
-	if (!is_good_name(sys_event) || !is_good_name(sys_name))
-		goto parse_error;
 
 	mutex_lock(&event_mutex);
 	event_call = find_and_get_event(sys_name, sys_event);
Signature · 1 line
2.35.1
author maintainer
#33 lore raw

PATCH 21/23 tracing: Auto generate event name when creating a group of events

In reply to Steven Rostedt

From: Linyu Yuan <[email protected]>

Currently when creating a specific group of trace events, take kprobe event as example, the user must use the following format:
p:GRP/EVENT [MOD:]KSYM[+OFFS]|KADDR [FETCHARGS],
which means user must enter EVENT name, one example is:

echo 'p:usb_gadget/config_usb_cfg_link config_usb_cfg_link $arg1' >> kprobe_events

It is not simple if there are too many entries because the event name is the same as symbol name.

This change allows user to specify no EVENT name, format changed as:

p:GRP/ [MOD:]KSYM[+OFFS]|KADDR [FETCHARGS]

It will generate event name automatically and one example is:

echo 'p:usb_gadget/ config_usb_cfg_link $arg1' >> kprobe_events.

---
 Documentation/trace/kprobetrace.rst  |  8 ++++----
 Documentation/trace/uprobetracer.rst |  8 ++++----
 kernel/trace/trace.c                 |  8 ++++----
 kernel/trace/trace_dynevent.c        |  2 +-
 kernel/trace/trace_eprobe.c          | 25 +++++++++++++------------
 kernel/trace/trace_kprobe.c          | 16 ++++++++++------
 kernel/trace/trace_probe.c           |  4 ++++
 kernel/trace/trace_uprobe.c          | 12 ++++++++----
 8 files changed, 48 insertions(+), 35 deletions(-)
Documentation/trace/kprobetrace.rst +4 -4
index b175d88f31eb..4274cc6a2f94 100644
@@ -28,10 +28,10 @@ Synopsis of kprobe_events
 -------------------------
 ::
 
-  p[:[GRP/]EVENT] [MOD:]SYM[+offs]|MEMADDR [FETCHARGS]	: Set a probe
-  r[MAXACTIVE][:[GRP/]EVENT] [MOD:]SYM[+0] [FETCHARGS]	: Set a return probe
-  p:[GRP/]EVENT] [MOD:]SYM[+0]%return [FETCHARGS]	: Set a return probe
-  -:[GRP/]EVENT						: Clear a probe
+  p[:[GRP/][EVENT]] [MOD:]SYM[+offs]|MEMADDR [FETCHARGS]	: Set a probe
+  r[MAXACTIVE][:[GRP/][EVENT]] [MOD:]SYM[+0] [FETCHARGS]	: Set a return probe
+  p[:[GRP/][EVENT]] [MOD:]SYM[+0]%return [FETCHARGS]	: Set a return probe
+  -:[GRP/][EVENT]						: Clear a probe
 
  GRP		: Group name. If omitted, use "kprobes" for it.
  EVENT		: Event name. If omitted, the event name is generated
Documentation/trace/uprobetracer.rst +4 -4
index a8e5938f609e..3a1797d707f4 100644
@@ -26,10 +26,10 @@ Synopsis of uprobe_tracer
 -------------------------
 ::
 
-  p[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] : Set a uprobe
-  r[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] : Set a return uprobe (uretprobe)
-  p[:[GRP/]EVENT] PATH:OFFSET%return [FETCHARGS] : Set a return uprobe (uretprobe)
-  -:[GRP/]EVENT                           : Clear uprobe or uretprobe event
+  p[:[GRP/][EVENT]] PATH:OFFSET [FETCHARGS] : Set a uprobe
+  r[:[GRP/][EVENT]] PATH:OFFSET [FETCHARGS] : Set a return uprobe (uretprobe)
+  p[:[GRP/][EVENT]] PATH:OFFSET%return [FETCHARGS] : Set a return uprobe (uretprobe)
+  -:[GRP/][EVENT]                           : Clear uprobe or uretprobe event
 
   GRP           : Group name. If omitted, "uprobes" is the default value.
   EVENT         : Event name. If omitted, the event name is generated based
kernel/trace/trace.c +4 -4
index b8dd54627075..7eb5bce62500 100644
@@ -5569,13 +5569,13 @@ static const char readme_msg[] =
 #endif
 #if defined(CONFIG_KPROBE_EVENTS) || defined(CONFIG_UPROBE_EVENTS)
 	"\t  accepts: event-definitions (one definition per line)\n"
-	"\t   Format: p[:[<group>/]<event>] <place> [<args>]\n"
-	"\t           r[maxactive][:[<group>/]<event>] <place> [<args>]\n"
+	"\t   Format: p[:[<group>/][<event>]] <place> [<args>]\n"
+	"\t           r[maxactive][:[<group>/][<event>]] <place> [<args>]\n"
 #ifdef CONFIG_HIST_TRIGGERS
 	"\t           s:[synthetic/]<event> <field> [<field>]\n"
 #endif
-	"\t           e[:[<group>/]<event>] <attached-group>.<attached-event> [<args>]\n"
-	"\t           -:[<group>/]<event>\n"
+	"\t           e[:[<group>/][<event>]] <attached-group>.<attached-event> [<args>]\n"
+	"\t           -:[<group>/][<event>]\n"
 #ifdef CONFIG_KPROBE_EVENTS
 	"\t    place: [<module>:]<symbol>[+<offset>]|<memaddr>\n"
   "place (kretprobe): [<module>:]<symbol>[+<offset>]%return|<memaddr>\n"
kernel/trace/trace_dynevent.c +1 -1
index 076b447a1b88..154996684fb5 100644
@@ -101,7 +101,7 @@ int dyn_event_release(const char *raw_command, struct dyn_event_operations *type
 		event = p + 1;
 		*p = '\0';
 	}
-	if (event[0] == '\0') {
+	if (!system && event[0] == '\0') {
 		ret = -EINVAL;
 		goto out;
 	}
kernel/trace/trace_eprobe.c +13 -12
index 8979cb9ec37a..a30f21499e81 100644
@@ -125,6 +125,7 @@ static bool eprobe_dyn_event_match(const char *system, const char *event,
 	 * We match the following:
 	 *  event only			- match all eprobes with event name
 	 *  system and event only	- match all system/event probes
+	 *  system only			- match all system probes
 	 *
 	 * The below has the above satisfied with more arguments:
 	 *
@@ -143,7 +144,7 @@ static bool eprobe_dyn_event_match(const char *system, const char *event,
 		return false;
 
 	/* Must match the event name */
-	if (strcmp(trace_probe_name(&ep->tp), event) != 0)
+	if (event[0] != '\0' && strcmp(trace_probe_name(&ep->tp), event) != 0)
 		return false;
 
 	/* No arguments match all */
@@ -848,7 +849,7 @@ static int __trace_eprobe_create(int argc, const char *argv[])
 {
 	/*
 	 * Argument syntax:
-	 *      e[:[GRP/]ENAME] SYSTEM.EVENT [FETCHARGS]
+	 *      e[:[GRP/][ENAME]] SYSTEM.EVENT [FETCHARGS]
 	 * Fetch args:
 	 *  <name>=$<field>[:TYPE]
 	 */
@@ -858,6 +859,7 @@ static int __trace_eprobe_create(int argc, const char *argv[])
 	struct trace_eprobe *ep = NULL;
 	char buf1[MAX_EVENT_NAME_LEN];
 	char buf2[MAX_EVENT_NAME_LEN];
+	char gbuf[MAX_EVENT_NAME_LEN];
 	int ret = 0;
 	int i;
 
@@ -869,25 +871,24 @@ static int __trace_eprobe_create(int argc, const char *argv[])
 	event = strchr(&argv[0][1], ':');
 	if (event) {
 		event++;
-		ret = traceprobe_parse_event_name(&event, &group, buf1,
+		ret = traceprobe_parse_event_name(&event, &group, gbuf,
 						  event - argv[0]);
 		if (ret)
 			goto parse_error;
-	} else {
-		strscpy(buf1, argv[1], MAX_EVENT_NAME_LEN);
-		sanitize_event_name(buf1);
-		event = buf1;
 	}
-	if (!is_good_name(event) || !is_good_name(group))
-		goto parse_error;
 
 	trace_probe_log_set_index(1);
 	sys_event = argv[1];
-	ret = traceprobe_parse_event_name(&sys_event, &sys_name, buf2,
-					  sys_event - argv[1]);
-	if (ret || !sys_name)
+	ret = traceprobe_parse_event_name(&sys_event, &sys_name, buf2, 0);
+	if (!sys_event || !sys_name)
 		goto parse_error;
 
+	if (!event) {
+		strscpy(buf1, argv[1], MAX_EVENT_NAME_LEN);
+		sanitize_event_name(buf1);
+		event = buf1;
+	}
+
 	mutex_lock(&event_mutex);
 	event_call = find_and_get_event(sys_name, sys_event);
 	ep = alloc_event_probe(group, event, event_call, argc - 2);
kernel/trace/trace_kprobe.c +10 -6
index a245ea673715..23f7f0ec4f4c 100644
@@ -163,7 +163,8 @@ static bool trace_kprobe_match(const char *system, const char *event,
 {
 	struct trace_kprobe *tk = to_trace_kprobe(ev);
 
-	return strcmp(trace_probe_name(&tk->tp), event) == 0 &&
+	return (event[0] == '\0' ||
+		strcmp(trace_probe_name(&tk->tp), event) == 0) &&
 	    (!system || strcmp(trace_probe_group_name(&tk->tp), system) == 0) &&
 	    trace_kprobe_match_command_head(tk, argc, argv);
 }
@@ -708,11 +709,11 @@ static int __trace_kprobe_create(int argc, const char *argv[])
 	/*
 	 * Argument syntax:
 	 *  - Add kprobe:
-	 *      p[:[GRP/]EVENT] [MOD:]KSYM[+OFFS]|KADDR [FETCHARGS]
+	 *      p[:[GRP/][EVENT]] [MOD:]KSYM[+OFFS]|KADDR [FETCHARGS]
 	 *  - Add kretprobe:
-	 *      r[MAXACTIVE][:[GRP/]EVENT] [MOD:]KSYM[+0] [FETCHARGS]
+	 *      r[MAXACTIVE][:[GRP/][EVENT]] [MOD:]KSYM[+0] [FETCHARGS]
 	 *    Or
-	 *      p:[GRP/]EVENT] [MOD:]KSYM[+0]%return [FETCHARGS]
+	 *      p[:[GRP/][EVENT]] [MOD:]KSYM[+0]%return [FETCHARGS]
 	 *
 	 * Fetch args:
 	 *  $retval	: fetch return value
@@ -739,6 +740,7 @@ static int __trace_kprobe_create(int argc, const char *argv[])
 	long offset = 0;
 	void *addr = NULL;
 	char buf[MAX_EVENT_NAME_LEN];
+	char gbuf[MAX_EVENT_NAME_LEN];
 	unsigned int flags = TPARG_FL_KERNEL;
 
 	switch (argv[0][0]) {
@@ -833,11 +835,13 @@ static int __trace_kprobe_create(int argc, const char *argv[])
 
 	trace_probe_log_set_index(0);
 	if (event) {
-		ret = traceprobe_parse_event_name(&event, &group, buf,
+		ret = traceprobe_parse_event_name(&event, &group, gbuf,
 						  event - argv[0]);
 		if (ret)
 			goto parse_error;
-	} else {
+	}
+
+	if (!event) {
 		/* Make a new event name */
 		if (symbol)
 			snprintf(buf, MAX_EVENT_NAME_LEN, "%c_%s_%ld",
kernel/trace/trace_probe.c +4 -0
index 80863c6508e5..850a88abd33b 100644
@@ -257,6 +257,10 @@ int traceprobe_parse_event_name(const char **pevent, const char **pgroup,
 	}
 	len = strlen(event);
 	if (len == 0) {
+		if (slash) {
+			*pevent = NULL;
+			return 0;
+		}
 		trace_probe_log_err(offset, NO_EVENT_NAME);
 		return -EINVAL;
 	} else if (len > MAX_EVENT_NAME_LEN) {
kernel/trace/trace_uprobe.c +8 -4
index c3dc4f859a6b..a3fec28961d6 100644
@@ -312,7 +312,8 @@ static bool trace_uprobe_match(const char *system, const char *event,
 {
 	struct trace_uprobe *tu = to_trace_uprobe(ev);
 
-	return strcmp(trace_probe_name(&tu->tp), event) == 0 &&
+	return (event[0] == '\0' ||
+		strcmp(trace_probe_name(&tu->tp), event) == 0) &&
 	   (!system || strcmp(trace_probe_group_name(&tu->tp), system) == 0) &&
 	   trace_uprobe_match_command_head(tu, argc, argv);
 }
@@ -532,7 +533,7 @@ static int register_trace_uprobe(struct trace_uprobe *tu)
 
 /*
  * Argument syntax:
- *  - Add uprobe: p|r[:[GRP/]EVENT] PATH:OFFSET[%return][(REF)] [FETCHARGS]
+ *  - Add uprobe: p|r[:[GRP/][EVENT]] PATH:OFFSET[%return][(REF)] [FETCHARGS]
  */
 static int __trace_uprobe_create(int argc, const char **argv)
 {
@@ -540,6 +541,7 @@ static int __trace_uprobe_create(int argc, const char **argv)
 	const char *event = NULL, *group = UPROBE_EVENT_SYSTEM;
 	char *arg, *filename, *rctr, *rctr_end, *tmp;
 	char buf[MAX_EVENT_NAME_LEN];
+	char gbuf[MAX_EVENT_NAME_LEN];
 	enum probe_print_type ptype;
 	struct path path;
 	unsigned long offset, ref_ctr_offset;
@@ -644,11 +646,13 @@ static int __trace_uprobe_create(int argc, const char **argv)
 	/* setup a probe */
 	trace_probe_log_set_index(0);
 	if (event) {
-		ret = traceprobe_parse_event_name(&event, &group, buf,
+		ret = traceprobe_parse_event_name(&event, &group, gbuf,
 						  event - argv[0]);
 		if (ret)
 			goto fail_address_parse;
-	} else {
+	}
+
+	if (!event) {
 		char *tail;
 		char *ptr;
 
Signature · 1 line
2.35.1
author maintainer
#34 lore raw

PATCH 22/23 selftests/ftrace: Add test case for GRP/ only input

In reply to Steven Rostedt

From: Linyu Yuan <[email protected]>

Add kprobe and eprobe event test for new GRP/ only format.

---
 .../ftrace/test.d/dynevent/add_remove_eprobe.tc          | 9 ++++++++-
 .../ftrace/test.d/dynevent/add_remove_kprobe.tc          | 7 +++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/dynevent/add_remove_eprobe.tc +8 -1
index 60c02b482be8..c300eb020262 100644
@@ -1,7 +1,7 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0
 # description: Generic dynamic event - add/remove eprobe events
-# requires: dynamic_events events/syscalls/sys_enter_openat "e[:[<group>/]<event>] <attached-group>.<attached-event> [<args>]":README
+# requires: dynamic_events events/syscalls/sys_enter_openat "<attached-group>.<attached-event> [<args>]":README
 
 echo 0 > events/enable
 
@@ -87,4 +87,11 @@ echo "-:eprobes/$EPROBE $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
 ! grep -q "$EPROBE" dynamic_events
 ! test -d events/eprobes/$EPROBE
 
+if grep -q "e\[:\[<group>/]\[<event>]]" README; then
+	echo "e:mygroup/ $SYSTEM/$EVENT $OPTIONS" >> dynamic_events
+	test -d events/mygroup
+	echo "-:mygroup/" >> dynamic_events
+	! test -d events/mygroup
+fi
+
 clear_trace
tools/testing/selftests/ftrace/test.d/dynevent/add_remove_kprobe.tc +7 -0
index b4da41d126d5..13d43f40a6fc 100644
@@ -23,4 +23,11 @@ grep -q myevent1 dynamic_events
 
 echo > dynamic_events
 
+if grep -q "p\[:\[<group>/]\[<event>]]" README; then
+	echo "p:mygroup/ $PLACE" >> dynamic_events
+	test -d events/mygroup
+	echo "-:mygroup/" >> dynamic_events
+	! test -d events/mygroup
+fi
+
 clear_trace
Signature · 1 line
2.35.1
author maintainer
#35 lore raw

PATCH 23/23 selftests/kprobe: Do not test for GRP/ without event failures

In reply to Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

A new feature is added where kprobes (and other probes) do not need to explicitly state the event name when creating a probe. The event name will come from what is being attached.

That is:

  # echo 'p:foo/ vfs_read' > kprobe_events

Will no longer error, but instead create an event:

  # cat kprobe_events
 p:foo/p_vfs_read_0 vfs_read

This should not be tested as an error case anymore. Remove it from the selftest as now this feature "breaks" the selftest as it no longer fails as expected.

---
 .../selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc       | 1 -
 1 file changed, 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc +0 -1
index fa928b431555..7c02509c71d0 100644
@@ -21,7 +21,6 @@ check_error 'p:^/bar vfs_read'		# NO_GROUP_NAME
 check_error 'p:^12345678901234567890123456789012345678901234567890123456789012345/bar vfs_read'	# GROUP_TOO_LONG
 
 check_error 'p:^foo.1/bar vfs_read'	# BAD_GROUP_NAME
-check_error 'p:foo/^ vfs_read'		# NO_EVENT_NAME
 check_error 'p:foo/^12345678901234567890123456789012345678901234567890123456789012345 vfs_read'	# EVENT_TOO_LONG
 check_error 'p:foo/^bar.1 vfs_read'	# BAD_EVENT_NAME
 
Signature · 1 line
2.35.1