tracing: Addition of TRACE_DEFINE_ENUM() to convert enums it TP_printk()
Subsystems (19)
Steven Rostedt
maintainercover tracing: Addition of TRACE_DEFINE_ENUM() to convert enums it TP_printk()
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next
Head SHA1: 72226a4c470c2a57c70be260a96f3a708fe4a2ad
Steven Rostedt (1):
tracing/drm: Remove unused TRACE_SYSTEM_STRING define
Steven Rostedt (Red Hat) (20):
tracing: Add TRACE_SYSTEM_VAR to intel-sst
tracing: Add TRACE_SYSTEM_VAR to kvm-s390
tracing: Add TRACE_SYSTEM_VAR to xhci-hcd
mac80211: Move message tracepoints to their own header
iwlwifi: Move each system tracepoints to their own header
brcmsmac: Move each system tracepoints to their own header
tracing: Give system name a pointer
tracing: Update trace-event-sample with TRACE_SYSTEM_VAR documentation
tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values
tracing: Allow for modules to convert their enums to values tracing/samples: Update the trace-event-sample.h with TRACE_DEFINE_ENUM() x86/tlb/trace: Export enums in used by tlb_flush tracepoint net/9p/tracing: Export enums in tracepoints to userspace
f2fs: Export the enums in the tracepoints to userspace irq/tracing: Export enums in tracepoints to user space
mm: tracing: Export enums in tracepoints to user space
SUNRPC: Export enums in tracepoints to user space
v4l: Export enums used by tracepoints to user space
writeback: Export enums used by tracepoint to user space
tracing: Add enum_map file to show enums that have been mapped
----
arch/s390/kvm/trace-s390.h | 7 + drivers/gpu/drm/drm_trace.h | 1 - drivers/gpu/drm/i915/i915_trace.h | 1 - drivers/gpu/drm/radeon/radeon_trace.h | 1 - .../brcm80211/brcmsmac/brcms_trace_brcmsmac.h | 102 +++++ .../brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h | 88 +++++ .../brcm80211/brcmsmac/brcms_trace_brcmsmac_tx.h | 110 ++++++ .../brcm80211/brcmsmac/brcms_trace_events.h | 225 +---------- drivers/net/wireless/iwlwifi/iwl-devtrace-data.h | 79 ++++ drivers/net/wireless/iwlwifi/iwl-devtrace-io.h | 155 ++++++++ .../net/wireless/iwlwifi/iwl-devtrace-iwlwifi.h | 200 ++++++++++ drivers/net/wireless/iwlwifi/iwl-devtrace-msg.h | 97 +++++ drivers/net/wireless/iwlwifi/iwl-devtrace-ucode.h | 81 ++++ drivers/net/wireless/iwlwifi/iwl-devtrace.h | 438 +-------------------- drivers/usb/host/xhci-trace.h | 7 + include/asm-generic/vmlinux.lds.h | 5 +- include/linux/ftrace_event.h | 4 +- include/linux/module.h | 2 + include/linux/tracepoint.h | 8 + include/trace/events/9p.h | 157 ++++---- include/trace/events/f2fs.h | 30 ++ include/trace/events/intel-sst.h | 7 + include/trace/events/irq.h | 39 +- include/trace/events/migrate.h | 42 +- include/trace/events/sunrpc.h | 62 ++- include/trace/events/tlb.h | 30 +- include/trace/events/v4l2.h | 75 ++-- include/trace/events/writeback.h | 33 +- include/trace/ftrace.h | 41 +- kernel/module.c | 3 + kernel/trace/Kconfig | 28 ++ kernel/trace/trace.c | 304 +++++++++++++- kernel/trace/trace.h | 2 + kernel/trace/trace_events.c | 121 +++++- net/mac80211/trace.c | 1 + net/mac80211/trace.h | 38 -- net/mac80211/trace_msg.h | 53 +++ samples/trace_events/trace-events-sample.h | 84 +++- 38 files changed, 1909 insertions(+), 852 deletions(-)
Steven Rostedt
maintainerPATCH 1/21 tracing/drm: Remove unused TRACE_SYSTEM_STRING define
From: Steven Rostedt <[email protected]>
The tracing infrastructure is adding a macro TRACE_SYSTEM_STRING, and hit the following build failure:
In file included from include/trace/define_trace.h:90:0,
from drivers/gpu/drm/.//radeon/radeon_trace.h:209,
from drivers/gpu/drm/.//radeon/radeon_trace_points.c:9:Quoted 1 line
Quoted 1 line
include/trace/ftrace.h:28:0: warning: "TRACE_SYSTEM_STRING" redefined
#define TRACE_SYSTEM_STRING __app(TRACE_SYSTEM_VAR,__trace_system_name)
Seems that the DRM folks have added their own use to the TRACE_SYSTEM_STRING, with:
#define TRACE_SYSTEM_STRING __stringify(TRACE_SYSTEM)
Although, I can not find its use anywhere. I could simply use another name, but if this macro is not being used, it should be removed.
--- drivers/gpu/drm/drm_trace.h | 1 - drivers/gpu/drm/i915/i915_trace.h | 1 - drivers/gpu/drm/radeon/radeon_trace.h | 1 - 3 files changed, 3 deletions(-)
drivers/gpu/drm/drm_trace.h +0 -1
@@ -7,7 +7,6 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM drm -#define TRACE_SYSTEM_STRING __stringify(TRACE_SYSTEM)#define TRACE_INCLUDE_FILE drm_trace TRACE_EVENT(drm_vblank_event,
drivers/gpu/drm/i915/i915_trace.h +0 -1
@@ -12,7 +12,6 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM i915 -#define TRACE_SYSTEM_STRING __stringify(TRACE_SYSTEM)#define TRACE_INCLUDE_FILE i915_trace/* pipe updates */
drivers/gpu/drm/radeon/radeon_trace.h +0 -1
@@ -9,7 +9,6 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM radeon -#define TRACE_SYSTEM_STRING __stringify(TRACE_SYSTEM)#define TRACE_INCLUDE_FILE radeon_trace TRACE_EVENT(radeon_bo_create,
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 2/21 tracing: Add TRACE_SYSTEM_VAR to intel-sst
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
New code will require TRACE_SYSTEM to be a valid C variable name, but some tracepoints have TRACE_SYSTEM with '-' and not '_', so it can not be used. Instead, add a TRACE_SYSTEM_VAR that can give the tracing infrastructure a unique name for the trace system.
--- include/trace/events/intel-sst.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/trace/events/intel-sst.h +7 -0
@@ -1,6 +1,13 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM intel-sst +/* +* The TRACE_SYSTEM_VAR defaults to TRACE_SYSTEM, but must be a +* legitimate C variable. It is not exported to user space. +*/ +#undef TRACE_SYSTEM_VAR +#define TRACE_SYSTEM_VAR intel_sst +#if !defined(_TRACE_INTEL_SST_H) || defined(TRACE_HEADER_MULTI_READ )#define _TRACE_INTEL_SST_H
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 3/21 tracing: Add TRACE_SYSTEM_VAR to kvm-s390
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
New code will require TRACE_SYSTEM to be a valid C variable name, but some tracepoints have TRACE_SYSTEM with '-' and not '_', so it can not be used. Instead, add a TRACE_SYSTEM_VAR that can give the tracing infrastructure a unique name for the trace system.
--- arch/s390/kvm/trace-s390.h | 7 +++++++ 1 file changed, 7 insertions(+)
arch/s390/kvm/trace-s390.h +7 -0
@@ -10,6 +10,13 @@#define TRACE_INCLUDE_FILE trace-s390/* +* The TRACE_SYSTEM_VAR defaults to TRACE_SYSTEM, but must be a +* legitimate C variable. It is not exported to user space. +*/ +#undef TRACE_SYSTEM_VAR +#define TRACE_SYSTEM_VAR kvm_s390 + +/* * Trace point for the creation of the kvm instance. */ TRACE_EVENT(kvm_s390_create_vm,
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 4/21 tracing: Add TRACE_SYSTEM_VAR to xhci-hcd
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
New code will require TRACE_SYSTEM to be a valid C variable name, but some tracepoints have TRACE_SYSTEM with '-' and not '_', so it can not be used. Instead, add a TRACE_SYSTEM_VAR that can give the tracing infrastructure a unique name for the trace system.
--- drivers/usb/host/xhci-trace.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/host/xhci-trace.h +7 -0
@@ -14,6 +14,13 @@#undef TRACE_SYSTEM#define TRACE_SYSTEM xhci-hcd +/* +* The TRACE_SYSTEM_VAR defaults to TRACE_SYSTEM, but must be a +* legitimate C variable. It is not exported to user space. +*/ +#undef TRACE_SYSTEM_VAR +#define TRACE_SYSTEM_VAR xhci_hcd +#if !defined(__XHCI_TRACE_H) || defined(TRACE_HEADER_MULTI_READ )#define __XHCI_TRACE_H
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 5/21 mac80211: Move message tracepoints to their own header
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Every tracing file must have its own TRACE_SYSTEM defined. The mac80211 tracepoint header broke this and add in the middle of the file had:
#undef TRACE_SYSTEM
#define TRACE_SYSTEM mac80211_msg
Unfortunately, this broke new code in the ftrace infrastructure. Moving the mac80211_msg into its own trace file with its own TRACE_SYSTEM defined fixes the issue.
--- net/mac80211/trace.c | 1 + net/mac80211/trace.h | 38 ---------------------------------- net/mac80211/trace_msg.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 38 deletions(-) create mode 100644 net/mac80211/trace_msg.h
net/mac80211/trace.c +1 -0
@@ -8,6 +8,7 @@#include "debug.h" #define CREATE_TRACE_POINTS #include "trace.h" +#include "trace_msg.h" #ifdef CONFIG_MAC80211_MESSAGE_TRACING void __sdata_info (const char *fmt, ...)
net/mac80211/trace.h +0 -38
@@ -2312,44 +2312,6 @@ TRACE_EVENT(drv_tdls_recv_channel_switch, ) ); -#ifdef CONFIG_MAC80211_MESSAGE_TRACING -#undef TRACE_SYSTEM -#define TRACE_SYSTEM mac80211_msg - -#define MAX_MSG_LEN 100 - -DECLARE_EVENT_CLASS (mac80211_msg_event, - TP_PROTO(struct va_format *vaf), - -TP_ARGS (vaf), - -TP_STRUCT__entry ( -__dynamic_array (char, msg,MAX_MSG_LEN ) - ), - -TP_fast_assign ( -WARN_ON_ONCE (vsnprintf (__get_dynamic_array (msg), -MAX_MSG_LEN , vaf->fmt, - *vaf->va) >= MAX_MSG_LEN); - ), - -TP_printk ("%s" ,__get_str (msg)) -); - -DEFINE_EVENT (mac80211_msg_event, mac80211_info, - TP_PROTO(struct va_format *vaf), -TP_ARGS (vaf) -); -DEFINE_EVENT (mac80211_msg_event, mac80211_dbg, - TP_PROTO(struct va_format *vaf), -TP_ARGS (vaf) -); -DEFINE_EVENT (mac80211_msg_event, mac80211_err, - TP_PROTO(struct va_format *vaf), -TP_ARGS (vaf) -); -#endif -#endif /* !__MAC80211_DRIVER_TRACE || TRACE_HEADER_MULTI_READ */ #undef TRACE_INCLUDE_PATH
net/mac80211/trace_msg.h new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 6/21 iwlwifi: Move each system tracepoints to their own header
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Every tracing file must have its own TRACE_SYSTEM defined. The iwlwifi tracepoint header broke this and added in the middle of the file:
#undef TRACE_SYSTEM
#define TRACE_SYSTEM iwlwifi_io
#undef TRACE_SYSTEM
#define TRACE_SYSTEM iwlwifi_ucode
#undef TRACE_SYSTEM
#define TRACE_SYSTEM iwlwifi_msg
#undef TRACE_SYSTEM
#define TRACE_SYSTEM iwlwifi_data
#undef TRACE_SYSTEM
#define TRACE_SYSTEM iwlwifi
Unfortunately, this broke new code in the ftrace infrastructure. Moving each of these TRACE_SYSTEMs into their own trace file with just one TRACE_SYSTEM per file fixes the issue.
--- drivers/net/wireless/iwlwifi/iwl-devtrace-data.h | 79 ++++ drivers/net/wireless/iwlwifi/iwl-devtrace-io.h | 155 ++++++++ .../net/wireless/iwlwifi/iwl-devtrace-iwlwifi.h | 200 ++++++++++ drivers/net/wireless/iwlwifi/iwl-devtrace-msg.h | 97 +++++ drivers/net/wireless/iwlwifi/iwl-devtrace-ucode.h | 81 ++++ drivers/net/wireless/iwlwifi/iwl-devtrace.h | 438 +-------------------- 6 files changed, 618 insertions(+), 432 deletions(-) create mode 100644 drivers/net/wireless/iwlwifi/iwl-devtrace-data.h create mode 100644 drivers/net/wireless/iwlwifi/iwl-devtrace-io.h create mode 100644 drivers/net/wireless/iwlwifi/iwl-devtrace-iwlwifi.h create mode 100644 drivers/net/wireless/iwlwifi/iwl-devtrace-msg.h create mode 100644 drivers/net/wireless/iwlwifi/iwl-devtrace-ucode.h
drivers/net/wireless/iwlwifi/iwl-devtrace-data.h new file +79 -0
@@ -0,0 +1,79 @@ +/****************************************************************************** +* +* Copyright(c) 2009 - 2014 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* The full GNU General Public License is included in this distribution in the +* file called LICENSE. +* +* Contact Information: +* Intel Linux Wireless <[email protected]> +* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 +* +*****************************************************************************/ + +#if !defined(__IWLWIFI_DEVICE_TRACE_DATA) || defined(TRACE_HEADER_MULTI_READ ) +#define __IWLWIFI_DEVICE_TRACE_DATA + +#include <linux/tracepoint.h> + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM iwlwifi_data + +TRACE_EVENT (iwlwifi_dev_tx_data, + TP_PROTO(const struct device *dev, + struct sk_buff *skb, + void *data, size_t data_len), +TP_ARGS (dev, skb, data, data_len), +TP_STRUCT__entry ( + DEV_ENTRY + +__dynamic_array (u8, data,iwl_trace_data (skb) ? data_len :0 ) + ), +TP_fast_assign ( + DEV_ASSIGN; + if (iwl_trace_data(skb)) + memcpy(__get_dynamic_array(data), data, data_len); + ), +TP_printk ("[%s] TX frame data" ,__get_str (dev)) +); + +TRACE_EVENT (iwlwifi_dev_rx_data, + TP_PROTO(const struct device *dev, + const struct iwl_trans *trans, + void *rxbuf, size_t len), +TP_ARGS (dev, trans, rxbuf, len), +TP_STRUCT__entry ( + DEV_ENTRY + +__dynamic_array (u8, data, + len -iwl_rx_trace_len (trans, rxbuf, len)) + ), +TP_fast_assign ( + size_t offs = iwl_rx_trace_len(trans, rxbuf, len); + DEV_ASSIGN; + if (offs < len) +memcpy (__get_dynamic_array (data), + ((u8 *)rxbuf) + offs, len - offs); + ), +TP_printk ("[%s] RX frame data" ,__get_str (dev)) +); +#endif /* __IWLWIFI_DEVICE_TRACE_DATA */ + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE iwl-devtrace-data +#include <trace/define_trace.h>
drivers/net/wireless/iwlwifi/iwl-devtrace-io.h new file +155 -0
155 lines not on this page · raw message
drivers/net/wireless/iwlwifi/iwl-devtrace-iwlwifi.h new file +200 -0
200 lines not on this page · raw message
drivers/net/wireless/iwlwifi/iwl-devtrace-msg.h new file +97 -0
97 lines not on this page · raw message
drivers/net/wireless/iwlwifi/iwl-devtrace-ucode.h new file +81 -0
81 lines not on this page · raw message
drivers/net/wireless/iwlwifi/iwl-devtrace.h +6 -432
449 lines not on this page · raw message
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 7/21 brcmsmac: Move each system tracepoints to their own header
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Every tracing file must have its own TRACE_SYSTEM defined. The brcmsmac tracepoint header broke this and added in the middle of the file:
#undef TRACE_SYSTEM
#define TRACE_SYSTEM brcmsmac
#undef TRACE_SYSTEM
#define TRACE_SYSTEM brcmsmac_tx
#undef TRACE_SYSTEM
#define TRACE_SYSTEM brcmsmac_msg
Unfortunately, this broke new code in the ftrace infrastructure. Moving each of these TRACE_SYSTEMs into their own trace file with just one TRACE_SYSTEM per file fixes the issue.
--- .../brcm80211/brcmsmac/brcms_trace_brcmsmac.h | 102 ++++++++++ .../brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h | 88 ++++++++ .../brcm80211/brcmsmac/brcms_trace_brcmsmac_tx.h | 110 ++++++++++ .../brcm80211/brcmsmac/brcms_trace_events.h | 225 +-------------------- 4 files changed, 305 insertions(+), 220 deletions(-) create mode 100644 drivers/net/wireless/brcm80211/brcmsmac/brcms_trace_brcmsmac.h create mode 100644 drivers/net/wireless/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h create mode 100644 drivers/net/wireless/brcm80211/brcmsmac/brcms_trace_brcmsmac_tx.h
drivers/net/wireless/brcm80211/brcmsmac/brcms_trace_brcmsmac.h new file +102 -0
@@ -0,0 +1,102 @@ +/* +* Copyright (c) 2011 Broadcom Corporation +* +* Permission to use, copy, modify, and/or distribute this software for any +* purpose with or without fee is hereby granted, provided that the above +* copyright notice and this permission notice appear in all copies. +* +* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +#if !defined(__TRACE_BRCMSMAC_H) || defined(TRACE_HEADER_MULTI_READ ) +#define __TRACE_BRCMSMAC_H + +#include <linux/tracepoint.h> + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM brcmsmac + +/* +* We define a tracepoint, its arguments, its printk format and its +* 'fast binary record' layout. +*/ +TRACE_EVENT (brcms_timer, +/* TPPROTO is the prototype of the function called by this tracepoint */ + TP_PROTO(struct brcms_timer *t), +/* +* TPARGS(firstarg, p) are the parameters names, same as found in the +* prototype. +*/ +TP_ARGS (t), +/* +* Fast binary tracing: define the trace record via TP_STRUCT__entry(). +* You can think about it like a regular C structure local variable +* definition. +*/ +TP_STRUCT__entry ( + __field(uint, ms) + __field(uint, set) +__field (uint, periodic) + ), +TP_fast_assign ( + __entry->ms = t->ms; + __entry->set = t->set; + __entry->periodic = t->periodic; + ), +TP_printk ( +"ms=%u set=%u periodic=%u" , + __entry->ms, __entry->set, __entry->periodic + ) +); + +TRACE_EVENT (brcms_dpc, + TP_PROTO(unsigned long data), +TP_ARGS (data), +TP_STRUCT__entry ( + __field(unsigned long, data) + ), +TP_fast_assign ( + __entry->data = data; + ), +TP_printk ( +"data=%p" , + (void *)__entry->data + ) +); + +TRACE_EVENT (brcms_macintstatus, + TP_PROTO(const struct device *dev, int in_isr, u32 macintstatus, + u32 mask), +TP_ARGS (dev, in_isr, macintstatus, mask), +TP_STRUCT__entry ( + __string(dev, dev_name(dev)) + __field(int, in_isr) + __field(u32, macintstatus) +__field (u32, mask) + ), +TP_fast_assign ( + __assign_str(dev, dev_name(dev)); + __entry->in_isr = in_isr; + __entry->macintstatus = macintstatus; + __entry->mask = mask; + ), +TP_printk ("[%s] in_isr=%d macintstatus=%#x mask=%#x" ,__get_str (dev), + __entry->in_isr, __entry->macintstatus, __entry->mask) +); +#endif /* __TRACE_BRCMSMAC_H */ + +#ifdef CONFIG_BRCM_TRACING + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE brcms_trace_brcmsmac +#include <trace/define_trace.h> + +#endif /* CONFIG_BRCM_TRACING */
drivers/net/wireless/brcm80211/brcmsmac/brcms_trace_brcmsmac_msg.h new file +88 -0
88 lines not on this page · raw message
drivers/net/wireless/brcm80211/brcmsmac/brcms_trace_brcmsmac_tx.h new file +110 -0
110 lines not on this page · raw message
drivers/net/wireless/brcm80211/brcmsmac/brcms_trace_events.h +5 -220
236 lines not on this page · raw message
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 8/21 tracing: Give system name a pointer
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Normally the compiler will use the same pointer for a string throughout the file. But there's no guarantee of that happening. Later changes will require that all events have the same pointer to the system string.
Name the system string and have all events point to it.
Testing this, it did not increases the size of the text, except for the notes section, which should not harm the real size any.
--- include/linux/ftrace_event.h | 2 +- include/trace/ftrace.h | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-)
include/linux/ftrace_event.h +1 -1
@@ -202,7 +202,7 @@ enum trace_reg {struct ftrace_event_call ;struct ftrace_event_class { -char *system; +const char *system;void *probe;#ifdef CONFIG_PERF_EVENTS void *perf_probe;
include/trace/ftrace.h +17 -2
@@ -18,6 +18,21 @@#include <linux/ftrace_event.h> +#ifndef TRACE_SYSTEM_VAR +#define TRACE_SYSTEM_VAR TRACE_SYSTEM +#endif + +#define __app__ (x, y) str__##x##y +#define __app (x, y) __app__(x, y) + +#define TRACE_SYSTEM_STRING __app(TRACE_SYSTEM_VAR,__trace_system_name) + +#define TRACE_MAKE_SYSTEM_STR () \ + static const char TRACE_SYSTEM_STRING[] = \ + __stringify(TRACE_SYSTEM) + +TRACE_MAKE_SYSTEM_STR (); +/* * DECLARE_EVENT_CLASS can be used to add a generic function * handlers for events. That is, if all events have the same
@@ -105,7 +120,6 @@#include TRACE_INCLUDE (TRACE_INCLUDE_FILE ) -/* * Stage 2 of the trace events. *
@@ -692,7 +706,7 @@ static inline void ftrace_test_probe_##call(void) \_TRACE_PERF_PROTO (call,PARAMS (proto)); \ static const char print_fmt_##call[] = print; \ static struct ftrace_event_class __used __refdata event_class_##call = { \ - .system = __stringify(TRACE_SYSTEM), \ + .system = TRACE_SYSTEM_STRING, \ .define_fields = ftrace_define_fields_##call, \ .fields = LIST_HEAD_INIT(event_class_##call.fields),\ .raw_init = trace_event_raw_init, \
@@ -735,6 +749,7 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call#include TRACE_INCLUDE (TRACE_INCLUDE_FILE ) +#undef TRACE_SYSTEM_VAR#ifdef CONFIG_PERF_EVENTS
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 9/21 tracing: Update trace-event-sample with TRACE_SYSTEM_VAR documentation
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Add documentation about TRACE_SYSTEM needing to be alpha-numeric or with underscores, and that if it is not, then the use of TRACE_SYSTEM_VAR is required to make something that is.
An example of this is shown in samples/trace_events/trace-events-sample.h
--- samples/trace_events/trace-events-sample.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
samples/trace_events/trace-events-sample.h +19 -1
@@ -22,7 +22,25 @@* protection, just like TRACE_INCLUDE_FILE. */ #undef TRACE_SYSTEM -#define TRACE_SYSTEM sample +#define TRACE_SYSTEM sample-trace + +/* +* TRACE_SYSTEM is expected to be a C valid variable (alpha-numeric +* and underscore), although it may start with numbers. If for some +* reason it is not, you need to add the following lines: +*/ +#undef TRACE_SYSTEM_VAR +#define TRACE_SYSTEM_VAR sample_trace +/* +* But the above is only needed if TRACE_SYSTEM is not alpha-numeric +* and underscored. By default, TRACE_SYSTEM_VAR will be equal to +* TRACE_SYSTEM. As TRACE_SYSTEM_VAR must be alpha-numeric, if +* TRACE_SYSTEM is not, then TRACE_SYSTEM_VAR must be defined with +* only alpha-numeric and underscores. +* +* The TRACE_SYSTEM_VAR is only used internally and not visible to +* user space. +*/ /* * Notice that this file is not protected like a normal header.
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 10/21 tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Several tracepoints use the helper functions __print_symbolic() or __print_flags() and pass in enums that do the mapping between the binary data stored and the value to print. This works well for reading the ASCII trace files, but when the data is read via userspace tools such as perf and trace-cmd, the conversion of the binary value to a human string format is lost if an enum is used, as userspace does not have access to what the ENUM is.
For example, the tracepoint trace_tlb_flush() has:
__print_symbolic(REC->reason,
{ TLB_FLUSH_ON_TASK_SWITCH, "flush on task switch" }, { TLB_REMOTE_SHOOTDOWN, "remote shootdown" }, { TLB_LOCAL_SHOOTDOWN, "local shootdown" }, { TLB_LOCAL_MM_SHOOTDOWN, "local mm shootdown" })
Which maps the enum values to the strings they represent. But perf and trace-cmd do no know what value TLB_LOCAL_MM_SHOOTDOWN is, and would not be able to map it.
With TRACE_DEFINE_ENUM(), developers can place these in the event header files and ftrace will convert the enums to their values:
By adding:
TRACE_DEFINE_ENUM(TLB_FLUSH_ON_TASK_SWITCH);
TRACE_DEFINE_ENUM(TLB_REMOTE_SHOOTDOWN);
TRACE_DEFINE_ENUM(TLB_LOCAL_SHOOTDOWN);
TRACE_DEFINE_ENUM(TLB_LOCAL_MM_SHOOTDOWN);
$ cat /sys/kernel/debug/tracing/events/tlb/tlb_flush/format
[...]
__print_symbolic(REC->reason,
{ 0, "flush on task switch" },
{ 1, "remote shootdown" },
{ 2, "local shootdown" },
{ 3, "local mm shootdown" })The above is what userspace expects to see, and tools do not need to be modified to parse them.
--- include/asm-generic/vmlinux.lds.h | 5 +- include/linux/ftrace_event.h | 2 +- include/linux/tracepoint.h | 8 +++ include/trace/ftrace.h | 22 ++++++- kernel/trace/trace.c | 26 ++++++++- kernel/trace/trace.h | 2 + kernel/trace/trace_events.c | 119 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 178 insertions(+), 6 deletions(-)
include/asm-generic/vmlinux.lds.h +4 -1
@@ -124,7 +124,10 @@#define FTRACE_EVENTS () . = ALIGN(8); \ VMLINUX_SYMBOL(__start_ftrace_events) = .; \ *(_ftrace_events) \ - VMLINUX_SYMBOL(__stop_ftrace_events) = .; + VMLINUX_SYMBOL(__stop_ftrace_events) = .; \ + VMLINUX_SYMBOL(__start_ftrace_enum_maps) = .; \ + *(_ftrace_enum_map) \ + VMLINUX_SYMBOL(__stop_ftrace_enum_maps) = .;#else #define FTRACE_EVENTS ()#endif
include/linux/ftrace_event.h +1 -1
@@ -285,7 +285,7 @@ struct ftrace_event_call {struct tracepoint *tp; };struct trace_event event; -const char *print_fmt; +char *print_fmt;struct event_filter *filter;void *mod;void *data;
include/linux/tracepoint.h +8 -0
@@ -36,6 +36,12 @@ struct tracepoint {struct tracepoint_func __rcu *funcs; }; +struct trace_enum_map { +const char *system; +const char *enum_string; +unsigned long enum_value; +}; +extern int tracepoint_probe_register (struct tracepoint *tp,void *probe,void *data); extern int
@@ -87,6 +93,8 @@ extern void syscall_unregfunc(void); #define PARAMS(args...) args +#define TRACE_DEFINE_ENUM (x) +#endif /* _LINUX_TRACEPOINT_H */ /*
include/trace/ftrace.h +19 -3
@@ -33,6 +33,19 @@TRACE_MAKE_SYSTEM_STR (); +#undef TRACE_DEFINE_ENUM +#define TRACE_DEFINE_ENUM (a) \ + static struct trace_enum_map __used __initdata \ + __##TRACE_SYSTEM##_##a = \ + { \ + .system = TRACE_SYSTEM_STRING, \ + .enum_string = #a, \ + .enum_value = a \ + }; \ + static struct trace_enum_map __used \ + __attribute__((section("_ftrace_enum_map"))) \ + *TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a +/* * DECLARE_EVENT_CLASS can be used to add a generic function * handlers for events. That is, if all events have the same
@@ -136,6 +149,9 @@ TRACE_MAKE_SYSTEM_STR();* The size of an array is also encoded, in the higher 16 bits of <item>. */ +#undef TRACE_DEFINE_ENUM +#define TRACE_DEFINE_ENUM (a) +#undef __field#define __field (type, item)
@@ -553,7 +569,7 @@ static inline notrace int ftrace_get_offsets_##call( \* .trace = ftrace_raw_output_<call>, <-- stage 2 * }; * -* static const char print_fmt_<call>[] = <TP_printk>; +* static char print_fmt_<call>[] = <TP_printk>; * * static struct ftrace_event_class __used event_class_<template> = { * .system = "<system>",
@@ -704,7 +720,7 @@ static inline void ftrace_test_probe_##call(void) \#undef DECLARE_EVENT_CLASS#define DECLARE_EVENT_CLASS (call, proto, args, tstruct, assign, print) \ _TRACE_PERF_PROTO(call, PARAMS(proto)); \ -static const char print_fmt_##call[] = print; \ +static char print_fmt_##call[] = print; \ static struct ftrace_event_class __used __refdata event_class_##call = { \ .system = TRACE_SYSTEM_STRING, \ .define_fields = ftrace_define_fields_##call, \
@@ -733,7 +749,7 @@ __attribute__((section("_ftrace_events"))) *__event_##call = &event_##call#undef DEFINE_EVENT_PRINT#define DEFINE_EVENT_PRINT (template, call, proto, args, print) \ \ -static const char print_fmt_##call[] = print; \ +static char print_fmt_##call[] = print; \ \ static struct ftrace_event_call __used event_##call = { \ .class = &event_class_##template, \
kernel/trace/trace.c +25 -1
@@ -3908,6 +3908,20 @@ static const struct file_operations tracing_saved_cmdlines_size_fops = { .write = tracing_saved_cmdlines_size_write, }; +static void +trace_insert_enum_map (struct trace_enum_map **start,struct trace_enum_map **stop) +{ +struct trace_enum_map **map; +int len = stop - start; + +if (len <=0 ) +return ; + + map = start; + +trace_event_enum_update (map, len); +} +static ssize_t tracing_set_trace_read (struct file *filp,char __user *ubuf,size_t cnt,loff_t *ppos)
@@ -6542,6 +6556,14 @@ struct dentry *tracing_init_dentry(void)return tr->dir; } +extern struct trace_enum_map *__start_ftrace_enum_maps[]; +extern struct trace_enum_map *__stop_ftrace_enum_maps[]; + +static void __init trace_enum_init (void ) +{ +trace_insert_enum_map (__start_ftrace_enum_maps, __stop_ftrace_enum_maps); +} +static __init int tracer_init_debugfs (void ) {struct dentry *d_tracer;
@@ -6566,6 +6588,8 @@ static __init int tracer_init_debugfs(void)trace_create_file ("saved_cmdlines_size" ,0644 , d_tracer,NULL , &tracing_saved_cmdlines_size_fops); +trace_enum_init (); +#ifdef CONFIG_DYNAMIC_FTRACE trace_create_file ("dyn_ftrace_total_info" ,0444 , d_tracer, &ftrace_update_tot_cnt, &tracing_dyn_info_fops);
@@ -6888,7 +6912,7 @@ void __init trace_init(void) tracepoint_printk =0 ; }tracer_alloc_buffers (); -trace_event_init (); +trace_event_init (); }__init static int clear_boot_tracer (void )
kernel/trace/trace.h +2 -0
@@ -1309,8 +1309,10 @@ static inline void init_ftrace_syscalls(void) { }#ifdef CONFIG_EVENT_TRACING void trace_event_init (void ); +void trace_event_enum_update (struct trace_enum_map **map,int len);#else static inline void __init trace_event_init (void ) { } +static inlin void trace_event_enum_update(struct trace_enum_map **map, int len) { }#endif extern struct trace_iterator *tracepoint_print_iter;
kernel/trace/trace_events.c +119 -0
125 lines not on this page · raw message
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 11/21 tracing: Allow for modules to convert their enums to values
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Update the infrastructure such that modules that declare TRACE_DEFINE_ENUM() will have those enums converted into their values in the tracepoint print fmt strings.
--- include/linux/module.h | 2 ++ kernel/module.c | 3 +++ kernel/trace/trace.c | 49 +++++++++++++++++++++++++++++++++++++++++---- kernel/trace/trace_events.c | 2 +- 4 files changed, 51 insertions(+), 5 deletions(-)
include/linux/module.h +2 -0
@@ -338,6 +338,8 @@ struct module {#ifdef CONFIG_EVENT_TRACING struct ftrace_event_call **trace_events;unsigned int num_trace_events; +struct trace_enum_map **trace_enums; +unsigned int num_trace_enums;#endif #ifdef CONFIG_FTRACE_MCOUNT_RECORD unsigned int num_ftrace_callsites;
kernel/module.c +3 -0
@@ -2753,6 +2753,9 @@ static int find_module_sections(struct module *mod, struct load_info *info) mod->trace_events =section_objs (info,"_ftrace_events" ,sizeof (*mod->trace_events), &mod->num_trace_events); + mod->trace_enums =section_objs (info,"_ftrace_enum_map" , +sizeof (*mod->trace_enums), + &mod->num_trace_enums);#endif #ifdef CONFIG_TRACING mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt",
kernel/trace/trace.c +45 -4
71 lines not on this page · raw message
kernel/trace/trace_events.c +1 -1
@@ -2034,7 +2034,7 @@ static int trace_module_notify(struct notifier_block *self,static struct notifier_block trace_module_nb = { .notifier_call = trace_module_notify, - .priority =0 , + .priority =1 ,/* higher than trace.c module notify */ };#endif /* CONFIG_MODULES */
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 12/21 tracing/samples: Update the trace-event-sample.h with TRACE_DEFINE_ENUM()
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Document the use of TRACE_DEFINE_ENUM() by adding enums to the trace-event-sample.h and using this macro to convert them in the format files.
Also update the comments and sho the use of __print_symbolic() and __print_flags() as well as adding comments abount __print_array().
--- samples/trace_events/trace-events-sample.h | 64 +++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)
samples/trace_events/trace-events-sample.h +63 -1
@@ -198,8 +198,30 @@ static inline int __length_of(const int *list) ;return i; } + +enum { +TRACE_SAMPLE_FOO =2 , +TRACE_SAMPLE_BAR =4 , +TRACE_SAMPLE_ZOO =8 , +};#endif +/* +* If enums are used in the TP_printk(), their names will be shown in +* format files and not their values. This can cause problems with user +* space programs that parse the format files to know how to translate +* the raw binary trace output into human readable text. +* +* To help out user space programs, any enum that is used in the TP_printk() +* should be defined by TRACE_DEFINE_ENUM() macro. All that is needed to +* be done is to add this macro with the enum within it in the trace +* header file, and it will be converted in the output. +*/ + +TRACE_DEFINE_ENUM (TRACE_SAMPLE_FOO ); +TRACE_DEFINE_ENUM (TRACE_SAMPLE_BAR ); +TRACE_DEFINE_ENUM (TRACE_SAMPLE_ZOO ); + TRACE_EVENT(foo_bar, TP_PROTO(const char *foo, int bar, const int *lst,
@@ -224,7 +246,47 @@ TRACE_EVENT(foo_bar,__assign_bitmask (cpus,cpumask_bits (mask),num_possible_cpus ()); ), - TP_printk("foo %s %d %s %s (%s)", __entry->foo, __entry->bar, + TP_printk("foo %s %d %s %s %s %s (%s)", __entry->foo, __entry->bar, + +/* + * Notice here the use of some helper functions. This includes: + * + * __print_symbolic( variable, { value, "string" }, ... ), + * + * The variable is tested against each value of the { } pair. If + * the variable matches one of the values, then it will print the + * string in that pair. If non are matched, it returns a string + * version of the number (if __entry->bar == 7 then "7" is returned). + */ + __print_symbolic(__entry->bar, + { 0, "zero" }, + { TRACE_SAMPLE_FOO, "TWO" }, + { TRACE_SAMPLE_BAR, "FOUR" }, + { TRACE_SAMPLE_ZOO, "EIGHT" }, + { 10, "TEN" } + ), + +/* + * __print_flags( variable, "delim", { value, "flag" }, ... ), + * + * This is similar to __print_symbolic, except that it tests the bits + * of the value. If ((FLAG & variable) == FLAG) then the string is + * printed. If more than one flag matches, then each one that does is + * also printed with delim in between them. + * If not all bits are accounted for, then the not found bits will be + * added in hex format: 0x506 will show BIT2|BIT4|0x500 + */ + __print_flags(__entry->bar, "|", + { 1, "BIT1" }, + { 2, "BIT2" }, + { 4, "BIT3" }, + { 8, "BIT4" } + ), +/* + * __print_array( array, len, element_size ) + * + * This prints out the array that is defined by __array in a nice format. + */ __print_array(__get_dynamic_array(list), __get_dynamic_array_len(list), sizeof(int)),
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 13/21 x86/tlb/trace: Export enums in used by tlb_flush tracepoint
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Have the enums used in __print_symbolic() by the trace_tlb_flush() tracepoint exported to userpace such that they can be parsed by userspace tools.
--- include/trace/events/tlb.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
include/trace/events/tlb.h +25 -5
@@ -7,11 +7,31 @@#include <linux/mm_types.h> #include <linux/tracepoint.h> -#define TLB_FLUSH_REASON \ - { TLB_FLUSH_ON_TASK_SWITCH, "flush on task switch" }, \ - { TLB_REMOTE_SHOOTDOWN, "remote shootdown" }, \ - { TLB_LOCAL_SHOOTDOWN, "local shootdown" }, \ - { TLB_LOCAL_MM_SHOOTDOWN, "local mm shootdown" } +#define TLB_FLUSH_REASON \ + EM( TLB_FLUSH_ON_TASK_SWITCH, "flush on task switch" ) \ + EM( TLB_REMOTE_SHOOTDOWN, "remote shootdown" ) \ + EM( TLB_LOCAL_SHOOTDOWN, "local shootdown" ) \ + EMe( TLB_LOCAL_MM_SHOOTDOWN, "local mm shootdown" ) + +/* +* First define the enums in TLB_FLUSH_REASON to be exported to userspace +* via TRACE_DEFINE_ENUM(). +*/ +#undef EM +#undef EMe +#define EM (a,b) TRACE_DEFINE_ENUM(a); +#define EMe (a,b) TRACE_DEFINE_ENUM(a); + +TLB_FLUSH_REASON + +/* +* Now redefine the EM() and EMe() macros to map the enums to the strings +* that will be printed in the output. + */ +#undef EM +#undef EMe +#define EM (a,b) { a, b }, +#define EMe (a,b) { a, b } TRACE_EVENT_CONDITION(tlb_flush,
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 14/21 net/9p/tracing: Export enums in tracepoints to userspace
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
The tracepoints in the 9p code use a lot of enums for the __print_symbolic() function. These enums are shown in the tracepoint format files, and user space tools such as trace-cmd does not have the information to parse it. Add helper macros to export the enums with TRACE_DEFINE_ENUM().
--- include/trace/events/9p.h | 157 ++++++++++++++++++++++++++-------------------- 1 file changed, 88 insertions(+), 69 deletions(-)
include/trace/events/9p.h +88 -69
@@ -6,76 +6,95 @@#include <linux/tracepoint.h> +#define P9_MSG_T \ + EM( P9_TLERROR, "P9_TLERROR" ) \ + EM( P9_RLERROR, "P9_RLERROR" ) \ + EM( P9_TSTATFS, "P9_TSTATFS" ) \ + EM( P9_RSTATFS, "P9_RSTATFS" ) \ + EM( P9_TLOPEN, "P9_TLOPEN" ) \ + EM( P9_RLOPEN, "P9_RLOPEN" ) \ + EM( P9_TLCREATE, "P9_TLCREATE" ) \ + EM( P9_RLCREATE, "P9_RLCREATE" ) \ + EM( P9_TSYMLINK, "P9_TSYMLINK" ) \ + EM( P9_RSYMLINK, "P9_RSYMLINK" ) \ + EM( P9_TMKNOD, "P9_TMKNOD" ) \ + EM( P9_RMKNOD, "P9_RMKNOD" ) \ + EM( P9_TRENAME, "P9_TRENAME" ) \ + EM( P9_RRENAME, "P9_RRENAME" ) \ + EM( P9_TREADLINK, "P9_TREADLINK" ) \ + EM( P9_RREADLINK, "P9_RREADLINK" ) \ + EM( P9_TGETATTR, "P9_TGETATTR" ) \ + EM( P9_RGETATTR, "P9_RGETATTR" ) \ + EM( P9_TSETATTR, "P9_TSETATTR" ) \ + EM( P9_RSETATTR, "P9_RSETATTR" ) \ + EM( P9_TXATTRWALK, "P9_TXATTRWALK" ) \ + EM( P9_RXATTRWALK, "P9_RXATTRWALK" ) \ + EM( P9_TXATTRCREATE, "P9_TXATTRCREATE" ) \ + EM( P9_RXATTRCREATE, "P9_RXATTRCREATE" ) \ + EM( P9_TREADDIR, "P9_TREADDIR" ) \ + EM( P9_RREADDIR, "P9_RREADDIR" ) \ + EM( P9_TFSYNC, "P9_TFSYNC" ) \ + EM( P9_RFSYNC, "P9_RFSYNC" ) \ + EM( P9_TLOCK, "P9_TLOCK" ) \ + EM( P9_RLOCK, "P9_RLOCK" ) \ + EM( P9_TGETLOCK, "P9_TGETLOCK" ) \ + EM( P9_RGETLOCK, "P9_RGETLOCK" ) \ + EM( P9_TLINK, "P9_TLINK" ) \ + EM( P9_RLINK, "P9_RLINK" ) \ + EM( P9_TMKDIR, "P9_TMKDIR" ) \ + EM( P9_RMKDIR, "P9_RMKDIR" ) \ + EM( P9_TRENAMEAT, "P9_TRENAMEAT" ) \ + EM( P9_RRENAMEAT, "P9_RRENAMEAT" ) \ + EM( P9_TUNLINKAT, "P9_TUNLINKAT" ) \ + EM( P9_RUNLINKAT, "P9_RUNLINKAT" ) \ + EM( P9_TVERSION, "P9_TVERSION" ) \ + EM( P9_RVERSION, "P9_RVERSION" ) \ + EM( P9_TAUTH, "P9_TAUTH" ) \ + EM( P9_RAUTH, "P9_RAUTH" ) \ + EM( P9_TATTACH, "P9_TATTACH" ) \ + EM( P9_RATTACH, "P9_RATTACH" ) \ + EM( P9_TERROR, "P9_TERROR" ) \ + EM( P9_RERROR, "P9_RERROR" ) \ + EM( P9_TFLUSH, "P9_TFLUSH" ) \ + EM( P9_RFLUSH, "P9_RFLUSH" ) \ + EM( P9_TWALK, "P9_TWALK" ) \ + EM( P9_RWALK, "P9_RWALK" ) \ + EM( P9_TOPEN, "P9_TOPEN" ) \ + EM( P9_ROPEN, "P9_ROPEN" ) \ + EM( P9_TCREATE, "P9_TCREATE" ) \ + EM( P9_RCREATE, "P9_RCREATE" ) \ + EM( P9_TREAD, "P9_TREAD" ) \ + EM( P9_RREAD, "P9_RREAD" ) \ + EM( P9_TWRITE, "P9_TWRITE" ) \ + EM( P9_RWRITE, "P9_RWRITE" ) \ + EM( P9_TCLUNK, "P9_TCLUNK" ) \ + EM( P9_RCLUNK, "P9_RCLUNK" ) \ + EM( P9_TREMOVE, "P9_TREMOVE" ) \ + EM( P9_RREMOVE, "P9_RREMOVE" ) \ + EM( P9_TSTAT, "P9_TSTAT" ) \ + EM( P9_RSTAT, "P9_RSTAT" ) \ + EM( P9_TWSTAT, "P9_TWSTAT" ) \ + EMe(P9_RWSTAT, "P9_RWSTAT" ) + +/* Define EM() to export the enums to userspace via TRACE_DEFINE_ENUM() */ +#undef EM +#undef EMe +#define EM (a, b) TRACE_DEFINE_ENUM(a); +#define EMe (a, b) TRACE_DEFINE_ENUM(a); + +P9_MSG_T + +/* +* Now redefine the EM() and EMe() macros to map the enums to the strings +* that will be printed in the output. + */ +#undef EM +#undef EMe +#define EM (a, b) { a, b }, +#define EMe (a, b) { a, b } +#define show_9p_op (type) \ - __print_symbolic(type, \ - { P9_TLERROR, "P9_TLERROR" }, \ - { P9_RLERROR, "P9_RLERROR" }, \ - { P9_TSTATFS, "P9_TSTATFS" }, \ - { P9_RSTATFS, "P9_RSTATFS" }, \ - { P9_TLOPEN, "P9_TLOPEN" }, \ - { P9_RLOPEN, "P9_RLOPEN" }, \ - { P9_TLCREATE, "P9_TLCREATE" }, \ - { P9_RLCREATE, "P9_RLCREATE" }, \ - { P9_TSYMLINK, "P9_TSYMLINK" }, \ - { P9_RSYMLINK, "P9_RSYMLINK" }, \ - { P9_TMKNOD, "P9_TMKNOD" }, \ - { P9_RMKNOD, "P9_RMKNOD" }, \ - { P9_TRENAME, "P9_TRENAME" }, \ - { P9_RRENAME, "P9_RRENAME" }, \ - { P9_TREADLINK, "P9_TREADLINK" }, \ - { P9_RREADLINK, "P9_RREADLINK" }, \ - { P9_TGETATTR, "P9_TGETATTR" }, \ - { P9_RGETATTR, "P9_RGETATTR" }, \ - { P9_TSETATTR, "P9_TSETATTR" }, \ - { P9_RSETATTR, "P9_RSETATTR" }, \ - { P9_TXATTRWALK, "P9_TXATTRWALK" }, \ - { P9_RXATTRWALK, "P9_RXATTRWALK" }, \ - { P9_TXATTRCREATE, "P9_TXATTRCREATE" }, \ - { P9_RXATTRCREATE, "P9_RXATTRCREATE" }, \ - { P9_TREADDIR, "P9_TREADDIR" }, \ - { P9_RREADDIR, "P9_RREADDIR" }, \ - { P9_TFSYNC, "P9_TFSYNC" }, \ - { P9_RFSYNC, "P9_RFSYNC" }, \ - { P9_TLOCK, "P9_TLOCK" }, \ - { P9_RLOCK, "P9_RLOCK" }, \ - { P9_TGETLOCK, "P9_TGETLOCK" }, \ - { P9_RGETLOCK, "P9_RGETLOCK" }, \ - { P9_TLINK, "P9_TLINK" }, \ - { P9_RLINK, "P9_RLINK" }, \ - { P9_TMKDIR, "P9_TMKDIR" }, \ - { P9_RMKDIR, "P9_RMKDIR" }, \ - { P9_TRENAMEAT, "P9_TRENAMEAT" }, \ - { P9_RRENAMEAT, "P9_RRENAMEAT" }, \ - { P9_TUNLINKAT, "P9_TUNLINKAT" }, \ - { P9_RUNLINKAT, "P9_RUNLINKAT" }, \ - { P9_TVERSION, "P9_TVERSION" }, \ - { P9_RVERSION, "P9_RVERSION" }, \ - { P9_TAUTH, "P9_TAUTH" }, \ - { P9_RAUTH, "P9_RAUTH" }, \ - { P9_TATTACH, "P9_TATTACH" }, \ - { P9_RATTACH, "P9_RATTACH" }, \ - { P9_TERROR, "P9_TERROR" }, \ - { P9_RERROR, "P9_RERROR" }, \ - { P9_TFLUSH, "P9_TFLUSH" }, \ - { P9_RFLUSH, "P9_RFLUSH" }, \ - { P9_TWALK, "P9_TWALK" }, \ - { P9_RWALK, "P9_RWALK" }, \ - { P9_TOPEN, "P9_TOPEN" }, \ - { P9_ROPEN, "P9_ROPEN" }, \ - { P9_TCREATE, "P9_TCREATE" }, \ - { P9_RCREATE, "P9_RCREATE" }, \ - { P9_TREAD, "P9_TREAD" }, \ - { P9_RREAD, "P9_RREAD" }, \ - { P9_TWRITE, "P9_TWRITE" }, \ - { P9_RWRITE, "P9_RWRITE" }, \ - { P9_TCLUNK, "P9_TCLUNK" }, \ - { P9_RCLUNK, "P9_RCLUNK" }, \ - { P9_TREMOVE, "P9_TREMOVE" }, \ - { P9_RREMOVE, "P9_RREMOVE" }, \ - { P9_TSTAT, "P9_TSTAT" }, \ - { P9_RSTAT, "P9_RSTAT" }, \ - { P9_TWSTAT, "P9_TWSTAT" }, \ - { P9_RWSTAT, "P9_RWSTAT" }) + __print_symbolic(type, P9_MSG_T) TRACE_EVENT(9p_client_req, TP_PROTO(struct p9_client *clnt, int8_t type, int tag),
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 15/21 f2fs: Export the enums in the tracepoints to userspace
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
The tracepoints that use __print_symbolic() use enums as the value to convert to strings. Unfortunately, the format files for these tracepoints show the enum name and not their value. This causes some userspace tools not to know how to convert __print_symbolic() to their strings.
Add TRACE_DEFINE_ENUM() macros to export the enums used to userspace to let those tools know what those enum values are.
--- include/trace/events/f2fs.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
include/trace/events/f2fs.h +30 -0
@@ -9,6 +9,36 @@#define show_dev (entry) MAJOR(entry->dev), MINOR(entry->dev)#define show_dev_ino (entry) show_dev(entry), (unsigned long)entry->ino +TRACE_DEFINE_ENUM (NODE ); +TRACE_DEFINE_ENUM (DATA ); +TRACE_DEFINE_ENUM (META ); +TRACE_DEFINE_ENUM (META_FLUSH ); +TRACE_DEFINE_ENUM (CURSEG_HOT_DATA ); +TRACE_DEFINE_ENUM (CURSEG_WARM_DATA ); +TRACE_DEFINE_ENUM (CURSEG_COLD_DATA ); +TRACE_DEFINE_ENUM (CURSEG_HOT_NODE ); +TRACE_DEFINE_ENUM (CURSEG_WARM_NODE ); +TRACE_DEFINE_ENUM (CURSEG_COLD_NODE ); +TRACE_DEFINE_ENUM (NO_CHECK_TYPE ); +TRACE_DEFINE_ENUM (GC_GREEDY ); +TRACE_DEFINE_ENUM (GC_CB ); +TRACE_DEFINE_ENUM (FG_GC ); +TRACE_DEFINE_ENUM (BG_GC ); +TRACE_DEFINE_ENUM (LFS ); +TRACE_DEFINE_ENUM (SSR ); +TRACE_DEFINE_ENUM (__REQ_RAHEAD); +TRACE_DEFINE_ENUM (__REQ_WRITE); +TRACE_DEFINE_ENUM (__REQ_SYNC); +TRACE_DEFINE_ENUM (__REQ_NOIDLE); +TRACE_DEFINE_ENUM (__REQ_FLUSH); +TRACE_DEFINE_ENUM (__REQ_FUA); +TRACE_DEFINE_ENUM (__REQ_PRIO); +TRACE_DEFINE_ENUM (__REQ_META); +TRACE_DEFINE_ENUM (CP_UMOUNT ); +TRACE_DEFINE_ENUM (CP_FASTBOOT ); +TRACE_DEFINE_ENUM (CP_SYNC ); +TRACE_DEFINE_ENUM (CP_DISCARD ); +#define show_block_type (type) \ __print_symbolic(type, \ { NODE, "NODE" }, \
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 16/21 irq/tracing: Export enums in tracepoints to user space
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
The enums used by the softirq mapping is what is shown in the output of the __print_symbolic() and not their values, that are needed to map them to their strings. Export them to userspace with the TRACE_DEFINE_ENUM() macro so that user space tools can map the enums with their values.
--- include/trace/events/irq.h | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-)
include/trace/events/irq.h +27 -12
@@ -9,19 +9,34 @@struct irqaction ;struct softirq_action ; -#define softirq_name (sirq) { sirq##_SOFTIRQ, #sirq } +#define SOFTIRQ_NAME_LIST \ + softirq_name(HI) \ + softirq_name(TIMER) \ + softirq_name(NET_TX) \ + softirq_name(NET_RX) \ + softirq_name(BLOCK) \ + softirq_name(BLOCK_IOPOLL) \ + softirq_name(TASKLET) \ + softirq_name(SCHED) \ + softirq_name(HRTIMER) \ + softirq_name_end(RCU) + +#undef softirq_name +#undef softirq_name_end + +#define softirq_name (sirq) TRACE_DEFINE_ENUM(sirq##_SOFTIRQ); +#define softirq_name_end (sirq) TRACE_DEFINE_ENUM(sirq##_SOFTIRQ); + +SOFTIRQ_NAME_LIST + +#undef softirq_name +#undef softirq_name_end + +#define softirq_name (sirq) { sirq##_SOFTIRQ, #sirq }, +#define softirq_name_end (sirq) { sirq##_SOFTIRQ, #sirq } +#define show_softirq_name (val) \ - __print_symbolic(val, \ - softirq_name(HI), \ - softirq_name(TIMER), \ - softirq_name(NET_TX), \ - softirq_name(NET_RX), \ - softirq_name(BLOCK), \ - softirq_name(BLOCK_IOPOLL), \ - softirq_name(TASKLET), \ - softirq_name(SCHED), \ - softirq_name(HRTIMER), \ - softirq_name(RCU)) + __print_symbolic(val, SOFTIRQ_NAME_LIST)/** * irq_handler_entry - called immediately before the irq action handler
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 17/21 mm: tracing: Export enums in tracepoints to user space
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
The enums used in tracepoints with __print_symbolic() have their names shown in the tracepoint format files and not their values. This makes it difficult for user space tools to convert the binary data to the strings as user space does not know what those enums are about.
By having them use TRACE_DEFINE_ENUM(), the names of the enums will be mapped to the values and shown to user space.
--- include/trace/events/migrate.h | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-)
include/trace/events/migrate.h +32 -10
@@ -7,18 +7,40 @@#include <linux/tracepoint.h> #define MIGRATE_MODE \ - {MIGRATE_ASYNC, "MIGRATE_ASYNC"}, \ - {MIGRATE_SYNC_LIGHT, "MIGRATE_SYNC_LIGHT"}, \ - {MIGRATE_SYNC, "MIGRATE_SYNC"} + EM( MIGRATE_ASYNC, "MIGRATE_ASYNC") \ + EM( MIGRATE_SYNC_LIGHT, "MIGRATE_SYNC_LIGHT") \ + EMe(MIGRATE_SYNC, "MIGRATE_SYNC") +#define MIGRATE_REASON \ - {MR_COMPACTION, "compaction"}, \ - {MR_MEMORY_FAILURE, "memory_failure"}, \ - {MR_MEMORY_HOTPLUG, "memory_hotplug"}, \ - {MR_SYSCALL, "syscall_or_cpuset"}, \ - {MR_MEMPOLICY_MBIND, "mempolicy_mbind"}, \ - {MR_NUMA_MISPLACED, "numa_misplaced"}, \ - {MR_CMA, "cma"} + EM( MR_COMPACTION, "compaction") \ + EM( MR_MEMORY_FAILURE, "memory_failure") \ + EM( MR_MEMORY_HOTPLUG, "memory_hotplug") \ + EM( MR_SYSCALL, "syscall_or_cpuset") \ + EM( MR_MEMPOLICY_MBIND, "mempolicy_mbind") \ + EM( MR_NUMA_MISPLACED, "numa_misplaced") \ + EMe(MR_CMA, "cma") + +/* +* First define the enums in the above macros to be exported to userspace +* via TRACE_DEFINE_ENUM(). +*/ +#undef EM +#undef EMe +#define EM (a, b) TRACE_DEFINE_ENUM(a); +#define EMe (a, b) TRACE_DEFINE_ENUM(a); + +MIGRATE_MODE +MIGRATE_REASON + +/* +* Now redefine the EM() and EMe() macros to map the enums to the strings +* that will be printed in the output. + */ +#undef EM +#undef EMe +#define EM (a, b) {a, b}, +#define EMe (a, b) {a, b} TRACE_EVENT(mm_migrate_pages,
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 18/21 SUNRPC: Export enums in tracepoints to user space
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
The enums used in the tracepoints for __print_symbolic() have their names shown in the tracepoint format files. User space tools do not know how to convert those names into their values to be able to convert the binary data.
Use TRACE_DEFINE_ENUM() to export the enum names to their values for userspace to do the parsing correctly.
--- include/trace/events/sunrpc.h | 62 ++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 18 deletions(-)
include/trace/events/sunrpc.h +44 -18
@@ -179,27 +179,53 @@ DEFINE_EVENT(rpc_task_queued, rpc_task_wakeup, ); +/* +* First define the enums in the below macros to be exported to userspace +* via TRACE_DEFINE_ENUM(). +*/ +#undef EM +#undef EMe +#define EM (a, b) TRACE_DEFINE_ENUM(a); +#define EMe (a, b) TRACE_DEFINE_ENUM(a); + +#define RPC_SHOW_SOCKET \ + EM( SS_FREE, "FREE" ) \ + EM( SS_UNCONNECTED, "UNCONNECTED" ) \ + EM( SS_CONNECTING, "CONNECTING," ) \ + EM( SS_CONNECTED, "CONNECTED," ) \ + EMe(SS_DISCONNECTING, "DISCONNECTING" ) +#define rpc_show_socket_state (state) \ - __print_symbolic(state, \ - { SS_FREE, "FREE" }, \ - { SS_UNCONNECTED, "UNCONNECTED" }, \ - { SS_CONNECTING, "CONNECTING," }, \ - { SS_CONNECTED, "CONNECTED," }, \ - { SS_DISCONNECTING, "DISCONNECTING" }) + __print_symbolic(state, RPC_SHOW_SOCKET) + +RPC_SHOW_SOCKET + +#define RPC_SHOW_SOCK \ + EM( TCP_ESTABLISHED, "ESTABLISHED" ) \ + EM( TCP_SYN_SENT, "SYN_SENT" ) \ + EM( TCP_SYN_RECV, "SYN_RECV" ) \ + EM( TCP_FIN_WAIT1, "FIN_WAIT1" ) \ + EM( TCP_FIN_WAIT2, "FIN_WAIT2" ) \ + EM( TCP_TIME_WAIT, "TIME_WAIT" ) \ + EM( TCP_CLOSE, "CLOSE" ) \ + EM( TCP_CLOSE_WAIT, "CLOSE_WAIT" ) \ + EM( TCP_LAST_ACK, "LAST_ACK" ) \ + EM( TCP_LISTEN, "LISTEN" ) \ + EMe( TCP_CLOSING, "CLOSING" )#define rpc_show_sock_state (state) \ - __print_symbolic(state, \ - { TCP_ESTABLISHED, "ESTABLISHED" }, \ - { TCP_SYN_SENT, "SYN_SENT" }, \ - { TCP_SYN_RECV, "SYN_RECV" }, \ - { TCP_FIN_WAIT1, "FIN_WAIT1" }, \ - { TCP_FIN_WAIT2, "FIN_WAIT2" }, \ - { TCP_TIME_WAIT, "TIME_WAIT" }, \ - { TCP_CLOSE, "CLOSE" }, \ - { TCP_CLOSE_WAIT, "CLOSE_WAIT" }, \ - { TCP_LAST_ACK, "LAST_ACK" }, \ - { TCP_LISTEN, "LISTEN" }, \ - { TCP_CLOSING, "CLOSING" }) + __print_symbolic(state, RPC_SHOW_SOCK) + +RPC_SHOW_SOCK + +/* +* Now redefine the EM() and EMe() macros to map the enums to the strings +* that will be printed in the output. + */ +#undef EM +#undef EMe +#define EM (a, b) {a, b}, +#define EMe (a, b) {a, b} DECLARE_EVENT_CLASS(xs_socket_event,
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 19/21 v4l: Export enums used by tracepoints to user space
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Enums used by tracepoints for __print_symbolic() are shown in the tracepoint format files with just their names and not their values. This makes it difficult for user space tools to know how to convert the binary data into their string representations.
By adding the use of TRACE_DEFINE_ENUM(), the enum names will be mapped to their values and shown in the tracing file system to let tools convert the data as necessary.
--- include/trace/events/v4l2.h | 75 ++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 25 deletions(-)
include/trace/events/v4l2.h +50 -25
@@ -6,33 +6,58 @@#include <linux/tracepoint.h> -#define show_type (type) \ - __print_symbolic(type, \ - { V4L2_BUF_TYPE_VIDEO_CAPTURE, "VIDEO_CAPTURE" }, \ - { V4L2_BUF_TYPE_VIDEO_OUTPUT, "VIDEO_OUTPUT" }, \ - { V4L2_BUF_TYPE_VIDEO_OVERLAY, "VIDEO_OVERLAY" }, \ - { V4L2_BUF_TYPE_VBI_CAPTURE, "VBI_CAPTURE" }, \ - { V4L2_BUF_TYPE_VBI_OUTPUT, "VBI_OUTPUT" }, \ - { V4L2_BUF_TYPE_SLICED_VBI_CAPTURE, "SLICED_VBI_CAPTURE" }, \ - { V4L2_BUF_TYPE_SLICED_VBI_OUTPUT, "SLICED_VBI_OUTPUT" }, \ - { V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" },\ - { V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" },\ - { V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, "VIDEO_OUTPUT_MPLANE" }, \ - { V4L2_BUF_TYPE_SDR_CAPTURE, "SDR_CAPTURE" }, \ - { V4L2_BUF_TYPE_PRIVATE, "PRIVATE" }) +/* Enums require being exported to userspace, for user tool parsing */ +#undef EM +#undef EMe +#define EM (a, b) TRACE_DEFINE_ENUM(a); +#define EMe (a, b) TRACE_DEFINE_ENUM(a); + +#define show_type (type) \ + __print_symbolic(type, SHOW_TYPE) + +#define SHOW_TYPE \ + EM( V4L2_BUF_TYPE_VIDEO_CAPTURE, "VIDEO_CAPTURE" ) \ + EM( V4L2_BUF_TYPE_VIDEO_OUTPUT, "VIDEO_OUTPUT" ) \ + EM( V4L2_BUF_TYPE_VIDEO_OVERLAY, "VIDEO_OVERLAY" ) \ + EM( V4L2_BUF_TYPE_VBI_CAPTURE, "VBI_CAPTURE" ) \ + EM( V4L2_BUF_TYPE_VBI_OUTPUT, "VBI_OUTPUT" ) \ + EM( V4L2_BUF_TYPE_SLICED_VBI_CAPTURE, "SLICED_VBI_CAPTURE" ) \ + EM( V4L2_BUF_TYPE_SLICED_VBI_OUTPUT, "SLICED_VBI_OUTPUT" ) \ + EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" ) \ + EM( V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" ) \ + EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, "VIDEO_OUTPUT_MPLANE" ) \ + EM( V4L2_BUF_TYPE_SDR_CAPTURE, "SDR_CAPTURE" ) \ + EMe(V4L2_BUF_TYPE_PRIVATE, "PRIVATE" ) + +SHOW_TYPE#define show_field (field) \ - __print_symbolic(field, \ - { V4L2_FIELD_ANY, "ANY" }, \ - { V4L2_FIELD_NONE, "NONE" }, \ - { V4L2_FIELD_TOP, "TOP" }, \ - { V4L2_FIELD_BOTTOM, "BOTTOM" }, \ - { V4L2_FIELD_INTERLACED, "INTERLACED" }, \ - { V4L2_FIELD_SEQ_TB, "SEQ_TB" }, \ - { V4L2_FIELD_SEQ_BT, "SEQ_BT" }, \ - { V4L2_FIELD_ALTERNATE, "ALTERNATE" }, \ - { V4L2_FIELD_INTERLACED_TB, "INTERLACED_TB" }, \ - { V4L2_FIELD_INTERLACED_BT, "INTERLACED_BT" }) + __print_symbolic(field, SHOW_FIELD) + +#define SHOW_FIELD \ + EM( V4L2_FIELD_ANY, "ANY" ) \ + EM( V4L2_FIELD_NONE, "NONE" ) \ + EM( V4L2_FIELD_TOP, "TOP" ) \ + EM( V4L2_FIELD_BOTTOM, "BOTTOM" ) \ + EM( V4L2_FIELD_INTERLACED, "INTERLACED" ) \ + EM( V4L2_FIELD_SEQ_TB, "SEQ_TB" ) \ + EM( V4L2_FIELD_SEQ_BT, "SEQ_BT" ) \ + EM( V4L2_FIELD_ALTERNATE, "ALTERNATE" ) \ + EM( V4L2_FIELD_INTERLACED_TB, "INTERLACED_TB" ) \ + EMe( V4L2_FIELD_INTERLACED_BT, "INTERLACED_BT" ) + +SHOW_FIELD + +/* +* Now redefine the EM() and EMe() macros to map the enums to the strings +* that will be printed in the output. + */ +#undef EM +#undef EMe +#define EM (a, b) {a, b}, +#define EMe (a, b) {a, b} + +/* V4L2_TC_TYPE_* are macros, not defines, they do not need processing */ #define show_timecode_type (type) \ __print_symbolic(type, \
Signature · 1 line
2.1.4
Re: [for-next][PATCH 19/21] v4l: Export enums used by tracepoints to user space
Em Wed, 08 Apr 2015 09:48:23 -0400
Steven Rostedt <[email protected]> escreveu:
Quoted 7 lines
From: "Steven Rostedt (Red Hat)" <[email protected]>
Enums used by tracepoints for
__print_symbolic()are shown in the tracepoint format files with just their names and not their values. This makes it difficult for user space tools to know how to convert the binary data into their string representations.
Quoted 7 lines
By adding the use of
TRACE_DEFINE_ENUM(), the enum names will be mapped to their values and shown in the tracing file system to let tools convert the data as necessary.Cc Mauro Carvalho Chehab <[email protected]>
Quoted 95 lines
Reviewed-by Masami Hiramatsu <[email protected]>Tested-by Masami Hiramatsu <[email protected]>Signed-off-by Steven Rostedt <[email protected]>--- include/trace/events/v4l2.h | 75 ++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 25 deletions(-)include/trace/events/v4l2.h +50
-25@@ -6,33 +6,58 @@#include <linux/tracepoint.h> -#define show_type (type) \ - __print_symbolic(type, \ - { V4L2_BUF_TYPE_VIDEO_CAPTURE, "VIDEO_CAPTURE" }, \ - { V4L2_BUF_TYPE_VIDEO_OUTPUT, "VIDEO_OUTPUT" }, \ - { V4L2_BUF_TYPE_VIDEO_OVERLAY, "VIDEO_OVERLAY" }, \ - { V4L2_BUF_TYPE_VBI_CAPTURE, "VBI_CAPTURE" }, \ - { V4L2_BUF_TYPE_VBI_OUTPUT, "VBI_OUTPUT" }, \ - { V4L2_BUF_TYPE_SLICED_VBI_CAPTURE, "SLICED_VBI_CAPTURE" }, \ - { V4L2_BUF_TYPE_SLICED_VBI_OUTPUT, "SLICED_VBI_OUTPUT" }, \ - { V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" },\ - { V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" },\ - { V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, "VIDEO_OUTPUT_MPLANE" }, \ - { V4L2_BUF_TYPE_SDR_CAPTURE, "SDR_CAPTURE" }, \ - { V4L2_BUF_TYPE_PRIVATE, "PRIVATE" }) +/* Enums require being exported to userspace, for user tool parsing */ +#undef EM +#undef EMe +#define EM (a, b) TRACE_DEFINE_ENUM(a); +#define EMe (a, b) TRACE_DEFINE_ENUM(a); + +#define show_type (type) \ + __print_symbolic(type, SHOW_TYPE) + +#define SHOW_TYPE \ + EM( V4L2_BUF_TYPE_VIDEO_CAPTURE, "VIDEO_CAPTURE" ) \ + EM( V4L2_BUF_TYPE_VIDEO_OUTPUT, "VIDEO_OUTPUT" ) \ + EM( V4L2_BUF_TYPE_VIDEO_OVERLAY, "VIDEO_OVERLAY" ) \ + EM( V4L2_BUF_TYPE_VBI_CAPTURE, "VBI_CAPTURE" ) \ + EM( V4L2_BUF_TYPE_VBI_OUTPUT, "VBI_OUTPUT" ) \ + EM( V4L2_BUF_TYPE_SLICED_VBI_CAPTURE, "SLICED_VBI_CAPTURE" ) \ + EM( V4L2_BUF_TYPE_SLICED_VBI_OUTPUT, "SLICED_VBI_OUTPUT" ) \ + EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, "VIDEO_OUTPUT_OVERLAY" ) \ + EM( V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, "VIDEO_CAPTURE_MPLANE" ) \ + EM( V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, "VIDEO_OUTPUT_MPLANE" ) \ + EM( V4L2_BUF_TYPE_SDR_CAPTURE, "SDR_CAPTURE" ) \ + EMe(V4L2_BUF_TYPE_PRIVATE, "PRIVATE" ) + +SHOW_TYPE#define show_field (field) \ - __print_symbolic(field, \ - { V4L2_FIELD_ANY, "ANY" }, \ - { V4L2_FIELD_NONE, "NONE" }, \ - { V4L2_FIELD_TOP, "TOP" }, \ - { V4L2_FIELD_BOTTOM, "BOTTOM" }, \ - { V4L2_FIELD_INTERLACED, "INTERLACED" }, \ - { V4L2_FIELD_SEQ_TB, "SEQ_TB" }, \ - { V4L2_FIELD_SEQ_BT, "SEQ_BT" }, \ - { V4L2_FIELD_ALTERNATE, "ALTERNATE" }, \ - { V4L2_FIELD_INTERLACED_TB, "INTERLACED_TB" }, \ - { V4L2_FIELD_INTERLACED_BT, "INTERLACED_BT" }) + __print_symbolic(field, SHOW_FIELD) + +#define SHOW_FIELD \ + EM( V4L2_FIELD_ANY, "ANY" ) \ + EM( V4L2_FIELD_NONE, "NONE" ) \ + EM( V4L2_FIELD_TOP, "TOP" ) \ + EM( V4L2_FIELD_BOTTOM, "BOTTOM" ) \ + EM( V4L2_FIELD_INTERLACED, "INTERLACED" ) \ + EM( V4L2_FIELD_SEQ_TB, "SEQ_TB" ) \ + EM( V4L2_FIELD_SEQ_BT, "SEQ_BT" ) \ + EM( V4L2_FIELD_ALTERNATE, "ALTERNATE" ) \ + EM( V4L2_FIELD_INTERLACED_TB, "INTERLACED_TB" ) \ + EMe( V4L2_FIELD_INTERLACED_BT, "INTERLACED_BT" ) + +SHOW_FIELD + +/* +* Now redefine the EM() and EMe() macros to map the enums to the strings +* that will be printed in the output. + */ +#undef EM +#undef EMe +#define EM (a, b) {a, b}, +#define EMe (a, b) {a, b} + +/* V4L2_TC_TYPE_* are macros, not defines, they do not need processing */ #define show_timecode_type (type) \ __print_symbolic(type, \
Steven Rostedt
maintainerRe: [for-next][PATCH 19/21] v4l: Export enums used by tracepoints to user space
Quoted 14 lines · On Wed, 8 Apr 2015 11:43:02 -0300 Mauro Carvalho Chehab…
Em Wed, 08 Apr 2015 09:48:23 -0400
Steven Rostedt <[email protected]> escreveu:Quoted 11 lines
From: "Steven Rostedt (Red Hat)" <[email protected]>
Enums used by tracepoints for
__print_symbolic()are shown in the tracepoint format files with just their names and not their values. This makes it difficult for user space tools to know how to convert the binary data into their string representations.By adding the use of
TRACE_DEFINE_ENUM(), the enum names will be mapped to their values and shown in the tracing file system to let tools convert the data as necessary.
Quoted 6 lines
Quoted 3 lines
Cc Mauro Carvalho Chehab <[email protected]>
Thanks!
-- Steve
Steven Rostedt
maintainerPATCH 20/21 writeback: Export enums used by tracepoint to user space
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
The enums used in tracepoints for __print_symbolic() do not have their values shown in the tracepoint format files and this makes it difficult for user space tools to convert the binary values to the strings they are to represent.
Add TRACE_DEFINE_ENUM(x) macros to export the enum names to their values to make the tracing output from user space tools more robust.
--- include/trace/events/writeback.h | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-)
include/trace/events/writeback.h +25 -8
@@ -23,15 +23,32 @@ {I_REFERENCED, "I_REFERENCED"} \ ) +/* enums need to be exported to user space */ +#undef EM +#undef EMe +#define EM (a,b) TRACE_DEFINE_ENUM(a); +#define EMe (a,b) TRACE_DEFINE_ENUM(a); +#define WB_WORK_REASON \ - {WB_REASON_BACKGROUND, "background"}, \ - {WB_REASON_TRY_TO_FREE_PAGES, "try_to_free_pages"}, \ - {WB_REASON_SYNC, "sync"}, \ - {WB_REASON_PERIODIC, "periodic"}, \ - {WB_REASON_LAPTOP_TIMER, "laptop_timer"}, \ - {WB_REASON_FREE_MORE_MEM, "free_more_memory"}, \ - {WB_REASON_FS_FREE_SPACE, "fs_free_space"}, \ - {WB_REASON_FORKER_THREAD, "forker_thread"} + EM( WB_REASON_BACKGROUND, "background") \ + EM( WB_REASON_TRY_TO_FREE_PAGES, "try_to_free_pages") \ + EM( WB_REASON_SYNC, "sync") \ + EM( WB_REASON_PERIODIC, "periodic") \ + EM( WB_REASON_LAPTOP_TIMER, "laptop_timer") \ + EM( WB_REASON_FREE_MORE_MEM, "free_more_memory") \ + EM( WB_REASON_FS_FREE_SPACE, "fs_free_space") \ + EMe(WB_REASON_FORKER_THREAD, "forker_thread") + +WB_WORK_REASON + +/* +* Now redefine the EM() and EMe() macros to map the enums to the strings +* that will be printed in the output. + */ +#undef EM +#undef EMe +#define EM (a,b) { a, b }, +#define EMe (a,b) { a, b }struct wb_writeback_work ;
Signature · 1 line
2.1.4
Steven Rostedt
maintainerPATCH 21/21 tracing: Add enum_map file to show enums that have been mapped
In reply to Steven RostedtFrom: "Steven Rostedt (Red Hat)" <[email protected]>
Add a enum_map file in the tracing directory to see what enums have been saved to convert in the print fmt files.
As this requires the enum mapping to be persistent in memory, it is only created if the new config option CONFIG_TRACE_ENUM_MAP_FILE is enabled. This is for debugging and will increase the persistent memory footprint of the kernel.
--- kernel/trace/Kconfig | 28 ++++++ kernel/trace/trace.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 269 insertions(+), 4 deletions(-)
kernel/trace/Kconfig +28 -0
@@ -599,6 +599,34 @@ config RING_BUFFER_STARTUP_TEST If unsure, say N +config TRACE_ENUM_MAP_FILE + bool "Show enum mappings for trace events" + depends on TRACING + help + The "print fmt" of the trace events will show the enum names instead + of their values. This can cause problems for user space tools that + use this string to parse the raw data as user space does not know + how to convert the string to its value. + + To fix this, there's a special macro in the kernel that can be used + to convert the enum into its value. If this macro is used, then the + print fmt strings will have the enums converted to their values. + + If something does not get converted properly, this option can be + used to show what enums the kernel tried to convert. + + This option is for debugging the enum conversions. A file is created + in the tracing directory called "enum_map" that will show the enum + names matched with their values and what trace event system they + belong too. + + Normally, the mapping of the strings to values will be freed after + boot up or module load. With this option, they will not be freed, as + they are needed for the "enum_map" file. Enabling this option will + increase the memory footprint of the running kernel. + + If unsure, say N + endif # FTRACE endif # TRACING_SUPPORT
kernel/trace/trace.c +241 -4
295 lines not on this page · raw message
Signature · 1 line
2.1.4