public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/13] tracing/events: Add __vstring and __assign_vstr helpers
@ 2022-07-05 22:44 Steven Rostedt
  2022-07-05 22:44 ` [PATCH 01/13] tracing/events: Add __vstring() and __assign_vstr() helper macros Steven Rostedt
                   ` (12 more replies)
  0 siblings, 13 replies; 32+ messages in thread
From: Steven Rostedt @ 2022-07-05 22:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton

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, and more importantly, simplifies the code!


Steven Rostedt (Google) (13):
      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

----
 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 ++-----
 .../wireless/broadcom/brcm80211/brcmfmac/tracepoint.h  | 12 ++++--------
 .../brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h      | 12 ++++--------
 drivers/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/iscsi.h                           |  4 ++--
 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 +++++++
 net/batman-adv/trace.h                                 |  7 ++-----
 net/mac80211/trace_msg.h                               |  6 ++----
 23 files changed, 82 insertions(+), 86 deletions(-)

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

end of thread, other threads:[~2022-07-15 21:44 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-05 22:44 [PATCH 00/13] tracing/events: Add __vstring and __assign_vstr helpers Steven Rostedt
2022-07-05 22:44 ` [PATCH 01/13] tracing/events: Add __vstring() and __assign_vstr() helper macros Steven Rostedt
2022-07-07  1:35   ` Chunfeng Yun
2022-07-12 18:00     ` Steven Rostedt
2022-07-13  9:41       ` Chunfeng Yun
2022-07-15 21:42   ` [PATCH 01/13 v2] " Steven Rostedt
2022-07-15 21:44     ` Steven Rostedt
2022-07-05 22:44 ` [PATCH 02/13] tracing/IB/hfi1: Use the new __vstring() helper Steven Rostedt
2022-07-06  4:20   ` kernel test robot
2022-07-05 22:44 ` [PATCH 03/13] tracing/ath: " Steven Rostedt
2022-07-08  6:45   ` Kalle Valo
2022-07-05 22:44 ` [PATCH 04/13] tracing/brcm: " Steven Rostedt
2022-07-06  2:35   ` kernel test robot
2022-07-06  2:50     ` Steven Rostedt
2022-07-06  9:09       ` Arend Van Spriel
2022-07-06 11:51         ` Chen, Rong A
2022-07-08  5:02   ` Kalle Valo
2022-07-05 22:44 ` [PATCH 05/13] tracing/iwlwifi: " Steven Rostedt
2022-07-08  5:03   ` Kalle Valo
2022-07-05 22:44 ` [PATCH 06/13] usb: chipidea: tracing: " Steven Rostedt
2022-07-05 22:45 ` [PATCH 07/13] xhci: " Steven Rostedt
2022-07-05 22:45 ` [PATCH 08/13] USB: mtu3: " Steven Rostedt
2022-07-06  4:30   ` kernel test robot
2022-07-06 10:23   ` kernel test robot
2022-07-14 13:38   ` [PATCH 08/13 v2] " Steven Rostedt
2022-07-14 13:45     ` Greg Kroah-Hartman
2022-07-14 14:35       ` Steven Rostedt
2022-07-05 22:45 ` [PATCH 09/13] usb: musb: " Steven Rostedt
2022-07-05 22:45 ` [PATCH 10/13] scsi: iscsi: " Steven Rostedt
2022-07-05 22:45 ` [PATCH 11/13] scsi: qla2xxx: " Steven Rostedt
2022-07-05 22:45 ` [PATCH 12/13] batman-adv: " Steven Rostedt
2022-07-05 22:45 ` [PATCH 13/13] mac80211: " Steven Rostedt

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