Synchronize libtraceevent with trace-cmd
cover Synchronize libtraceevent with trace-cmd
Backported traceevent library patches from trace-cmd lib/traceevent
Jan Kiszka (2):
tools lib traceevent: Add more SVM exit reasons
tools lib traceevent: Fix reporting of unknown SVM exit reasons
Julia Cartwright (1):
tools lib traceevent: Add plugin for decoding syscalls/sys_enter_futex
Steven Rostedt (Red Hat) (2):
tools lib traceevent: Add --debug to trace-cmd report tools lib traceevent: Add plugin for tlb_flush
Steven Rostedt (VMware) (3):
tools lib traceevent: Add -O offset for function plugin tools lib traceevent: Add builtin handler for trace_marker_raw tools lib traceevent: Change to SPDX License format
Tom Zanussi (1):
tools lib traceevent: Add proper KBUFFER_TYPE_TIME_STAMP handling
Tzvetomir Stoyanov (VMware) (6):
tools lib traceevent: Remove trace-cmd plugin handling routines tools lib traceevent: Move plugin options from trace-cmd to
libtraceevent.
tools lib traceevent: Introduced new traceevent API, for adding new
plugins directories.
tools lib traceevent: Add support for more printk format specifiers tools lib traceevent: Optimize pretty_print() function tools lib traceevent: Move kernel_stack event handler to "function"
plugin.
tools/lib/traceevent/event-parse-local.h | 22 +- tools/lib/traceevent/event-parse.c | 1004 ++++++++++++----- tools/lib/traceevent/event-parse.h | 34 +- tools/lib/traceevent/event-plugin.c | 261 ++++- tools/lib/traceevent/kbuffer-parse.c | 43 +- tools/lib/traceevent/kbuffer.h | 19 +- tools/lib/traceevent/plugins/Build | 2 + tools/lib/traceevent/plugins/Makefile | 2 + .../lib/traceevent/plugins/plugin_function.c | 123 +- tools/lib/traceevent/plugins/plugin_futex.c | 123 ++ tools/lib/traceevent/plugins/plugin_hrtimer.c | 17 +- tools/lib/traceevent/plugins/plugin_jbd2.c | 17 +- tools/lib/traceevent/plugins/plugin_kmem.c | 17 +- tools/lib/traceevent/plugins/plugin_kvm.c | 42 +- .../lib/traceevent/plugins/plugin_mac80211.c | 17 +- .../traceevent/plugins/plugin_sched_switch.c | 17 +- tools/lib/traceevent/plugins/plugin_tlb.c | 66 ++ 17 files changed, 1406 insertions(+), 420 deletions(-) create mode 100644 tools/lib/traceevent/plugins/plugin_futex.c create mode 100644 tools/lib/traceevent/plugins/plugin_tlb.c
Signature · 1 line
2.26.2
PATCH 1/15 tools lib traceevent: Add --debug to trace-cmd report
From: Steven Rostedt (Red Hat) <[email protected]>
Add --debug option to trace-cmd report that enables page boundary recording as well as time stamp info to be printed.
--- tools/lib/traceevent/kbuffer-parse.c | 28 ++++++++++++++++++++++++++++ tools/lib/traceevent/kbuffer.h | 2 ++ 2 files changed, 30 insertions(+)
tools/lib/traceevent/kbuffer-parse.c +28 -0
@@ -546,6 +546,34 @@ int kbuffer_load_subbuffer(struct kbuffer *kbuf, void *subbuffer)return 0 ; } +/** +* kbuffer_subbuf_timestamp - read the timestamp from a sub buffer +* @kbuf: The kbuffer to load +* @subbuf: The subbuffer to read from. +* +* Return the timestamp from a subbuffer. +*/ +unsigned long long kbuffer_subbuf_timestamp (struct kbuffer *kbuf,void *subbuf) +{ +return kbuf->read_8 (subbuf); +} + +/** +* kbuffer_ptr_delta - read the delta field from a record +* @kbuf: The kbuffer to load +* @ptr: The record in the buffe. +* +* Return the timestamp delta from a record +*/ +unsigned int kbuffer_ptr_delta (struct kbuffer *kbuf,void *ptr) +{ +unsigned int type_len_ts; + + type_len_ts =read_4 (kbuf, ptr); +return ts4host (kbuf, type_len_ts); +} + +/** * kbuffer_read_event - read the next event in the kbuffer subbuffer * @kbuf: The kbuffer to read from
tools/lib/traceevent/kbuffer.h +2 -0
@@ -49,6 +49,8 @@ int kbuffer_load_subbuffer(struct kbuffer *kbuf, void *subbuffer);void *kbuffer_read_event (struct kbuffer *kbuf,unsigned long long *ts);void *kbuffer_next_event (struct kbuffer *kbuf,unsigned long long *ts);unsigned long long kbuffer_timestamp (struct kbuffer *kbuf); +unsigned long long kbuffer_subbuf_timestamp (struct kbuffer *kbuf,void *subbuf); +unsigned int kbuffer_ptr_delta (struct kbuffer *kbuf,void *ptr);void *kbuffer_translate_data (int swap,void *data,unsigned int *size);
Signature · 1 line
2.26.2
PATCH 2/15 tools lib traceevent: Add proper KBUFFER_TYPE_TIME_STAMP handling
In reply to Tzvetomir Stoyanov (VMware)From: Tom Zanussi <[email protected]>
Kernel commit dc4e2801d400 (ring-buffer: Redefine the unimplemented RINGBUF_TYPE_TIME_STAMP) changed the way the ring buffer timestamps work - after that commit the previously unimplemented RINGBUF_TYPE_TIME_STAMP type causes the time delta to be used as a timestamp rather than a delta to be added to the timestamp.
The trace-cmd code didn't get updated to handle this, so misinterprets the event data for this case, which causes a cascade of errors, including trace-report not being able to identify synthetic (or any other) events generated by the histogram code (which uses TIME_STAMP mode). For example, the following triggers along with the trace-cmd shown cause an UNKNOWN_EVENT error and trace-cmd report crash:
# echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > /sys/kernel/debug/tracing/synthetic_events
# echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > /sys/kernel/debug/tracing/events/sched/sched_wakeup/trigger # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).trace(wakeup_latency,$wakeup_lat,next_pid,next_comm) if next_comm=="ping"' > /sys/kernel/debug/tracing/events/sched/sched_switch/trigger # echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/trigger
# trace-cmd record -e wakeup_latency -e sched_wakeup -f comm==\"ping\" ping localhost -c 5
# trace-cmd report
CPU 0 is empty
CPU 1 is empty
CPU 2 is empty
CPU 3 is empty
CPU 5 is empty
CPU 6 is empty
CPU 7 is empty
cpus=8
ug! no event found for type 0
[UNKNOWN TYPE 0]
ug! no event found for type 11520
Segmentation fault (core dumped)After this patch we get the correct interpretation and the events are shown properly:
# trace-cmd report
CPU 0 is empty
CPU 1 is empty
CPU 2 is empty
CPU 3 is empty
CPU 5 is empty
CPU 6 is empty
CPU 7 is empty
cpus=8
<idle>-0 [004] 23284.341392: sched_wakeup: ping:12031 [120] success=1 CPU:004
<idle>-0 [004] 23284.341464: wakeup_latency: lat=58, pid=12031, comm=ping
<idle>-0 [004] 23285.365303: sched_wakeup: ping:12031 [120] success=1 CPU:004
<idle>-0 [004] 23285.365382: wakeup_latency: lat=64, pid=12031, comm=ping
<idle>-0 [004] 23286.389290: sched_wakeup: ping:12031 [120] success=1 CPU:004
<idle>-0 [004] 23286.389378: wakeup_latency: lat=72, pid=12031, comm=ping
<idle>-0 [004] 23287.413213: sched_wakeup: ping:12031 [120] success=1 CPU:004
<idle>-0 [004] 23287.413291: wakeup_latency: lat=64, pid=12031, comm=ping--- tools/lib/traceevent/kbuffer-parse.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
tools/lib/traceevent/kbuffer-parse.c +9 -6
@@ -361,6 +361,7 @@ translate_data(struct kbuffer *kbuf, void *data, void **rptr,break ;case KBUFFER_TYPE_TIME_EXTEND : +case KBUFFER_TYPE_TIME_STAMP : extend =read_4 (kbuf, data); data +=4 ; extend <<=TS_SHIFT ;
@@ -369,10 +370,6 @@ translate_data(struct kbuffer *kbuf, void *data, void **rptr, *length =0 ;break ; -case KBUFFER_TYPE_TIME_STAMP : - data +=12 ; - *length =0 ; -break ;case 0 : *length =read_4 (kbuf, data) -4 ; *length = (*length +3 ) & ~3 ;
@@ -397,7 +394,11 @@ static unsigned int update_pointers(struct kbuffer *kbuf) type_len =translate_data (kbuf, ptr, &ptr, &delta, &length); - kbuf->timestamp += delta; +if (type_len ==KBUFFER_TYPE_TIME_STAMP ) + kbuf->timestamp = delta; +else + kbuf->timestamp += delta; + kbuf->index =calc_index (kbuf, ptr); kbuf->next = kbuf->index + length;
@@ -454,7 +455,9 @@ static int __next_event(struct kbuffer *kbuf)if (kbuf->next >= kbuf->size)return -1 ; type =update_pointers (kbuf); - }while (type ==KBUFFER_TYPE_TIME_EXTEND || type ==KBUFFER_TYPE_PADDING ); + }while (type ==KBUFFER_TYPE_TIME_EXTEND || + type ==KBUFFER_TYPE_TIME_STAMP || + type ==KBUFFER_TYPE_PADDING );return 0 ; }
Signature · 1 line
2.26.2
PATCH 3/15 tools lib traceevent: Remove trace-cmd plugin handling routines
In reply to Tzvetomir Stoyanov (VMware)Currently there are no trace-cmd related plugins, all of them are designed to be used with libtraceeevnt. As both libtraceevent and trace-cmd have logic for managing plugins, the one in trace-cmd is redundant. Those redundant code is removed and replaced with calls to libtraceeevnt plugin APIs. When trace-cmd has to load any plugins, it uses libtraceeevnt to do the job.
Removed trace-cmd functions:
tracecmd_load_plugins()
tracecmd_unload_plugins()
trace_util_load_plugins()
trace_util_read_plugin_options()
trace_util_free_options()
trace_util_print_plugins()
trace_util_free_plugin_options_list()
A new libtraceevent API is added:
tep_load_plugins_hook() - the local static
function load_plugins() is exposed as API, as this functionality is needed be trace-cmd.
--- tools/lib/traceevent/event-parse.h | 6 ++++++ tools/lib/traceevent/event-plugin.c | 19 +++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-)
tools/lib/traceevent/event-parse.h +6 -0
@@ -396,6 +396,12 @@ struct tep_plugin_list;struct tep_plugin_list *tep_load_plugins (struct tep_handle *tep);void tep_unload_plugins (struct tep_plugin_list *plugin_list,struct tep_handle *tep); +void tep_load_plugins_hook (struct tep_handle *tep,const char *suffix, +void (*load_plugin)(struct tep_handle *tep, +const char *path, +const char *name, +void *data), +void *data);char **tep_plugin_list_options (void );void tep_plugin_free_options_list (char **list); int tep_plugin_add_options(const char *name,
tools/lib/traceevent/event-plugin.c +9 -10
@@ -365,20 +365,19 @@ load_plugins_dir(struct tep_handle *tep, const char *suffix,closedir (dir); } -static void -load_plugins (struct tep_handle *tep,const char *suffix, -void (*load_plugin)(struct tep_handle *tep, -const char *path, -const char *name, -void *data), -void *data) +void tep_load_plugins_hook (struct tep_handle *tep,const char *suffix, +void (*load_plugin)(struct tep_handle *tep, +const char *path, +const char *name, +void *data), +void *data) {char *home;char *path;char *envdir;int ret; -if (tep->flags &TEP_DISABLE_PLUGINS ) +if (tep && tep->flags &TEP_DISABLE_PLUGINS )return ;/*
@@ -386,7 +385,7 @@ load_plugins(struct tep_handle *tep, const char *suffix,* check that first. */ #ifdef PLUGIN_DIR -if (!(tep->flags &TEP_DISABLE_SYS_PLUGINS )) +if (!tep || !(tep->flags &TEP_DISABLE_SYS_PLUGINS ))load_plugins_dir (tep, suffix,PLUGIN_DIR , load_plugin, data);#endif
@@ -423,7 +422,7 @@ tep_load_plugins(struct tep_handle *tep) {struct tep_plugin_list *list =NULL ; -load_plugins (tep,".so" , load_plugin, &list); +tep_load_plugins_hook (tep,".so" , load_plugin, &list);return list; }
Signature · 1 line
2.26.2
PATCH 4/15 tools lib traceevent: Move plugin options from trace-cmd to libtraceevent.
In reply to Tzvetomir Stoyanov (VMware)There are two different implementations of plugin options, which work in parallel - one in trace-cmd and the other one in libtraceevent. Both have the same functionality and most of the implementation is the same, duplicated. As currently there are only libtraceevent plugins,the implementation plugin options should be in libtraceevent only.
--- tools/lib/traceevent/event-parse.h | 2 + tools/lib/traceevent/event-plugin.c | 172 ++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+)
tools/lib/traceevent/event-parse.h +2 -0
@@ -406,7 +406,9 @@ char **tep_plugin_list_options(void);void tep_plugin_free_options_list (char **list);int tep_plugin_add_options (const char *name,struct tep_plugin_option *options); +int tep_plugin_add_option (const char *name,const char *val);void tep_plugin_remove_options (struct tep_plugin_option *options); +void tep_plugin_print_options (struct trace_seq *s);void tep_print_plugins (struct trace_seq *s,const char *prefix,const char *suffix,const struct tep_plugin_list *list);
tools/lib/traceevent/event-plugin.c +172 -0
196 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 5/15 tools lib traceevent: Introduced new traceevent API, for adding new plugins directories.
In reply to Tzvetomir Stoyanov (VMware)Implement new traceevent plugin API, which can be used to add new plugins directories:
enum tep_plugin_load_priority {
TEP_PLUGIN_FIRST,
TEP_PLUGIN_LAST,
};
int tep_add_plugin_path(struct tep_handle *tep, char *path,
enum tep_plugin_load_priority prio);
It adds the "path" as new plugin directory, in the context of the handler "tep". The tep_load_plugins() API searches for plugins in this new location. Depending of the priority "prio", the plugins from this directory are loaded before (TEP_PLUGIN_FIRST) or after (TEP_PLUGIN_LAST) the ordinary libtraceevent plugin locations.
--- tools/lib/traceevent/event-parse-local.h | 5 +- tools/lib/traceevent/event-parse.c | 1 + tools/lib/traceevent/event-parse.h | 7 +++ tools/lib/traceevent/event-plugin.c | 70 ++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 1 deletion(-)
tools/lib/traceevent/event-parse-local.h +4 -1
@@ -13,6 +13,7 @@ struct func_map;struct func_list ;struct event_handler ;struct func_resolver ; +struct tep_plugins_dir ;struct tep_handle {int ref_count;
@@ -47,7 +48,6 @@ struct tep_handle {struct printk_list *printklist;unsigned int printk_count; -struct tep_event **events;int nr_events;struct tep_event **sort_events;
@@ -81,10 +81,13 @@ struct tep_handle {/* cache */ struct tep_event *last_event; + +struct tep_plugins_dir *plugins_dir; };void tep_free_event (struct tep_event *event);void tep_free_format_field (struct tep_format_field *field); +void tep_free_plugin_paths (struct tep_handle *tep);unsigned short tep_data2host2 (struct tep_handle *tep,unsigned short data);unsigned int tep_data2host4 (struct tep_handle *tep,unsigned int data);
tools/lib/traceevent/event-parse.c +1 -0
@@ -7119,6 +7119,7 @@ void tep_free(struct tep_handle *tep)free (tep->events);free (tep->sort_events);free (tep->func_resolver); +tep_free_plugin_paths (tep);free (tep); }
tools/lib/traceevent/event-parse.h +7 -0
@@ -393,6 +393,13 @@ struct tep_plugin_list;#define INVALID_PLUGIN_LIST_OPTION ((char **)((unsigned long)-1)) +enum tep_plugin_load_priority { +TEP_PLUGIN_FIRST , +TEP_PLUGIN_LAST , +}; + +int tep_add_plugin_path (struct tep_handle *tep,char *path, +enum tep_plugin_load_priority prio);struct tep_plugin_list *tep_load_plugins (struct tep_handle *tep);void tep_unload_plugins (struct tep_plugin_list *plugin_list,struct tep_handle *tep);
tools/lib/traceevent/event-plugin.c +70 -0
100 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 6/15 tools lib traceevent: Add support for more printk format specifiers
In reply to Tzvetomir Stoyanov (VMware)The printk format specifiers used in event's print format files extend the standard printf formats. There are a lot of new options related to printing pointers and kernel specific structures. Currently trace-cmd does not support many of them.
Support for these new printk specifiers is added to the pretty_print() function:
- UUID/GUID address: %pU[bBlL]
- Raw buffer as a hex string: %*ph[CDN]
These are improved:
- MAC address: %pMF, %pM and %pmR
- IPv4 adderss: %p[Ii]4[hnbl]
Function pretty_print() is refactored. The logic for printing pointers %p[...] is moved to its own function.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207605
--- tools/lib/traceevent/event-parse.c | 363 +++++++++++++++++++++++------ 1 file changed, 289 insertions(+), 74 deletions(-)
tools/lib/traceevent/event-parse.c +289 -74
@@ -4564,43 +4564,93 @@ get_bprint_format(void *data, int size __maybe_unused,return format; } -static void print_mac_arg (struct trace_seq *s,int mac,void *data,int size, -struct tep_event *event,struct tep_print_arg *arg) +static int print_mac_arg (struct trace_seq *s,const char *format, +void *data,int size,struct tep_event *event, +struct tep_print_arg *arg) { -unsigned char *buf;const char *fmt ="%.2x:%.2x:%.2x:%.2x:%.2x:%.2x" ; +bool reverse = false; +unsigned char *buf; +int ret =0 ;if (arg->type ==TEP_PRINT_FUNC ) {process_defined_func (s, data, size, event, arg); -return ; +return 0 ; }if (arg->type !=TEP_PRINT_FIELD ) {trace_seq_printf (s,"ARG TYPE NOT FIELD BUT %d" , arg->type); -return ; +return 0 ; } -if (mac =='m' ) +if (format[0 ] =='m' ) { fmt ="%.2x%.2x%.2x%.2x%.2x%.2x" ; + }else if (format[0 ] =='M' && format[1 ] =='F' ) { + fmt ="%.2x-%.2x-%.2x-%.2x-%.2x-%.2x" ; + ret++; + } +if (format[1 ] =='R' ) { + reverse = true; + ret++; + } +if (!arg->field.field) { arg->field.field =tep_find_any_field (event, arg->field.name);if (!arg->field.field) {do_warning_event (event,"%s: field %s not found" , __func__, arg->field.name); -return ; +return ret; } }if (arg->field.field->size !=6 ) {trace_seq_printf (s,"INVALIDMAC" ); -return ; +return ret; } + buf = data + arg->field.field->offset; -trace_seq_printf (s, fmt, buf[0 ], buf[1 ], buf[2 ], buf[3 ], buf[4 ], buf[5 ]); +if (reverse) +trace_seq_printf (s, fmt, buf[5 ], buf[4 ], buf[3 ], buf[2 ], buf[1 ], buf[0 ]); +else +trace_seq_printf (s, fmt, buf[0 ], buf[1 ], buf[2 ], buf[3 ], buf[4 ], buf[5 ]); + +return ret; +} + +static int parse_ip4_print_args (struct tep_handle *tep, +const char *ptr,bool *reverse) +{ +int ret =0 ; + + *reverse = false; + +/* hnbl */ +switch (*ptr) { +case 'h' : +if (tep->file_bigendian) + *reverse = false; +else + *reverse = true; + ret++; +break ; +case 'l' : + *reverse = true; + ret++; +break ; +case 'n' : +case 'b' : + ret++; +/* fall through */ +default : + *reverse = false; +break ; + } + +return ret; } -static void print_ip4_addr (struct trace_seq *s,char i,unsigned char *buf) +static void print_ip4_addr (struct trace_seq *s,char i,bool reverse,unsigned char *buf) {const char *fmt;
@@ -4609,7 +4659,11 @@ static void print_ip4_addr(struct trace_seq *s, char i, unsigned char *buf)else fmt ="%d.%d.%d.%d" ; -trace_seq_printf (s, fmt, buf[0 ], buf[1 ], buf[2 ], buf[3 ]); +if (reverse) +trace_seq_printf (s, fmt, buf[3 ], buf[2 ], buf[1 ], buf[0 ]); +else +trace_seq_printf (s, fmt, buf[0 ], buf[1 ], buf[2 ], buf[3 ]); + }static inline bool ipv6_addr_v4mapped (const struct in6_addr *a)
@@ -4692,7 +4746,7 @@ static void print_ip6c_addr(struct trace_seq *s, unsigned char *addr)if (useIPv4) {if (needcolon)trace_seq_printf (s,":" ); -print_ip4_addr (s,'I' , &in6.s6_addr[12 ]); +print_ip4_addr (s,'I' , false, &in6.s6_addr[12 ]); }return ;
@@ -4721,16 +4775,20 @@ static int print_ipv4_arg(struct trace_seq *s, const char *ptr, char i, void *data, int size, struct tep_event *event, struct tep_print_arg *arg) { + bool reverse = false;unsigned char *buf; +int ret; + + ret =parse_ip4_print_args (event->tep, ptr, &reverse);if (arg->type ==TEP_PRINT_FUNC ) {process_defined_func (s, data, size, event, arg); -return 0 ; +return ret; }if (arg->type !=TEP_PRINT_FIELD ) {trace_seq_printf (s,"ARG TYPE NOT FIELD BUT %d" , arg->type); -return 0 ; +return ret; }if (!arg->field.field) {
@@ -4739,7 +4797,7 @@ static int print_ipv4_arg(struct trace_seq *s, const char *ptr, char i,if (!arg->field.field) {do_warning ("%s: field %s not found" , __func__, arg->field.name); -return 0 ; +return ret; } }
@@ -4747,11 +4805,12 @@ static int print_ipv4_arg(struct trace_seq *s, const char *ptr, char i,if (arg->field.field->size !=4 ) {trace_seq_printf (s,"INVALIDIPv4" ); -return 0 ; +return ret; } -print_ip4_addr (s, i, buf); -return 0 ; +print_ip4_addr (s, i, reverse, buf); +return ret; + } static int print_ipv6_arg(struct trace_seq *s, const char *ptr, char i,
@@ -4811,7 +4870,9 @@ static int print_ipsa_arg(struct trace_seq *s, const char *ptr, char i,char have_c =0 , have_p =0 ;unsigned char *buf;struct sockaddr_storage *sa; +bool reverse = false;int rc =0 ; +int ret;/* pISpc */ if (i =='I' ) {
@@ -4826,6 +4887,9 @@ static int print_ipsa_arg(struct trace_seq *s, const char *ptr, char i, rc++; } } + ret =parse_ip4_print_args (event->tep, ptr, &reverse); + ptr += ret; + rc += ret;if (arg->type ==TEP_PRINT_FUNC ) {process_defined_func (s, data, size, event, arg);
@@ -4857,7 +4921,7 @@ static int print_ipsa_arg(struct trace_seq *s, const char *ptr, char i,return rc; } -print_ip4_addr (s, i, (unsigned char *) &sa4->sin_addr); +print_ip4_addr (s, i, reverse, (unsigned char *) &sa4->sin_addr);if (have_p)trace_seq_printf (s,":%d" ,ntohs (sa4->sin_port));
@@ -4891,25 +4955,20 @@ static int print_ip_arg(struct trace_seq *s, const char *ptr, struct tep_print_arg *arg) {char i = *ptr;/* 'i' or 'I' */ -char ver; -int rc =0 ; - - ptr++; - rc++; +int rc =1 ; - ver = *ptr; +/* IP version */ ptr++; - rc++; -switch (ver) { +switch (*ptr) {case '4' : - rc +=print_ipv4_arg (s, ptr, i, data, size, event, arg); + rc +=print_ipv4_arg (s, ptr +1 , i, data, size, event, arg);break ;case '6' : - rc +=print_ipv6_arg (s, ptr, i, data, size, event, arg); + rc +=print_ipv6_arg (s, ptr +1 , i, data, size, event, arg);break ;case 'S' : - rc +=print_ipsa_arg (s, ptr, i, data, size, event, arg); + rc +=print_ipsa_arg (s, ptr +1 , i, data, size, event, arg);break ;default :return 0 ;
@@ -4918,6 +4977,133 @@ static int print_ip_arg(struct trace_seq *s, const char *ptr,return rc; } +static const int guid_index[16 ] = {3 ,2 ,1 ,0 ,5 ,4 ,7 ,6 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 }; +static const int uuid_index[16 ] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 }; + +static int print_uuid_arg (struct trace_seq *s,const char *ptr, +void *data,int size,struct tep_event *event, +struct tep_print_arg *arg) +{ +const int *index = uuid_index; +char *format ="%02x" ; +int ret =0 ; +char *buf; +int i; + +switch (*(ptr +1 )) { +case 'L' : + format ="%02X" ; +/* fall through */ +case 'l' : + index = guid_index; + ret++; +break ; +case 'B' : + format ="%02X" ; +/* fall through */ +case 'b' : + ret++; +break ; + } + +if (arg->type ==TEP_PRINT_FUNC ) { +process_defined_func (s, data, size, event, arg); +return ret; + } + +if (arg->type !=TEP_PRINT_FIELD ) { +trace_seq_printf (s,"ARG TYPE NOT FIELD BUT %d" , arg->type); +return ret; + } + +if (!arg->field.field) { + arg->field.field = +tep_find_any_field (event, arg->field.name); +if (!arg->field.field) { +do_warning ("%s: field %s not found" , + __func__, arg->field.name); +return ret; + } + } + +if (arg->field.field->size !=16 ) { +trace_seq_printf (s,"INVALIDUUID" ); +return ret; + } + + buf = data + arg->field.field->offset; + +for (i =0 ; i <16 ; i++) { +trace_seq_printf (s, format, buf[index[i]] &0xff ); +switch (i) { +case 3 : +case 5 : +case 7 : +case 9 : +trace_seq_printf (s,"-" ); +break ; + } + } + +return ret; +} + +static int print_raw_buff_arg (struct trace_seq *s,const char *ptr, +void *data,int size,struct tep_event *event, +struct tep_print_arg *arg,int print_len) +{ +int plen = print_len; +char *delim =" " ; +int ret =0 ; +char *buf; +int i; +unsigned long offset; +int arr_len; + +switch (*(ptr +1 )) { +case 'C' : + delim =":" ; + ret++; +break ; +case 'D' : + delim ="-" ; + ret++; +break ; +case 'N' : + delim ="" ; + ret++; +break ; + } + +if (arg->type ==TEP_PRINT_FUNC ) { +process_defined_func (s, data, size, event, arg); +return ret; + } + +if (arg->type !=TEP_PRINT_DYNAMIC_ARRAY ) { +trace_seq_printf (s,"ARG TYPE NOT FIELD BUT %d" , arg->type); +return ret; + } + + offset =tep_read_number (event->tep, + data + arg->dynarray.field->offset, + arg->dynarray.field->size); + arr_len = (unsigned long long )(offset >>16 ); + buf = data + (offset &0xffff ); + +if (arr_len < plen) + plen = arr_len; + +if (plen <1 ) +return ret; + +trace_seq_printf (s,"%02x" , buf[0 ] &0xff ); +for (i =1 ; i < plen; i++) +trace_seq_printf (s,"%s%02x" , delim, buf[i] &0xff ); + +return ret; +} +static int is_printable_array (char *p,unsigned int len) {unsigned int i;
@@ -5006,6 +5192,68 @@ void tep_print_fields(struct trace_seq *s, void *data, } } +static int print_function (struct trace_seq *s,const char *format, +void *data,int size,struct tep_event *event, +struct tep_print_arg *arg) +{ +struct func_map *func; +unsigned long long val; + + val =eval_num_arg (data, size, event, arg); + func =find_func (event->tep, val); +if (func) { +trace_seq_puts (s, func->func); +if (*format =='F' || *format =='S' ) +trace_seq_printf (s,"+0x%llx" , val - func->addr); + }else { +if (event->tep->long_size ==4 ) +trace_seq_printf (s,"0x%lx" , (long )val); +else +trace_seq_printf (s,"0x%llx" , (long long )val); + } + +return 0 ; +} + +static int print_pointer (struct trace_seq *s,const char *format,int plen, +void *data,int size, +struct tep_event *event,struct tep_print_arg *arg) +{ +unsigned long long val; +int ret =1 ; + +switch (*format) { +case 'F' : +case 'f' : +case 'S' : +case 's' : + ret +=print_function (s, format, data, size, event, arg); +break ; +case 'M' : +case 'm' : + ret +=print_mac_arg (s, format, data, size, event, arg); +break ; +case 'I' : +case 'i' : + ret +=print_ip_arg (s, format, data, size, event, arg); +break ; +case 'U' : + ret +=print_uuid_arg (s, format, data, size, event, arg); +break ; +case 'h' : + ret +=print_raw_buff_arg (s, format, data, size, event, arg, plen); +break ; +default : + ret =0 ; + val =eval_num_arg (data, size, event, arg); +trace_seq_printf (s,"%p" , (void *)val); +break ; + } + +return ret; + +} +static void pretty_print (struct trace_seq *s,void *data,int size,struct tep_event *event) {struct tep_handle *tep = event->tep;
@@ -5014,16 +5262,15 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_estruct tep_print_arg *args =NULL ;const char *ptr = print_fmt->format;unsigned long long val; -struct func_map *func;const char *saveptr;struct trace_seq p;char *bprint_fmt =NULL ;char format[32 ]; -int show_func;int len_as_arg;int len_arg =0 ;int len;int ls; +int ret;if (event->flags &TEP_EVENT_FL_FAILED ) {trace_seq_printf (s,"[FAILED TO PARSE]" );
@@ -5062,7 +5309,6 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_e }else if (*ptr =='%' ) { saveptr = ptr; - show_func =0 ; len_as_arg =0 ; cont_process: ptr++;
@@ -5100,39 +5346,21 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_ecase '-' : goto cont_process;case 'p' : -if (tep->long_size ==4 ) - ls =1 ; -else - ls =2 ; - -if (isalnum (ptr[1 ])) - ptr++; -if (arg->type ==TEP_PRINT_BSTRING ) { +if (isalnum (ptr[1 ])) + ptr++;trace_seq_puts (s, arg->string.string); arg = arg->next;break ; } - -if (*ptr =='F' || *ptr =='f' || - *ptr =='S' || *ptr =='s' ) { - show_func = *ptr; - }else if (*ptr =='M' || *ptr =='m' ) { -print_mac_arg (s, *ptr, data, size, event, arg); - arg = arg->next; -break ; - }else if (*ptr =='I' || *ptr =='i' ) { -int n; - - n =print_ip_arg (s, ptr, data, size, event, arg); -if (n >0 ) { - ptr += n -1 ; - arg = arg->next; -break ; - } - } - -/* fall through */ + ret =print_pointer (s, ptr +1 , + len_as_arg ? len_arg :1 , + data, size, + event, arg); + arg = arg->next; +if (ret >0 ) + ptr += ret; +break ;case 'd' :case 'u' :case 'i' :
@@ -5161,17 +5389,6 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_e val =eval_num_arg (data, size, event, arg); arg = arg->next; -if (show_func) { - func =find_func (tep, val); -if (func) { -trace_seq_puts (s, func->func); -if (show_func =='F' ) -trace_seq_printf (s, -"+0x%llx" , - val - func->addr); -break ; - } - }if (tep->long_size ==8 && ls ==1 &&sizeof (long ) !=8 ) {char *p;
@@ -5179,8 +5396,6 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct tep_e/* make %l into %ll */ if (ls ==1 && (p =strchr (format,'l' )))memmove (p+1 , p,strlen (p)+1 ); -else if (strcmp (format,"%p" ) ==0 ) -strcpy (format,"0x%llx" ); ls =2 ; }switch (ls) {
Signature · 1 line
2.26.2
PATCH 7/15 tools lib traceevent: Optimize pretty_print() function
In reply to Tzvetomir Stoyanov (VMware)Each time the pretty_print() function is called to print an event, the event's format string is parsed. As this format string does not change, this parsing can be done only once - when the event struct is initialized.
--- tools/lib/traceevent/event-parse-local.h | 17 + tools/lib/traceevent/event-parse.c | 672 ++++++++++++++++------- tools/lib/traceevent/event-parse.h | 3 + 3 files changed, 495 insertions(+), 197 deletions(-)
tools/lib/traceevent/event-parse-local.h +17 -0
@@ -85,6 +85,23 @@ struct tep_handle {struct tep_plugins_dir *plugins_dir; }; +enum tep_print_parse_type { +PRINT_FMT_STING , +PRINT_FMT_ARG_DIGIT , +PRINT_FMT_ARG_POINTER , +PRINT_FMT_ARG_STRING , +}; + +struct tep_print_parse { +struct tep_print_parse *next; + +char *format; +int ls; +enum tep_print_parse_type type; +struct tep_print_arg *arg; +struct tep_print_arg *len_as_arg; +}; +void tep_free_event (struct tep_event *event);void tep_free_format_field (struct tep_format_field *field);void tep_free_plugin_paths (struct tep_handle *tep);
tools/lib/traceevent/event-parse.c +475 -197
735 lines not on this page · raw message
tools/lib/traceevent/event-parse.h +3 -0
@@ -272,9 +272,12 @@ struct tep_print_arg { }; }; +struct tep_print_parse ; +struct tep_print_fmt {char *format;struct tep_print_arg *args; +struct tep_print_parse *print_cache; };struct tep_event {
Signature · 1 line
2.26.2
PATCH 8/15 tools lib traceevent: Add plugin for tlb_flush
In reply to Tzvetomir Stoyanov (VMware)From: Steven Rostedt (Red Hat) <[email protected]>
The tlb_flush tracepoints uses enums that are not yet known by trace-cmd. Add a plugin to handle that.
--- tools/lib/traceevent/plugins/Build | 1 + tools/lib/traceevent/plugins/Makefile | 1 + tools/lib/traceevent/plugins/plugin_tlb.c | 81 +++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 tools/lib/traceevent/plugins/plugin_tlb.c
tools/lib/traceevent/plugins/Build +1 -0
@@ -8,3 +8,4 @@ plugin_function-y += plugin_function.o plugin_xen-y += plugin_xen.o plugin_scsi-y += plugin_scsi.o plugin_cfg80211-y += plugin_cfg80211.o +plugin_tlb-y += plugin_tlb.o
tools/lib/traceevent/plugins/Makefile +1 -0
@@ -137,6 +137,7 @@ PLUGINS += plugin_function.so PLUGINS += plugin_xen.so PLUGINS += plugin_scsi.so PLUGINS += plugin_cfg80211.so +PLUGINS += plugin_tlb.so PLUGINS := $(addprefix $(OUTPUT),$(PLUGINS)) PLUGINS_IN := $(PLUGINS:.so=-in.o)
tools/lib/traceevent/plugins/plugin_tlb.c new file +81 -0
81 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 9/15 tools lib traceevent: Add more SVM exit reasons
In reply to Tzvetomir Stoyanov (VMware)From: Jan Kiszka <[email protected]>
Exceptions require individual decoding (only feasible intercepts listed), XSETBV was missing and the AVIC brought in two new exit codes.
--- tools/lib/traceevent/plugins/plugin_kvm.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
tools/lib/traceevent/plugins/plugin_kvm.c +21 -2
@@ -155,7 +155,23 @@ static const char *disassemble(unsigned char *insn, int len, uint64_t rip, _ER(EXIT_WRITE_DR5, 0x035) \ _ER(EXIT_WRITE_DR6, 0x036) \ _ER(EXIT_WRITE_DR7, 0x037) \ - _ER(EXIT_EXCP_BASE, 0x040) \ + _ER(EXIT_EXCP_DE, 0x040) \ + _ER(EXIT_EXCP_DB, 0x041) \ + _ER(EXIT_EXCP_BP, 0x043) \ + _ER(EXIT_EXCP_OF, 0x044) \ + _ER(EXIT_EXCP_BR, 0x045) \ + _ER(EXIT_EXCP_UD, 0x046) \ + _ER(EXIT_EXCP_NM, 0x047) \ + _ER(EXIT_EXCP_DF, 0x048) \ + _ER(EXIT_EXCP_TS, 0x04a) \ + _ER(EXIT_EXCP_NP, 0x04b) \ + _ER(EXIT_EXCP_SS, 0x04c) \ + _ER(EXIT_EXCP_GP, 0x04d) \ + _ER(EXIT_EXCP_PF, 0x04e) \ + _ER(EXIT_EXCP_MF, 0x050) \ + _ER(EXIT_EXCP_AC, 0x051) \ + _ER(EXIT_EXCP_MC, 0x052) \ + _ER(EXIT_EXCP_XF, 0x053) \ _ER(EXIT_INTR, 0x060) \ _ER(EXIT_NMI, 0x061) \_ER (EXIT_SMI ,0x062 ) \
@@ -201,7 +217,10 @@ static const char *disassemble(unsigned char *insn, int len, uint64_t rip, _ER(EXIT_MONITOR, 0x08a) \ _ER(EXIT_MWAIT, 0x08b) \ _ER(EXIT_MWAIT_COND, 0x08c) \ - _ER(EXIT_NPF, 0x400) \ + _ER(EXIT_XSETBV, 0x08d) \ + _ER(EXIT_NPF, 0x400) \ + _ER(EXIT_AVIC_INCOMPLETE_IPI, 0x401) \ + _ER(EXIT_AVIC_UNACCELERATED_ACCESS, 0x402) \ _ER(EXIT_ERR, -1)#define _ER (reason, val) { #reason, val },
Signature · 1 line
2.26.2
I just noticed that I only see 1-9, I'm missing 10-15 and so is patchwork.
Quoted 6 lines · On Thu, 25 Jun 2020 13:05:07 +0300 "Tzvetomir Stoyanov (VMware)"…
Backported traceevent library patches from trace-cmd lib/traceevent
Jan Kiszka (2):
tools lib traceevent: Add more SVM exit reasonstools lib traceevent: Fix reporting of unknown SVM exit reasons
Missing.
Quoted 3 lines
Julia Cartwright (1):
tools lib traceevent: Add plugin for decoding syscalls/sys_enter_futex
Missing.
Quoted 7 lines
Steven Rostedt (Red Hat) (2):
tools lib traceevent: Add --debug to trace-cmd report tools lib traceevent: Add plugin fortlb_flushSteven Rostedt (VMware) (3):
tools lib traceevent: Add -O offset for function plugin
Missing.
Quoted 1 line
tools lib traceevent: Add builtin handler for
trace_marker_raw
Missing.
Quoted 1 line
tools lib traceevent: Change to SPDX License format
Missing.
Quoted 13 lines
Tom Zanussi (1):
tools lib traceevent: Add properKBUFFER_TYPE_TIME_STAMPhandlingTzvetomir Stoyanov (VMware) (6):
tools lib traceevent: Remove trace-cmd plugin handling routines tools lib traceevent: Move plugin options from trace-cmd to
libtraceevent.
tools lib traceevent: Introduced new traceevent API, for adding new
plugins directories.
tools lib traceevent: Add support for more printk format specifiers tools lib traceevent: Optimizepretty_print()function
Quoted 2 lines
tools lib traceevent: Move
kernel_stackevent handler to "function"
plugin.
Missing.
-- Steve
Quoted 22 lines
tools/lib/traceevent/event-parse-local.h | 22 +- tools/lib/traceevent/event-parse.c | 1004 ++++++++++++----- tools/lib/traceevent/event-parse.h | 34 +- tools/lib/traceevent/event-plugin.c | 261 ++++- tools/lib/traceevent/kbuffer-parse.c | 43 +- tools/lib/traceevent/kbuffer.h | 19 +- tools/lib/traceevent/plugins/Build | 2 + tools/lib/traceevent/plugins/Makefile | 2 + .../lib/traceevent/plugins/plugin_function.c | 123 +- tools/lib/traceevent/plugins/plugin_futex.c | 123 ++ tools/lib/traceevent/plugins/plugin_hrtimer.c | 17 +- tools/lib/traceevent/plugins/plugin_jbd2.c | 17 +- tools/lib/traceevent/plugins/plugin_kmem.c | 17 +- tools/lib/traceevent/plugins/plugin_kvm.c | 42 +- .../lib/traceevent/plugins/plugin_mac80211.c | 17 +- .../traceevent/plugins/plugin_sched_switch.c | 17 +- tools/lib/traceevent/plugins/plugin_tlb.c | 66 ++ 17 files changed, 1406 insertions(+), 420 deletions(-) create mode 100644 tools/lib/traceevent/plugins/plugin_futex.c create mode 100644 tools/lib/traceevent/plugins/plugin_tlb.c