perf tools: Add traceevent plugins support
cover perf tools: Add traceevent plugins support
hi,
backporting traceevent plugin support from trace-cmd.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
Initial RFC is here:
http://marc.info/?l=linux-kernel&m=137803257921043&w=2
Having plugins allow traceevent to properly parse 'print fmt' line of tracepoint format and display proper/additional data in perf script command (check examples below).
Plugins backported from trace-cmd:
plugin_function.c
plugin_hrtimer.c
plugin_jbd2.c
plugin_kmem.c
plugin_kvm.c
plugin_mac80211.c
plugin_sched_switch.c
Plugins newly added:
plugin_cfg80211.c
plugin_scsi.c
plugin_xen.c
Changes from RFC:
- added comment about repo/HEAD of the backport source
- ommited options plugin support
- change plugins installation path to:
$(perfexecdir)/traceevent/plugins
The code is available in here:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/core_plugins
thanks,
jirka
Examples (diffs of 'perf script' output):
* data was generated by 'perf record -e 'cfg80211:*' -a' --- script.cfg80211.old
+++ script.cfg80211.new
- ifconfig 2705 [003] 662.896560: cfg80211:cfg80211_tx_mlme_mgmt: [FAILED TO PARSE] name=wlan0 ifindex=3 frame=ARRAY[c0, 00,
+ ifconfig 2705 [003] 662.896560: cfg80211:cfg80211_tx_mlme_mgmt: netdev:wlan0(3), ftype:0xc0
- kworker/u16:0 1697 [002] 664.808210: cfg80211:cfg80211_rx_mlme_mgmt: [FAILED TO PARSE] name=wlan0 ifindex=3 frame=ARRAY[b0, 00,
+ kworker/u16:0 1697 [002] 664.808210: cfg80211:cfg80211_rx_mlme_mgmt: netdev:wlan0(3), ftype:0xb0
* data was generated by 'perf record -e sched:sched_switch -a' --- script.sched_switch.old
+++ script.sched_switch.new
- perf 577 [002] 30965.311852: sched:sched_switch: prev_comm=perf prev_pid=577 prev_prio=120 prev_state=S ==> next_comm=sw
+ perf 577 [002] 30965.311852: sched:sched_switch: perf:577 [120] S ==> swapper/2:0 [120]
* data was generated by 'perf record -e ftrace:function ls' --- script.function.old
+++ script.function.new
- ls 10781 [001] 32667.291379: ftrace:function: ffffffff811adb80 <-- ffffffff811afc48
- ls 10781 [001] 32667.291379: ftrace:function: ffffffff811b35d0 <-- ffffffff811adb9b
- ls 10781 [001] 32667.291380: ftrace:function: ffffffff811b3520 <-- ffffffff811b35e8
- ls 10781 [001] 32667.291380: ftrace:function: ffffffff811b2720 <-- ffffffff811b3549
- ls 10781 [001] 32667.291381: ftrace:function: ffffffff81297e10 <-- ffffffff811b356c
- ls 10781 [001] 32667.291381: ftrace:function: ffffffff81298f40 <-- ffffffff81297e2c
- ls 10781 [001] 32667.291382: ftrace:function: ffffffff81076160 <-- ffffffff811afbf0
- ls 10781 [001] 32667.291383: ftrace:function: ffffffff811c3eb0 <-- ffffffff811afbfc
- ls 10781 [001] 32667.291383: ftrace:function: ffffffff8164e100 <-- ffffffff811c3ed8
- ls 10781 [001] 32667.291384: ftrace:function: ffffffff811a5d10 <-- ffffffff811c3f53
- ls 10781 [001] 32667.291384: ftrace:function: ffffffff811e8e70 <-- ffffffff811a5d58
- ls 10781 [001] 32667.291385: ftrace:function: ffffffff811f38e0 <-- ffffffff811a5d63
- ls 10781 [001] 32667.291385: ftrace:function: ffffffff811a9ff0 <-- ffffffff811a5d6b
- ls 10781 [001] 32667.291386: ftrace:function: ffffffff811a9fa0 <-- ffffffff811aa015
- ls 10781 [001] 32667.291387: ftrace:function: ffffffff810851c0 <-- ffffffff811aa053
- ls 10781 [001] 32667.291387: ftrace:function: ffffffff81090e00 <-- ffffffff81085211
+ ls 10781 [001] 32667.291379: ftrace:function: would_dump <-- setup_new_exec
+ ls 10781 [001] 32667.291379: ftrace:function: inode_permission <-- would_dump
+ ls 10781 [001] 32667.291380: ftrace:function: __inode_permission <-- inode_permission
+ ls 10781 [001] 32667.291380: ftrace:function: generic_permission <-- __inode_permission
+ ls 10781 [001] 32667.291381: ftrace:function: security_inode_permission <-- __inode_permission
+ ls 10781 [001] 32667.291381: ftrace:function: cap_inode_permission <-- security_inode_permission
+ ls 10781 [001] 32667.291382: ftrace:function: flush_signal_handlers <-- setup_new_exec
+ ls 10781 [001] 32667.291383: ftrace:function: do_close_on_exec <-- setup_new_exec
+ ls 10781 [001] 32667.291383: ftrace:function: _raw_spin_lock <-- do_close_on_exec
+ ls 10781 [001] 32667.291384: ftrace:function: filp_close <-- do_close_on_exec
+ ls 10781 [001] 32667.291384: ftrace:function: dnotify_flush <-- filp_close
+ ls 10781 [001] 32667.291385: ftrace:function: locks_remove_posix <-- filp_close
+ ls 10781 [001] 32667.291385: ftrace:function: fput <-- filp_close
+ ls 10781 [001] 32667.291386: ftrace:function: file_sb_list_del <-- fput
+ ls 10781 [001] 32667.291387: ftrace:function: task_work_add <-- fput
+ ls 10781 [001] 32667.291387: ftrace:function: kick_process <-- task_work_add
* data was generated by 'perf record -e 'kvm:*,kvmmmu:*' -a'
--- script.kvm.old
+++ script.kvm.new
qemu-system-x86 17414 [000] 6868.995053: kvm:kvm_exit: reason EPT_VIOLATION rip 0xfff0 info 184 0 qemu-system-x86 17414 [000] 6868.995109: kvm:kvm_emulate_insn: f0000:c46b:e4 71 (real)
- qemu-system-x86 3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: [FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root_count=0
+ qemu-system-x86 3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: new sp gfn 0 0/4 q0 direct --- !pge !nxe root 0 sync
- qemu-system-x86 3006 [002] 10562.080502: kvmmmu:kvm_mmu_prepare_zap_page: [FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root
+ qemu-system-x86 3006 [002] 10562.080502: kvmmmu:kvm_mmu_prepare_zap_page: 0/4 q0 direct --- !pge !nxe root 1 sync qemu-system-x86 3290 [002] 10708.755312: kvmmmu:fast_page_fault: [FAILED TO PARSE] vcpu_id=0 gva=4094486080 error_code=3 sptep=0xfff
- insmod 2576 [001] 781.731666: kvmmmu:kvm_mmu_sync_page: [FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count=1
+ insmod 2576 [001] 781.731666: kvmmmu:kvm_mmu_sync_page: 3/0 q0 --- !pge !nxe root 10 unsync
- insmod 2576 [001] 781.731668: kvmmmu:kvm_mmu_unsync_page: [FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count
+ insmod 2576 [001] 781.731668: kvmmmu:kvm_mmu_unsync_page: 3/0 q0 --- !pge !nxe root 10 unsync
---
Jiri Olsa (22):
tools lib traceevent: Add plugin support
tools lib traceevent: Add plugin build support
tools lib traceevent: Add traceevent_host_bigendian function tools lib traceevent: Add jbd2 plugin
tools lib traceevent: Add hrtimer plugin
tools lib traceevent: Add kmem plugin
tools lib traceevent: Add kvm plugin
tools lib traceevent: Add mac80211 plugin
tools lib traceevent: Add sched_switch plugin
tools lib traceevent: Add function plugin
tools lib traceevent: Add xen plugin
tools lib traceevent: Add scsi plugin
tools lib traceevent: Add cfg80211 plugin
tools lib traceevent: Update kvm plugin with is_writable_pte helper tools lib traceevent: Change pevent_parse_event to return event format tools lib traceevent: Harmonize the install messages in lib-traceevent perf tools: Add build and install plugins targets
perf tools: Add udis86 disassembler feature check
perf tools: Add filename__read_str util function
perf tools: Add trace-event object
perf tools: Add trace-event global object for tracepoint interface perf tools: Overload pr_stat traceevent print function
tools/lib/traceevent/Makefile | 61 ++++++++++-- tools/lib/traceevent/event-parse.c | 32 +++---- tools/lib/traceevent/event-parse.h | 21 +++- tools/lib/traceevent/event-plugin.c | 202 +++++++++++++++++++++++++++++++++++++++ tools/lib/traceevent/plugin_cfg80211.c | 23 +++++ tools/lib/traceevent/plugin_function.c | 151 +++++++++++++++++++++++++++++ tools/lib/traceevent/plugin_hrtimer.c | 93 ++++++++++++++++++ tools/lib/traceevent/plugin_jbd2.c | 66 +++++++++++++ tools/lib/traceevent/plugin_kmem.c | 72 ++++++++++++++ tools/lib/traceevent/plugin_kvm.c | 436 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/lib/traceevent/plugin_mac80211.c | 95 +++++++++++++++++++ tools/lib/traceevent/plugin_sched_switch.c | 148 +++++++++++++++++++++++++++++ tools/lib/traceevent/plugin_scsi.c | 423 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/lib/traceevent/plugin_xen.c | 130 +++++++++++++++++++++++++ tools/perf/Makefile.perf | 16 +++- tools/perf/builtin-script.c | 2 +- tools/perf/builtin-trace.c | 5 +- tools/perf/config/Makefile | 10 ++ tools/perf/config/feature-checks/Makefile | 6 +- tools/perf/config/feature-checks/test-all.c | 5 + tools/perf/config/feature-checks/test-udis86.c | 11 +++ tools/perf/util/debug.c | 16 ++++ tools/perf/util/debug.h | 2 + tools/perf/util/evsel.c | 44 +-------- tools/perf/util/header.c | 8 +- tools/perf/util/python-ext-sources | 1 + tools/perf/util/session.h | 3 +- tools/perf/util/trace-event-parse.c | 17 +--- tools/perf/util/trace-event-read.c | 20 ++-- tools/perf/util/trace-event.c | 82 ++++++++++++++++ tools/perf/util/trace-event.h | 15 ++- tools/perf/util/util.c | 41 ++++++++ tools/perf/util/util.h | 1 + 33 files changed, 2144 insertions(+), 114 deletions(-) create mode 100644 tools/lib/traceevent/event-plugin.c create mode 100644 tools/lib/traceevent/plugin_cfg80211.c create mode 100644 tools/lib/traceevent/plugin_function.c create mode 100644 tools/lib/traceevent/plugin_hrtimer.c create mode 100644 tools/lib/traceevent/plugin_jbd2.c create mode 100644 tools/lib/traceevent/plugin_kmem.c create mode 100644 tools/lib/traceevent/plugin_kvm.c create mode 100644 tools/lib/traceevent/plugin_mac80211.c create mode 100644 tools/lib/traceevent/plugin_sched_switch.c create mode 100644 tools/lib/traceevent/plugin_scsi.c create mode 100644 tools/lib/traceevent/plugin_xen.c create mode 100644 tools/perf/config/feature-checks/test-udis86.c create mode 100644 tools/perf/util/trace-event.c
PATCH 1/22 tools lib traceevent: Add plugin support
Backporting plugin support for traceevent lib.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
It's now possible to use following interface to load plugins (shared objects) to enahnce pevent object functionality.
The plugin interface/hooks are as follows:
(taken from event-parse.h comments)
- 'pevent_plugin_loader' (required)
The function name to initialized the plugin.
int pevent_plugin_loader(struct pevent *pevent)
- 'pevent_plugin_unloader' (optional)
The function called just before unloading
int pevent_plugin_unloader(void)
- 'pevent_plugin_options' (optional)
Plugin options that can be set before loading
struct plugin_option pevent_plugin_options[] = {
{
.name = "option-name",
.plugin_alias = "overide-file-name", (optional) .description = "description of option to show users",
},
{
.name = NULL,
},
};
Array must end with .name = NULL;
The plugin_alias (below) can be used to give a shorter name to access the vairable. Useful if a plugin handles more than one event.
NOTE options support is not backported yet.
- 'pevent_plugin_alias' (optional)
The name to use for finding options (uses filename if not defined)
New traceevent functions are added to search and load available plugins:
struct plugin_list* traceevent_load_plugins(struct pevent *pevent)
- loads plusing for 'struct pevent' object and returns loaded plugins list
void traceevent_unload_plugins(struct plugin_list *plugin_list);
- unload plugin list
--- tools/lib/traceevent/Makefile | 6 +- tools/lib/traceevent/event-parse.h | 5 + tools/lib/traceevent/event-plugin.c | 202 ++++++++++++++++++++++++++++++++++++ 3 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 tools/lib/traceevent/event-plugin.c
tools/lib/traceevent/Makefile +5 -1
@@ -180,7 +180,11 @@ $(obj)/%.o: $(src)/%.c %.o: $(src)/%.c $(Q)$(call do_compile) -PEVENT_LIB_OBJS = event-parse.o trace-seq.o parse-filter.o parse-utils.o +PEVENT_LIB_OBJS = event-parse.o +PEVENT_LIB_OBJS += event-plugin.o +PEVENT_LIB_OBJS += trace-seq.o +PEVENT_LIB_OBJS += parse-filter.o +PEVENT_LIB_OBJS += parse-utils.o PEVENT_LIB_OBJS += kbuffer-parse.o ALL_OBJS = $(PEVENT_LIB_OBJS)
tools/lib/traceevent/event-parse.h +5 -0
@@ -377,6 +377,11 @@ enum pevent_errno { };#undef _PE +struct plugin_list ; + +struct plugin_list *traceevent_load_plugins (struct pevent *pevent); +void traceevent_unload_plugins (struct plugin_list *plugin_list); +struct cmdline ;struct cmdline_list ;struct func_map ;
tools/lib/traceevent/event-plugin.c new file +202 -0
202 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 01/22] tools lib traceevent: Add plugin support
Quoted 57 lines · On Thu, 21 Nov 2013 12:00:59 +0100 Jiri Olsa <[email protected]> wrote:
Backporting plugin support for traceevent lib.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitIt's now possible to use following interface to load plugins (shared objects) to enahnce pevent object functionality.
The plugin interface/hooks are as follows:
(taken fromevent-parse.hcomments)- '
pevent_plugin_loader' (required)
The function name to initialized the plugin.int
pevent_plugin_loader(struct pevent *pevent)- '
pevent_plugin_unloader' (optional)
The function called just before unloadingint
pevent_plugin_unloader(void)- '
pevent_plugin_options' (optional)
Plugin options that can be set before loadingstruct
plugin_optionpevent_plugin_options[] = {
{
.name = "option-name",
.plugin_alias = "overide-file-name", (optional) .description = "description of option to show users",
},
{
.name = NULL,
},
};Array must end with .name = NULL;
The
plugin_alias(below) can be used to give a shorter name to access the vairable. Useful if a plugin handles more than one event.NOTE options support is not backported yet.
- '
pevent_plugin_alias' (optional)
The name to use for finding options (uses filename if not defined)New traceevent functions are added to search and load available plugins:
struct plugin_list*
traceevent_load_plugins(struct pevent *pevent)
- loads plusing for 'struct pevent' object and returns loaded plugins listvoid
traceevent_unload_plugins(struct plugin_list *plugin_list);
- unload plugin list
Quoted 9 lines
Signed-off-by Jiri Olsa <[email protected]>Cc Corey Ashford <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Namhyung Kim <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Steven Rostedt <[email protected]>
As I authored the original code, you can add my:
-- Steve
Quoted 8 lines
Cc David Ahern <[email protected]>--- tools/lib/traceevent/Makefile | 6 +- tools/lib/traceevent/event-parse.h | 5 + tools/lib/traceevent/event-plugin.c | 202 ++++++++++++++++++++++++++++++++++++ 3 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 tools/lib/traceevent/event-plugin.c
Namhyung Kim
maintainerRe: [PATCH 01/22] tools lib traceevent: Add plugin support
In reply to Jiri OlsaHi Jiri,
2013-11-21 (목), 12:00 +0100, Jiri Olsa:
Quoted 49 lines
Backporting plugin support for traceevent lib.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitIt's now possible to use following interface to load plugins (shared objects) to enahnce pevent object functionality.
The plugin interface/hooks are as follows:
(taken fromevent-parse.hcomments)- '
pevent_plugin_loader' (required)
The function name to initialized the plugin.int
pevent_plugin_loader(struct pevent *pevent)- '
pevent_plugin_unloader' (optional)
The function called just before unloadingint
pevent_plugin_unloader(void)- '
pevent_plugin_options' (optional)
Plugin options that can be set before loadingstruct
plugin_optionpevent_plugin_options[] = {
{
.name = "option-name",
.plugin_alias = "overide-file-name", (optional) .description = "description of option to show users",
},
{
.name = NULL,
},
};Array must end with .name = NULL;
The
plugin_alias(below) can be used to give a shorter name to access the vairable. Useful if a plugin handles more than one event.NOTE options support is not backported yet.
- '
pevent_plugin_alias' (optional)
The name to use for finding options (uses filename if not defined)New traceevent functions are added to search and load available plugins:
Quoted 7 lines
struct plugin_list*
traceevent_load_plugins(struct pevent *pevent)
- loads plusing for 'struct pevent' object and returns loaded plugins listvoid
traceevent_unload_plugins(struct plugin_list *plugin_list);
- unload plugin list
First of all, thank you for your nice work! :)
Quoted 1 line
[SNIP[
tools/lib/traceevent/event-plugin.c line 50
Quoted 12 lines
tools/lib/traceevent/event-plugin.c new file +12
-0+static void +load_plugin (struct pevent *pevent,const char *path, +const char *file,void *data) +{ +struct plugin_list **plugin_list = data; +pevent_plugin_load_func func; +struct plugin_list *list; +const char *alias; +char *plugin; +void *handle; + + plugin =malloc_or_die (strlen (path) +strlen (file) +2 );
I'd like not to see this malloc_or_die() anymore in a new code. Just returning after showing a warning looks enough here.
tools/lib/traceevent/event-plugin.c line 56
Quoted 6 lines
tools/lib/traceevent/event-plugin.c new file +6
-0+ +strcpy (plugin, path); +strcat (plugin,"/" ); +strcat (plugin, file); + + handle =dlopen (plugin,RTLD_NOW |RTLD_GLOBAL );
Why RTLD_NOW and RTLD_GLOBAL? Hmm.. maybe using _NOW is needed to prevent a runtime error, but not sure why _GLOBAL is needed.
IIUC _GLOBAL is for exporting symbols to *other libraries*. Is it intended for this plugin support?
tools/lib/traceevent/event-plugin.c line 65
Quoted 9 lines
tools/lib/traceevent/event-plugin.c new file +9
-0+if (!handle) { +warning ("could not load plugin '%s'\n%s\n" , + plugin,dlerror ()); + goto out_free; + } + + alias =dlsym (handle,PEVENT_PLUGIN_ALIAS_NAME ); +if (!alias) + alias = file;
So this 'alias' is not used anywhere in the current code, right? Do you plan to add the option processing soon?
tools/lib/traceevent/event-plugin.c line 74
Quoted 9 lines
tools/lib/traceevent/event-plugin.c new file +9
-0+ + func =dlsym (handle,PEVENT_PLUGIN_LOADER_NAME ); +if (!func) { +warning ("could not find func '%s' in plugin '%s'\n%s\n" , +PEVENT_PLUGIN_LOADER_NAME , plugin,dlerror ()); + goto out_free; + } + + list =malloc_or_die (sizeof (*list));
Ditto. Please check return value and handle error properly.
Quoted 10 lines
tools/lib/traceevent/event-plugin.c new file +10
-0+ list->next = *plugin_list; + list->handle = handle; + list->name = plugin; + *plugin_list = list; + +pr_stat ("registering plugin: %s" , plugin); +func (pevent); +return ; + + out_free:
tools/lib/traceevent/event-plugin.c line 94
Quoted 10 lines
tools/lib/traceevent/event-plugin.c new file +10
-0+free (plugin); +} + +static void +load_plugins_dir(struct pevent *pevent, const char *suffix, + const char *path, + void (*load_plugin)(struct pevent *pevent, + const char *path, + const char *name, + void *data),
Doesn't gcc complain about the name shadows other function? Anyway I think we should avoid using same name - probably using typedef for the function might be helpful.
Quoted 1 line
(quoted diff) +1
-0+ void *data)
[SNIP]
tools/lib/traceevent/event-plugin.c line 166
Quoted 9 lines
tools/lib/traceevent/event-plugin.c new file +9
-0+/* +* Now let the home directory override the environment +* or system defaults. +*/ + home =getenv ("HOME" ); +if (!home) +return ; + + path =malloc_or_die (strlen (home) +strlen (LOCAL_PLUGIN_DIR ) +2 );
Ditto.
Thanks,
Namhyung
Quoted 36 lines
tools/lib/traceevent/event-plugin.c new file +36
-0+ +strcpy (path, home); +strcat (path,"/" ); +strcat (path,LOCAL_PLUGIN_DIR ); + +load_plugins_dir (pevent, suffix, path, load_plugin, data); + +free (path); +} + +struct plugin_list * +traceevent_load_plugins (struct pevent *pevent) +{ +struct plugin_list *list =NULL ; + +load_plugins (pevent,".so" , load_plugin, &list); +return list; +} + +void +traceevent_unload_plugins (struct plugin_list *plugin_list) +{ +pevent_plugin_unload_func func; +struct plugin_list *list; + +while (plugin_list) { + list = plugin_list; + plugin_list = list->next; + func =dlsym (list->handle,PEVENT_PLUGIN_UNLOADER_NAME ); +if (func) +func (); +dlclose (list->handle); +free (list->name); +free (list); + } +}
Re: [PATCH 01/22] tools lib traceevent: Add plugin support
Quoted 17 lines · On Fri, 22 Nov 2013 23:17:06 +0900 Namhyung Kim <[email protected]> wrote:
Quoted 1 line
[SNIP[
tools/lib/traceevent/event-plugin.c line 50
Quoted 12 lines
tools/lib/traceevent/event-plugin.c new file +12
-0+static void +load_plugin (struct pevent *pevent,const char *path, +const char *file,void *data) +{ +struct plugin_list **plugin_list = data; +pevent_plugin_load_func func; +struct plugin_list *list; +const char *alias; +char *plugin; +void *handle; + + plugin =malloc_or_die (strlen (path) +strlen (file) +2 );I'd like not to see this
malloc_or_die()anymore in a new code. Just returning after showing a warning looks enough here.
Yeah I agree. This is a relic from my code. I think it's OK to add here, as it is pretty much direct port of my code, and then we can just add a patch against it to remove it.
Quoted 10 lines
tools/lib/traceevent/event-plugin.c line 56
Quoted 7 lines
tools/lib/traceevent/event-plugin.c new file +6
-0+ +strcpy (plugin, path); +strcat (plugin,"/" ); +strcat (plugin, file); + + handle =dlopen (plugin,RTLD_NOW |RTLD_GLOBAL );Why
RTLD_NOWandRTLD_GLOBAL? Hmm.. maybe using_NOWis needed to prevent a runtime error, but not sure why_GLOBALis needed.
Yes, we want to make sure all symbols defined are available at time of load, otherwise bail out.
Quoted 3 lines
IIUC
_GLOBALis for exporting symbols to *other libraries*. Is it intended for this plugin support?
That was the plan. To have one plugin supply a set of functions that other plugins may use. That is what GLOBAL is for, right? I don't recall if I every did this, but it was something I wanted for future work.
Now if we don't need it, we could remove it, but is it bad to have?
Quoted 14 lines
tools/lib/traceevent/event-plugin.c line 65
Quoted 11 lines
tools/lib/traceevent/event-plugin.c new file +9
-0+if (!handle) { +warning ("could not load plugin '%s'\n%s\n" , + plugin,dlerror ()); + goto out_free; + } + + alias =dlsym (handle,PEVENT_PLUGIN_ALIAS_NAME ); +if (!alias) + alias = file;So this 'alias' is not used anywhere in the current code, right? Do you plan to add the option processing soon?
I believe he is, and hopefully he will, because I want to forward port this code to have trace-cmd use it. The end result should be a separate library that we all can use.
It may be best to add the above alias when we add option support. But it doesn't hurt to include it now, as long as we plan to add that in the near future.
Quoted 12 lines
tools/lib/traceevent/event-plugin.c line 74
Quoted 10 lines
tools/lib/traceevent/event-plugin.c new file +9
-0+ + func =dlsym (handle,PEVENT_PLUGIN_LOADER_NAME ); +if (!func) { +warning ("could not find func '%s' in plugin '%s'\n%s\n" , +PEVENT_PLUGIN_LOADER_NAME , plugin,dlerror ()); + goto out_free; + } + + list =malloc_or_die (sizeof (*list));Ditto. Please check return value and handle error properly.
I agree, but lets make that a separate patch, such that we see the changes between the backport and updates.
Quoted 18 lines
Quoted 18 lines
tools/lib/traceevent/event-plugin.c new file +16
-0+ list->next = *plugin_list; + list->handle = handle; + list->name = plugin; + *plugin_list = list; + +pr_stat ("registering plugin: %s" , plugin); +func (pevent); +return ; + + out_free: +free (plugin); +} + +static void +load_plugins_dir(struct pevent *pevent, const char *suffix, + const char *path,
Quoted 8 lines
tools/lib/traceevent/event-plugin.c line 94
Quoted 4 lines
tools/lib/traceevent/event-plugin.c new file +4
-0+void (*load_plugin)(struct pevent *pevent, +const char *path, +const char *name, + void *data),Doesn't gcc complain about the name shadows other function? Anyway I think we should avoid using same name - probably using typedef for the function might be helpful.
I agree here too, but again, lets keep the backport and fixes as separate patches.
-- Steve
Quoted 18 lines
Quoted 3 lines
(quoted diff) +1
-0+ void *data)[SNIP]
tools/lib/traceevent/event-plugin.c line 166
Quoted 9 lines
tools/lib/traceevent/event-plugin.c new file +9
-0+/* +* Now let the home directory override the environment +* or system defaults. +*/ + home =getenv ("HOME" ); +if (!home) +return ; + + path =malloc_or_die (strlen (home) +strlen (LOCAL_PLUGIN_DIR ) +2 );Ditto.
Thanks,
Namhyung
Namhyung Kim
maintainerRe: [PATCH 01/22] tools lib traceevent: Add plugin support
Quoted 21 lines · Steven Rostedt
Quoted 17 lines · On Fri, 22 Nov 2013 23:17:06 +0900 Namhyung Kim <[email protected]> wrote:
Quoted 1 line
[SNIP[
tools/lib/traceevent/event-plugin.c line 50
Quoted 12 lines
tools/lib/traceevent/event-plugin.c new file +12
-0+static void +load_plugin (struct pevent *pevent,const char *path, +const char *file,void *data) +{ +struct plugin_list **plugin_list = data; +pevent_plugin_load_func func; +struct plugin_list *list; +const char *alias; +char *plugin; +void *handle; + + plugin =malloc_or_die (strlen (path) +strlen (file) +2 );I'd like not to see this
malloc_or_die()anymore in a new code. Just returning after showing a warning looks enough here.
Quoted 3 lines
Yeah I agree. This is a relic from my code. I think it's OK to add here, as it is pretty much direct port of my code, and then we can just add a patch against it to remove it.
Okay. I agree that it'd be better to make them separate patches.
Quoted 19 lines
Quoted 11 lines
tools/lib/traceevent/event-plugin.c line 56
Quoted 8 lines
tools/lib/traceevent/event-plugin.c new file +6
-0+ +strcpy (plugin, path); +strcat (plugin,"/" ); +strcat (plugin, file); + + handle =dlopen (plugin,RTLD_NOW |RTLD_GLOBAL );Why
RTLD_NOWandRTLD_GLOBAL? Hmm.. maybe using_NOWis needed to prevent a runtime error, but not sure why_GLOBALis needed.Yes, we want to make sure all symbols defined are available at time of load, otherwise bail out.
Quoted 3 lines
IIUC
_GLOBALis for exporting symbols to *other libraries*. Is it intended for this plugin support?
Quoted 6 lines
That was the plan. To have one plugin supply a set of functions that other plugins may use. That is what GLOBAL is for, right? I don't recall if I every did this, but it was something I wanted for future work.
Now if we don't need it, we could remove it, but is it bad to have?
I might be slow down symbol resolution of new plugins tiny bit. But I don't think it's a real problem as its effect will be negligible.
I don't object the code but just want to know your intention. :)
Thanks,
Namhyung
Re: [PATCH 01/22] tools lib traceevent: Add plugin support
In reply to Steven RostedtOn Sat, Nov 23, 2013 at 03:12:19AM -0500, Steven Rostedt wrote:
SNIP
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
tools/lib/traceevent/event-plugin.c new file +4
-0+if (!handle) { +warning ("could not load plugin '%s'\n%s\n" , + plugin,dlerror ()); + goto out_free;Quoted 8 lines
tools/lib/traceevent/event-plugin.c line 65
Quoted 5 lines
tools/lib/traceevent/event-plugin.c new file +5
-0+ } + + alias =dlsym (handle,PEVENT_PLUGIN_ALIAS_NAME ); +if (!alias) + alias = file;So this 'alias' is not used anywhere in the current code, right? Do you plan to add the option processing soon?
Quoted 3 lines
I believe he is, and hopefully he will, because I want to forward port this code to have trace-cmd use it. The end result should be a separate library that we all can use.
yep, thats the plan ;-)
so I get the the deal is in v2 I keep the current code and add patches addressing comments on top of it..
jirka
PATCH 2/22 tools lib traceevent: Add plugin build support
In reply to Jiri OlsaBackporting missing pieces of plugin building infrastructure:
- adding Makefile 'plugins' target to build all defined plugins
- adding Makefile 'install_plugins' target as 'install_lib' target dependency
- link plugin objects with shared object building
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
Plugins are by default installed into following locations:
'$(HOME)/.traceevent/plugins'
- if we are installing under $(HOME)
'$(prefix)/lib/traceevent/plugins'
- otherwise
This path is propagated to the plugin object as a plugins search path.
--- tools/lib/traceevent/Makefile | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-)
tools/lib/traceevent/Makefile +37 -5
@@ -43,6 +43,20 @@ man_dir_SQ = '$(subst ','\'',$(man_dir))' export man_dir man_dir_SQ INSTALL export DESTDIR DESTDIR_SQ +# Set plugin_dir to preffered global plugin location +# If we install under $HOME directory we go under +# $(HOME)/.traceevent/plugins +ifeq ($(plugin_dir),) +ifeq ($(prefix),$(HOME)) +override plugin_dir = $(HOME)/.traceevent/plugins +else +override plugin_dir = $(prefix)/lib/traceevent/plugins +endif +endif + +PLUGIN_DIR = -DPLUGIN_DIR="$(DESTDIR)/$(plugin_dir)" +PLUGIN_DIR_SQ = '$(subst ','\'',$(PLUGIN_DIR))' + # copy a bit from Linux kbuild ifeq ("$(origin V)", "command line")
@@ -96,6 +110,7 @@ export prefix bindir src obj # Shell quotes bindir_SQ = $(subst ','\'',$(bindir)) bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) +plugin_dir_SQ = $(subst ','\'',$(plugin_dir)) LIB_FILE = libtraceevent.a libtraceevent.so
@@ -138,8 +153,8 @@ else print_app_build = echo ' BUILD '$(OBJ); print_fpic_compile = echo ' CC FPIC '$(OBJ); print_shared_lib_compile = echo ' BUILD SHARED LIB '$(OBJ); - print_plugin_obj_compile = echo ' BUILD PLUGIN OBJ '$(OBJ); - print_plugin_build = echo ' BUILD PLUGIN '$(OBJ); + print_plugin_obj_compile = echo ' CC FPIC '$(OBJ); + print_plugin_build = echo ' BUILD PLUGIN '$(OBJ); print_static_lib_build = echo ' BUILD STATIC LIB '$(OBJ); print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2'; endif
@@ -187,9 +202,11 @@ PEVENT_LIB_OBJS += parse-filter.o PEVENT_LIB_OBJS += parse-utils.o PEVENT_LIB_OBJS += kbuffer-parse.o -ALL_OBJS = $(PEVENT_LIB_OBJS) +PLUGINS := $(PLUGIN_OBJS:.o=.so) + +ALL_OBJS = $(PEVENT_LIB_OBJS) $(PLUGIN_OBJS) -CMD_TARGETS = $(LIB_FILE) +CMD_TARGETS = $(LIB_FILE) $(PLUGINS) TARGETS = $(CMD_TARGETS)
@@ -204,9 +221,17 @@ libtraceevent.so: $(PEVENT_LIB_OBJS) libtraceevent.a: $(PEVENT_LIB_OBJS) $(Q)$(do_build_static_lib) +plugins: $(PLUGINS) + $(PEVENT_LIB_OBJS): %.o: $(src)/%.c TRACEEVENT-CFLAGS $(Q)$(do_fpic_compile) +$(PLUGIN_OBJS): %.o : $(src)/%.c + $(Q)$(do_compile_plugin_obj) + +$(PLUGINS): %.so: %.o + $(Q)$(do_plugin_build) + define make_version.h (echo '/* This file is automatically generated. Do not modify. */'; \ echo \#define VERSION_CODE $(shell \
@@ -294,9 +319,16 @@ define do_install $(INSTALL) $1 '$(DESTDIR_SQ)$2' endef -install_lib: all_cmd +install_lib: all_cmd install_plugins $(Q)$(call do_install,$(LIB_FILE),$(bindir_SQ)) +PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) + +$(PLUGINS_INSTALL): %.install : %.so force + $(Q)$(call do_install,$<,$(plugin_dir_SQ)) + +install_plugins: $(PLUGINS_INSTALL) + install: install_lib clean:
Signature · 1 line
1.8.3.1
PATCH 3/22 tools lib traceevent: Add traceevent_host_bigendian function
In reply to Jiri OlsaAdding traceevent_host_bigendian function to get host endianity. It's used in following patches.
--- tools/lib/traceevent/event-parse.h | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/lib/traceevent/event-parse.h +9 -0
@@ -527,6 +527,15 @@ __data2host8(struct pevent *pevent, unsigned long long data)__data2host8 (pevent, __val); \ }) +static inline int traceevent_host_bigendian (void ) +{ +unsigned char str[] = {0x1 ,0x2 ,0x3 ,0x4 }; +unsigned int *ptr; + + ptr = (unsigned int *)str; +return *ptr ==0x01020304 ; +} +/* taken from kernel/trace/trace.h */ enum trace_flag_type {TRACE_FLAG_IRQS_OFF =0x01 ,
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 03/22] tools lib traceevent: Add traceevent_host_bigendian function
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 2 lines
Adding
traceevent_host_bigendianfunction to get host endianity. It's used in following patches.
[SNIP]
tools/lib/traceevent/event-parse.h __data2host8(struct pevent *pevent, unsigned long long data) · line 536
Quoted 7 lines
tools/lib/traceevent/event-parse.h +7
-0+static inline int traceevent_host_bigendian (void ) +{ +unsigned char str[] = {0x1 ,0x2 ,0x3 ,0x4 }; +unsigned int *ptr; + + ptr = (unsigned int *)str; +return *ptr ==0x01020304 ;
Is it safe for every architecture supported - especially ones that require stricter alignment? I know many architectures/compilers align stack but not sure doing this is safe for all architecture.
Thanks,
Namhyung
Re: [PATCH 03/22] tools lib traceevent: Add traceevent_host_bigendian function
Quoted 5 lines · On Fri, 22 Nov 2013 23:22:52 +0900 Namhyung Kim <[email protected]> wrote:
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 2 lines
Adding
traceevent_host_bigendianfunction to get host endianity. It's used in following patches.[SNIP]
Quoted 11 lines
tools/lib/traceevent/event-parse.h __data2host8(struct pevent *pevent, unsigned long long data) · line 536
Quoted 7 lines
tools/lib/traceevent/event-parse.h +7
-0+static inline int traceevent_host_bigendian (void ) +{ +unsigned char str[] = {0x1 ,0x2 ,0x3 ,0x4 }; +unsigned int *ptr; + + ptr = (unsigned int *)str; +return *ptr ==0x01020304 ;Is it safe for every architecture supported - especially ones that require stricter alignment? I know many architectures/compilers align stack but not sure doing this is safe for all architecture.
Would you prefer this (I tested it on both a big and little endian)
{
unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
unsigned int val;
memcpy(&val, str, 4);
return val == 0x01020304;
}-- Steve
Namhyung Kim
maintainerRe: [PATCH 03/22] tools lib traceevent: Add traceevent_host_bigendian function
Hi Steve,
Quoted 22 lines · Steven Rostedt
Quoted 5 lines · On Fri, 22 Nov 2013 23:22:52 +0900 Namhyung Kim <[email protected]> wrote:
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 2 lines
Adding
traceevent_host_bigendianfunction to get host endianity. It's used in following patches.[SNIP]
Quoted 11 lines
tools/lib/traceevent/event-parse.h __data2host8(struct pevent *pevent, unsigned long long data) · line 536
Quoted 7 lines
tools/lib/traceevent/event-parse.h +7
-0+static inline int traceevent_host_bigendian (void ) +{ +unsigned char str[] = {0x1 ,0x2 ,0x3 ,0x4 }; +unsigned int *ptr; + + ptr = (unsigned int *)str; +return *ptr ==0x01020304 ;Is it safe for every architecture supported - especially ones that require stricter alignment? I know many architectures/compilers align stack but not sure doing this is safe for all architecture.
Would you prefer this (I tested it on both a big and little endian)
Quoted 7 lines
{
unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
unsigned int val;
memcpy(&val, str, 4);
return val == 0x01020304;
}Yeah, looks good to me.
Thanks,
Namhyung
Re: [PATCH 03/22] tools lib traceevent: Add traceevent_host_bigendian function
Quoted 29 lines · Namhyung Kim
Hi Steve,
Quoted 26 lines · Steven Rostedt
Quoted 5 lines · On Fri, 22 Nov 2013 23:22:52 +0900 Namhyung Kim <[email protected]> wrote:
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 2 lines
Adding
traceevent_host_bigendianfunction to get host endianity. It's used in following patches.[SNIP]
Quoted 11 lines
tools/lib/traceevent/event-parse.h __data2host8(struct pevent *pevent, unsigned long long data) · line 536
Quoted 7 lines
tools/lib/traceevent/event-parse.h +7
-0+static inline int traceevent_host_bigendian (void ) +{ +unsigned char str[] = {0x1 ,0x2 ,0x3 ,0x4 }; +unsigned int *ptr; + + ptr = (unsigned int *)str; +return *ptr ==0x01020304 ;Is it safe for every architecture supported - especially ones that require stricter alignment? I know many architectures/compilers align stack but not sure doing this is safe for all architecture.
Would you prefer this (I tested it on both a big and little endian)
{ unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 }; unsigned int val;
Quoted 5 lines
Quoted 3 lines
memcpy(&val, str, 4); return val == 0x01020304; }Yeah, looks good to me.
ok, will change to this one
thanks,
jirka
PATCH 4/22 tools lib traceevent: Add jbd2 plugin
In reply to Jiri OlsaBackporting jbd2 plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
This plugin adds field resolving functions for following tracepoint events:
jbd2:jbd2_checkpoint_stats jbd2:jbd2_run_stats
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'jbd2:jbd2_run_stats,jbd2:jbd2_checkpoint_stats' -a')
--- script.jbd2.old
+++ script.jbd2.new
- jbd2/dm-3-8 576 [000] 2983.748423: jbd2:jbd2_checkpoint_stats: [FAILED TO PARSE] dev=265289731 tid=0x3f2bbb chp_time=0x0 forced_to_close=0 written=0 dropped=2 + jbd2/dm-3-8 576 [000] 2983.748423: jbd2:jbd2_checkpoint_stats: dev 253,3 tid 4139963 chp_time 0 forced_to_close 0 written 0 dropped 2 - jbd2/dm-3-8 576 [000] 2983.852789: jbd2:jbd2_run_stats: [FAILED TO PARSE] dev=265289731 tid=0x3f2bc0 wait=0x0 request_delay=0x0 running=0x138d locked=0x0 flushing=0x0 logging=0x68 handle_count=2995 blocks=17 blocks_logged=18 + jbd2/dm-3-8 576 [000] 2983.852789: jbd2:jbd2_run_stats: dev 253,3 tid 4139968 wait 0 request_delay 0 running 5005 locked 0 flushing 0 logging 104 handle_count 2995 blocks 17 blocks_logged 18
This plugin also adds jbd2_dev_to_name function, which was removed from jdb2 tracepoints recently. Keeping it in for backward compatibility reasons.
--- tools/lib/traceevent/Makefile | 2 ++ tools/lib/traceevent/plugin_jbd2.c | 66 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 tools/lib/traceevent/plugin_jbd2.c
tools/lib/traceevent/Makefile +2 -0
@@ -202,6 +202,8 @@ PEVENT_LIB_OBJS += parse-filter.o PEVENT_LIB_OBJS += parse-utils.o PEVENT_LIB_OBJS += kbuffer-parse.o +PLUGIN_OBJS = plugin_jbd2.o + PLUGINS := $(PLUGIN_OBJS:.o=.so) ALL_OBJS = $(PEVENT_LIB_OBJS) $(PLUGIN_OBJS)
tools/lib/traceevent/plugin_jbd2.c new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 04/22] tools lib traceevent: Add jbd2 plugin
Quoted 24 lines · On Thu, 21 Nov 2013 12:01:02 +0100 Jiri Olsa <[email protected]> wrote:
Backporting jbd2 plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds field resolving functions for following tracepoint events:
jbd2:jbd2_checkpoint_stats jbd2:jbd2_run_statsThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'jbd2:jbd2_run_stats,jbd2:jbd2_checkpoint_stats' -a')script.jbd2.new renamed from script.jbd2.old +2
-2- jbd2/dm-3-8 576 [000] 2983.748423: jbd2:jbd2_checkpoint_stats: [FAILED TO PARSE] dev=265289731 tid=0x3f2bbb chp_time=0x0 forced_to_close=0 written=0 dropped=2 + jbd2/dm-3-8 576 [000] 2983.748423: jbd2:jbd2_checkpoint_stats: dev 253,3 tid 4139963 chp_time 0 forced_to_close 0 written 0 dropped 2 - jbd2/dm-3-8 576 [000] 2983.852789: jbd2:jbd2_run_stats: [FAILED TO PARSE] dev=265289731 tid=0x3f2bc0 wait=0x0 request_delay=0x0 running=0x138d locked=0x0 flushing=0x0 logging=0x68 handle_count=2995 blocks=17 blocks_logged=18 + jbd2/dm-3-8 576 [000] 2983.852789: jbd2:jbd2_run_stats: dev 253,3 tid 4139968 wait 0 request_delay 0 running 5005 locked 0 flushing 0 logging 104 handle_count 2995 blocks 17 blocks_logged 18This plugin also adds
jbd2_dev_to_namefunction, which was removed from jdb2 tracepoints recently. Keeping it in for backward compatibility reasons.
Quoted 9 lines
Signed-off-by Jiri Olsa <[email protected]>Cc Corey Ashford <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Namhyung Kim <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Steven Rostedt <[email protected]>
-- Steve
Quoted 2 lines
Cc David Ahern <[email protected]>---
Namhyung Kim
maintainerRe: [PATCH 04/22] tools lib traceevent: Add jbd2 plugin
In reply to Jiri Olsa2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 23 lines
Backporting jbd2 plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds field resolving functions for following tracepoint events:
jbd2:jbd2_checkpoint_stats jbd2:jbd2_run_statsThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'jbd2:jbd2_run_stats,jbd2:jbd2_checkpoint_stats' -a')script.jbd2.new renamed from script.jbd2.old +2
-2- jbd2/dm-3-8 576 [000] 2983.748423: jbd2:jbd2_checkpoint_stats: [FAILED TO PARSE] dev=265289731 tid=0x3f2bbb chp_time=0x0 forced_to_close=0 written=0 dropped=2 + jbd2/dm-3-8 576 [000] 2983.748423: jbd2:jbd2_checkpoint_stats: dev 253,3 tid 4139963 chp_time 0 forced_to_close 0 written 0 dropped 2 - jbd2/dm-3-8 576 [000] 2983.852789: jbd2:jbd2_run_stats: [FAILED TO PARSE] dev=265289731 tid=0x3f2bc0 wait=0x0 request_delay=0x0 running=0x138d locked=0x0 flushing=0x0 logging=0x68 handle_count=2995 blocks=17 blocks_logged=18 + jbd2/dm-3-8 576 [000] 2983.852789: jbd2:jbd2_run_stats: dev 253,3 tid 4139968 wait 0 request_delay 0 running 5005 locked 0 flushing 0 logging 104 handle_count 2995 blocks 17 blocks_logged 18This plugin also adds
jbd2_dev_to_namefunction, which was removed from jdb2 tracepoints recently. Keeping it in for backward compatibility reasons.
[SNIP]
script.jbd2.new
Quoted 8 lines
script.jbd2.new renamed from script.jbd2.old +8
-0+#define MINORBITS 20 +#define MINORMASK ((1U << MINORBITS) - 1) + +#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS)) +#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK)) + +unsigned long long process_jbd2_dev_to_name(struct trace_seq *s, + unsigned long long *args)
Isn't it better to make these functions static?
Quoted 11 lines
script.jbd2.new renamed from script.jbd2.old +11
-0+{ + unsigned int dev = args[0]; + + trace_seq_printf(s, "%d:%d", MAJOR(dev), MINOR(dev)); + return 0; +} + +unsigned long long process_jiffies_to_msecs(struct trace_seq *s, + unsigned long long *args) +{ + unsigned long long jiffies = args[0];
script.jbd2.new
Quoted 10 lines
script.jbd2.new renamed from script.jbd2.old +10
-0+ + trace_seq_printf(s, "%lld", jiffies); + return jiffies; +} + +int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +{ + pevent_register_print_function(pevent, + process_jbd2_dev_to_name, + PEVENT_FUNC_ARG_STRING,
Actually the function returns long long not string. But it seems the current code doesn't care about the return type.
script.jbd2.new
Quoted 12 lines
script.jbd2.new renamed from script.jbd2.old +12
-0+ "jbd2_dev_to_name", + PEVENT_FUNC_ARG_INT, + PEVENT_FUNC_ARG_VOID); + + pevent_register_print_function(pevent, + process_jiffies_to_msecs, + PEVENT_FUNC_ARG_LONG, + "jiffies_to_msecs", + PEVENT_FUNC_ARG_LONG, + PEVENT_FUNC_ARG_VOID); + return 0; +}
Shouldn't it unregister these functions when unloaded?
Thanks,
Namhyung
Re: [PATCH 04/22] tools lib traceevent: Add jbd2 plugin
Quoted 11 lines · On Fri, 22 Nov 2013 23:27:57 +0900 Namhyung Kim <[email protected]> wrote:
[SNIP]
tools/lib/traceevent/plugin_jbd2.c line 33
Quoted 8 lines
tools/lib/traceevent/plugin_jbd2.c new file +8
-0+#define MINORBITS 20 +#define MINORMASK ((1U << MINORBITS) - 1) + +#define MAJOR (dev) ((unsigned int) ((dev) >> MINORBITS)) +#define MINOR (dev) ((unsigned int) ((dev) & MINORMASK)) + +unsigned long long process_jbd2_dev_to_name (struct trace_seq *s, +unsigned long long *args)Isn't it better to make these functions static?
Yeah, but that was my mistake. Lets keep the fix separate from the backport though. Thanks!
Quoted 18 lines
Quoted 18 lines
tools/lib/traceevent/plugin_jbd2.c new file +16
-0+{ +unsigned int dev = args[0 ]; + +trace_seq_printf (s,"%d:%d" ,MAJOR (dev),MINOR (dev)); +return 0 ; +} + +unsigned long long process_jiffies_to_msecs (struct trace_seq *s, +unsigned long long *args) +{ +unsigned long long jiffies = args[0 ]; + +trace_seq_printf (s,"%lld" , jiffies); +return jiffies; +} +
Quoted 8 lines
tools/lib/traceevent/plugin_jbd2.c line 54
Quoted 5 lines
tools/lib/traceevent/plugin_jbd2.c new file +5
-0+int PEVENT_PLUGIN_LOADER (struct pevent *pevent) +{ + pevent_register_print_function(pevent, + process_jbd2_dev_to_name, + PEVENT_FUNC_ARG_STRING,Actually the function returns long long not string. But it seems the current code doesn't care about the return type.
Actually it's not representing what process_jbd2_dev_to_name() returns (which will always return unsigned long long), but what "jbd2_dev_to_name()" returns that is (was) defined in the kernel. That was:
const char *jbd2_dev_to_name(dev_t device)
When registering a function to handle, you need to express the prototype of that function (not the handler). The third argument is the ret_type of that function.
But this is interesting, the ret_type doesn't seem to be used in event_parse.c. The return value of the callback is only done in eval_num_arg() where we could put a warning if the ret_type is not a number.
Funny thing is, this patch is irrelevant with todays kernel due to this commit:
commit 4862fd6047ed02e2726667c54d35f538eecc56aa
Author: Theodore Ts'o <[email protected]> Date: Sun Jul 10 22:05:08 2011 -0400
jbd2: remove jbd2_dev_to_name() from jbd2 tracepoints
Using function calls in TP_printk causes perf heartburn, so print the MAJOR/MINOR device numbers instead.
Quoted 16 lines
Quoted 4 lines
tools/lib/traceevent/plugin_jbd2.c new file +2
-0+"jbd2_dev_to_name" , + PEVENT_FUNC_ARG_INT,tools/lib/traceevent/plugin_jbd2.c line 66
Quoted 10 lines
tools/lib/traceevent/plugin_jbd2.c new file +10
-0+ PEVENT_FUNC_ARG_VOID); + +pevent_register_print_function (pevent, + process_jiffies_to_msecs, +PEVENT_FUNC_ARG_LONG , +"jiffies_to_msecs" , +PEVENT_FUNC_ARG_LONG , +PEVENT_FUNC_ARG_VOID ); +return 0 ; +}Shouldn't it unregister these functions when unloaded?
Probably ;-)
-- Steve
Quoted 4 lines
Thanks,
Namhyung
Namhyung Kim
maintainerRe: [PATCH 04/22] tools lib traceevent: Add jbd2 plugin
Quoted 42 lines · Steven Rostedt
Quoted 25 lines · On Fri, 22 Nov 2013 23:27:57 +0900 Namhyung Kim <[email protected]> wrote:
[SNIP]
Quoted 24 lines
tools/lib/traceevent/plugin_jbd2.c new file +24
-0+#define MINORBITS 20 +#define MINORMASK ((1U << MINORBITS) - 1) + +#define MAJOR (dev) ((unsigned int) ((dev) >> MINORBITS)) +#define MINOR (dev) ((unsigned int) ((dev) & MINORMASK)) + +unsigned long long process_jbd2_dev_to_name (struct trace_seq *s, +unsigned long long *args) +{ +unsigned int dev = args[0 ]; + +trace_seq_printf (s,"%d:%d" ,MAJOR (dev),MINOR (dev)); +return 0 ; +} + +unsigned long long process_jiffies_to_msecs (struct trace_seq *s, +unsigned long long *args) +{ +unsigned long long jiffies = args[0 ]; + +trace_seq_printf (s,"%lld" , jiffies); +return jiffies; +} +Quoted 8 lines
tools/lib/traceevent/plugin_jbd2.c line 54
Quoted 5 lines
tools/lib/traceevent/plugin_jbd2.c new file +5
-0+int PEVENT_PLUGIN_LOADER (struct pevent *pevent) +{ + pevent_register_print_function(pevent, + process_jbd2_dev_to_name, + PEVENT_FUNC_ARG_STRING,Actually the function returns long long not string. But it seems the current code doesn't care about the return type.
Actually it's not representing what
process_jbd2_dev_to_name()returns (which will always return unsigned long long), but what "jbd2_dev_to_name()" returns that is (was) defined in the kernel. That was:
Quoted 5 lines
const char *jbd2_dev_to_name(dev_t device)
When registering a function to handle, you need to express the prototype of that function (not the handler). The third argument is the
ret_typeof that function.
Aha, got it. Thank you for the explanation.
Quoted 4 lines
But this is interesting, the
ret_typedoesn't seem to be used inevent_parse.c. The return value of the callback is only done ineval_num_arg()where we could put a warning if theret_typeis not a number.
Yes. :)
Thanks,
Namhyung
Re: [PATCH 04/22] tools lib traceevent: Add jbd2 plugin
In reply to Steven RostedtQuoted 15 lines · Steven Rostedt
Quoted 11 lines · On Fri, 22 Nov 2013 23:27:57 +0900 Namhyung Kim <[email protected]> wrote:
[SNIP]
tools/lib/traceevent/plugin_jbd2.c line 33
Quoted 8 lines
tools/lib/traceevent/plugin_jbd2.c new file +8
-0+#define MINORBITS 20 +#define MINORMASK ((1U << MINORBITS) - 1) + +#define MAJOR (dev) ((unsigned int) ((dev) >> MINORBITS)) +#define MINOR (dev) ((unsigned int) ((dev) & MINORMASK)) + +unsigned long long process_jbd2_dev_to_name (struct trace_seq *s, +unsigned long long *args)Isn't it better to make these functions static?
Quoted 2 lines
Yeah, but that was my mistake. Lets keep the fix separate from the backport though. Thanks!
ok
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
tools/lib/traceevent/plugin_jbd2.c new file +4
-0+{ +unsigned int dev = args[0 ]; + +trace_seq_printf (s,"%d:%d" ,MAJOR (dev),MINOR (dev));
SNIP
Quoted 7 lines
jbd2: remove
jbd2_dev_to_name()from jbd2 tracepointsUsing function calls in
TP_printkcauses perf heartburn, so print the MAJOR/MINOR device numbers instead.Signed-off-by "Theodore Ts'o" <[email protected]>
yep, it's rather old change (v3.1-rc1) but I thought we want to keep that for backward compatibility
and it's small piece of code anyway.. ;-)
Quoted 20 lines
Quoted 5 lines
Quoted 14 lines
tools/lib/traceevent/plugin_jbd2.c line 66
Quoted 12 lines
tools/lib/traceevent/plugin_jbd2.c new file +12
-0+"jbd2_dev_to_name" , +PEVENT_FUNC_ARG_INT , + PEVENT_FUNC_ARG_VOID); + +pevent_register_print_function (pevent, + process_jiffies_to_msecs, +PEVENT_FUNC_ARG_LONG , +"jiffies_to_msecs" , +PEVENT_FUNC_ARG_LONG , +PEVENT_FUNC_ARG_VOID ); +return 0 ; +}Shouldn't it unregister these functions when unloaded?
Quoted 1 line
Probably ;-)
will add,
thanks,
jirka
Re: [PATCH 04/22] tools lib traceevent: Add jbd2 plugin
Quoted 5 lines · Jiri Olsa
Quoted 3 lines
Quoted 1 line
Shouldn't it unregister these functions when unloaded?
Probably ;-)
will add,
hum... haven't found exported interface to unregister/remove for print function, seems like this is getting freed in the end at:
void pevent_free(struct pevent *pevent)
jirka
PATCH 5/22 tools lib traceevent: Add hrtimer plugin
In reply to Jiri OlsaBackporting hrtimer plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
This plugin adds function field resolving for following tracepoint events:
timer:hrtimer_expire_entry timer:hrtimer_start
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'timer:hrtimer*' -a')
--- script.hrtimer.old
+++ script.hrtimer.new
- swapper 0 [000] 27405.519092: timer:hrtimer_start: [FAILED TO PARSE] hrtimer=0xffff88021e20e800 function=0xffffffff810c0e10 expires=27398383000000 softexpires=27398383000000 + swapper 0 [000] 27405.519103: timer:hrtimer_start: hrtimer=0xffff88021e20e800 function=tick_sched_timer expires=27398383000000 softexpires=27398383000000 - swapper 0 [001] 27405.519544: timer:hrtimer_expire_entry: [FAILED TO PARSE] hrtimer=0xffff880211334058 now=27398294182491 function=0xffffffff81086f20 + swapper 0 [001] 27405.519544: timer:hrtimer_expire_entry: hrtimer=0xffff880211334058 now=27398294182491 function=posix_timer_fn/0x0
Check the 'function' field is translated into the function name.
--- tools/lib/traceevent/Makefile | 3 +- tools/lib/traceevent/plugin_hrtimer.c | 93 +++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 tools/lib/traceevent/plugin_hrtimer.c
tools/lib/traceevent/Makefile +2 -1
@@ -202,7 +202,8 @@ PEVENT_LIB_OBJS += parse-filter.o PEVENT_LIB_OBJS += parse-utils.o PEVENT_LIB_OBJS += kbuffer-parse.o -PLUGIN_OBJS = plugin_jbd2.o +PLUGIN_OBJS = plugin_jbd2.o +PLUGIN_OBJS += plugin_hrtimer.o PLUGINS := $(PLUGIN_OBJS:.o=.so)
tools/lib/traceevent/plugin_hrtimer.c new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 05/22] tools lib traceevent: Add hrtimer plugin
Quoted 22 lines · On Thu, 21 Nov 2013 12:01:03 +0100 Jiri Olsa <[email protected]> wrote:
Backporting hrtimer plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds function field resolving for following tracepoint events:
timer:hrtimer_expire_entry timer:hrtimer_startThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'timer:hrtimer*' -a')script.hrtimer.new renamed from script.hrtimer.old +2
-2- swapper 0 [000] 27405.519092: timer:hrtimer_start: [FAILED TO PARSE] hrtimer=0xffff88021e20e800 function=0xffffffff810c0e10 expires=27398383000000 softexpires=27398383000000 + swapper 0 [000] 27405.519103: timer:hrtimer_start: hrtimer=0xffff88021e20e800 function=tick_sched_timer expires=27398383000000 softexpires=27398383000000 - swapper 0 [001] 27405.519544: timer:hrtimer_expire_entry: [FAILED TO PARSE] hrtimer=0xffff880211334058 now=27398294182491 function=0xffffffff81086f20 + swapper 0 [001] 27405.519544: timer:hrtimer_expire_entry: hrtimer=0xffff880211334058 now=27398294182491 function=posix_timer_fn/0x0Check the 'function' field is translated into the function name.
Quoted 9 lines
Signed-off-by Jiri Olsa <[email protected]>Cc Corey Ashford <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Namhyung Kim <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Steven Rostedt <[email protected]>
-- Steve
Quoted 1 line
Cc David Ahern <[email protected]>
Namhyung Kim
maintainerRe: [PATCH 05/22] tools lib traceevent: Add hrtimer plugin
In reply to Jiri Olsa2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 21 lines
Backporting hrtimer plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds function field resolving for following tracepoint events:
timer:hrtimer_expire_entry timer:hrtimer_startThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'timer:hrtimer*' -a')script.hrtimer.new renamed from script.hrtimer.old +2
-2- swapper 0 [000] 27405.519092: timer:hrtimer_start: [FAILED TO PARSE] hrtimer=0xffff88021e20e800 function=0xffffffff810c0e10 expires=27398383000000 softexpires=27398383000000 + swapper 0 [000] 27405.519103: timer:hrtimer_start: hrtimer=0xffff88021e20e800 function=tick_sched_timer expires=27398383000000 softexpires=27398383000000 - swapper 0 [001] 27405.519544: timer:hrtimer_expire_entry: [FAILED TO PARSE] hrtimer=0xffff880211334058 now=27398294182491 function=0xffffffff81086f20 + swapper 0 [001] 27405.519544: timer:hrtimer_expire_entry: hrtimer=0xffff880211334058 now=27398294182491 function=posix_timer_fn/0x0Check the 'function' field is translated into the function name.
[SNIP]
script.hrtimer.new
Quoted 12 lines
script.hrtimer.new renamed from script.hrtimer.old +12
-0+ if (!fn) { + trace_seq_printf(s, " function=MISSING"); + } else { + unsigned long long function; + const char *func; + + if (pevent_read_number_field(fn, data, &function)) + trace_seq_printf(s, " function=INVALID"); + + func = pevent_find_function(pevent, function); + + trace_seq_printf(s, " function=%s", func);
Shouldn't it be like below?
if (pevent_read_number_field(fn, data, &function))
trace_seq_printf(s, " function=INVALID");
else {
func = pevent_find_function(pevent, function);
trace_seq_printf(s, " function=%s", func);
}Otherwise it'll print "function=XXX" twice if pevent_read_number_field() failed.
Thanks,
Namhyung
Quoted 20 lines
script.hrtimer.new renamed from script.hrtimer.old +20
-0+ } + + trace_seq_printf(s, " expires="); + pevent_print_num_field(s, "%llu", event, "expires", record, 1); + + trace_seq_printf(s, " softexpires="); + pevent_print_num_field(s, "%llu", event, "softexpires", record, 1); + return 0; +} + +int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +{ + pevent_register_event_handler(pevent, -1, + "timer", "hrtimer_expire_entry", + timer_expire_handler, NULL); + + pevent_register_event_handler(pevent, -1, "timer", "hrtimer_start", + timer_start_handler, NULL); + return 0; +}
Re: [PATCH 05/22] tools lib traceevent: Add hrtimer plugin
Quoted 46 lines · On Fri, 22 Nov 2013 23:33:29 +0900 Namhyung Kim <[email protected]> wrote:
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 21 lines
Backporting hrtimer plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds function field resolving for following tracepoint events:
timer:hrtimer_expire_entry timer:hrtimer_startThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'timer:hrtimer*' -a')script.hrtimer.new renamed from script.hrtimer.old +2
-2- swapper 0 [000] 27405.519092: timer:hrtimer_start: [FAILED TO PARSE] hrtimer=0xffff88021e20e800 function=0xffffffff810c0e10 expires=27398383000000 softexpires=27398383000000 + swapper 0 [000] 27405.519103: timer:hrtimer_start: hrtimer=0xffff88021e20e800 function=tick_sched_timer expires=27398383000000 softexpires=27398383000000 - swapper 0 [001] 27405.519544: timer:hrtimer_expire_entry: [FAILED TO PARSE] hrtimer=0xffff880211334058 now=27398294182491 function=0xffffffff81086f20 + swapper 0 [001] 27405.519544: timer:hrtimer_expire_entry: hrtimer=0xffff880211334058 now=27398294182491 function=posix_timer_fn/0x0Check the 'function' field is translated into the function name.
[SNIP]
script.hrtimer.new
Quoted 12 lines
script.hrtimer.new renamed from script.hrtimer.old +12
-0+ if (!fn) { + trace_seq_printf(s, " function=MISSING"); + } else { + unsigned long long function; + const char *func; + + if (pevent_read_number_field(fn, data, &function)) + trace_seq_printf(s, " function=INVALID"); + + func = pevent_find_function(pevent, function); + + trace_seq_printf(s, " function=%s", func);Shouldn't it be like below?
if (pevent_read_number_field(fn, data, &function)) trace_seq_printf(s, " function=INVALID"); else { func = pevent_find_function(pevent, function); trace_seq_printf(s, " function=%s", func); }
Quoted 3 lines
Otherwise it'll print "function=XXX" twice if
pevent_read_number_field()failed.
Nice catch, but lets keep the backport and fixes separate.
Actually, this was one of the first plugins I wrote, and since then, I added a function tat does this for you. The proper change is to rip this out and use:
pevent_print_func_field()
instead. That function does the checks properly.
-- Steve
PATCH 6/22 tools lib traceevent: Add kmem plugin
In reply to Jiri OlsaBackporting kmem plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
This plugin adds call_site field resolving for following tracepoint events:
kmem:kfree
kmem:kmalloc
kmem:kmalloc_node
kmem:kmem_cache_alloc kmem:kmem_cache_alloc_node kmem:kmem_cache_free
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kmem:*' -a')
--- script.kmem.old
+++ script.kmem.new
- perf 27846 [001] 29643.403319: kmem:kfree: call_site=ffffffff810e64f6 ptr=(nil) + perf 27846 [001] 29643.403238: kmem:kfree: (__audit_syscall_exit+0x1f6) call_site=ffffffff810e64f6 ptr=(nil) - perf 27846 [001] 29643.403337: kmem:kmem_cache_alloc: call_site=ffffffff812ff0c5 ptr=0xffff88020e155630 bytes_req=560 bytes_alloc=568 gfp_flags=GFP_KERNEL + perf 27846 [001] 29643.403337: kmem:kmem_cache_alloc: (radix_tree_preload+0x35) call_site=ffffffff812ff0c5 ptr=0xffff88020e155630 bytes_req=560 bytes_alloc=568 gfp_flags=GFP_KERNEL - perf 27846 [001] 29643.403342: kmem:kmem_cache_free: call_site=ffffffff8126ec61 ptr=0xffff88020dffe750 + perf 27846 [001] 29643.403342: kmem:kmem_cache_free: (jbd2_journal_stop+0x221) call_site=ffffffff8126ec61 ptr=0xffff88020dffe750 - firefox 954 [000] 29643.445477: kmem:kmem_cache_alloc_node: call_site=ffffffff8153c64e ptr=0xffff8801cecb4000 bytes_req=256 bytes_alloc=256 gfp_flags=GFP_KERNEL|GFP_REPEAT node=-1 + firefox 954 [000] 29643.445477: kmem:kmem_cache_alloc_node: (__alloc_skb+0x4e) call_site=ffffffff8153c64e ptr=0xffff8801cecb4000 bytes_req=256 bytes_alloc=256 gfp_flags=GFP_KERNEL|GFP_REPEAT node=-1 - perf 27846 [001] 29643.445510: kmem:kmalloc: call_site=ffffffff81250642 ptr=0xffff88020fd6c300 bytes_req=96 bytes_alloc=96 gfp_flags=GFP_NOFS|GFP_ZERO + perf 27846 [001] 29643.445510: kmem:kmalloc: (ext4_ext_find_extent+0x362) call_site=ffffffff81250642 ptr=0xffff88020fd6c300 bytes_req=96 bytes_alloc=96 gfp_flags=GFP_NOFS|GFP_ZERO - X 888 [002] 29643.445546: kmem:kmalloc_node: call_site=ffffffff8153c67e ptr=0xffff880103828e00 bytes_req=384 bytes_alloc=512 gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC node=-1 + X 888 [002] 29643.445546: kmem:kmalloc_node: (__alloc_skb+0x7e) call_site=ffffffff8153c67e ptr=0xffff880103828e00 bytes_req=384 bytes_alloc=512 gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC node=-1
--- tools/lib/traceevent/Makefile | 1 + tools/lib/traceevent/plugin_kmem.c | 72 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 tools/lib/traceevent/plugin_kmem.c
tools/lib/traceevent/Makefile +1 -0
@@ -204,6 +204,7 @@ PEVENT_LIB_OBJS += kbuffer-parse.o PLUGIN_OBJS = plugin_jbd2.o PLUGIN_OBJS += plugin_hrtimer.o +PLUGIN_OBJS += plugin_kmem.o PLUGINS := $(PLUGIN_OBJS:.o=.so)
tools/lib/traceevent/plugin_kmem.c new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 06/22] tools lib traceevent: Add kmem plugin
Quoted 95 lines · On Thu, 21 Nov 2013 12:01:04 +0100 Jiri Olsa <[email protected]> wrote:
Backporting kmem plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds
call_sitefield resolving for following tracepoint events:
kmem:kfree
kmem:kmalloc
kmem:kmalloc_node
kmem:kmem_cache_alloc kmem:kmem_cache_alloc_node kmem:kmem_cache_freeThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kmem:*' -a')script.kmem.new renamed from script.kmem.old +6
-6- perf 27846 [001] 29643.403319: kmem:kfree: call_site=ffffffff810e64f6 ptr=(nil) + perf 27846 [001] 29643.403238: kmem:kfree: (__audit_syscall_exit+0x1f6) call_site=ffffffff810e64f6 ptr=(nil) - perf 27846 [001] 29643.403337: kmem:kmem_cache_alloc: call_site=ffffffff812ff0c5 ptr=0xffff88020e155630 bytes_req=560 bytes_alloc=568 gfp_flags=GFP_KERNEL + perf 27846 [001] 29643.403337: kmem:kmem_cache_alloc: (radix_tree_preload+0x35) call_site=ffffffff812ff0c5 ptr=0xffff88020e155630 bytes_req=560 bytes_alloc=568 gfp_flags=GFP_KERNEL - perf 27846 [001] 29643.403342: kmem:kmem_cache_free: call_site=ffffffff8126ec61 ptr=0xffff88020dffe750 + perf 27846 [001] 29643.403342: kmem:kmem_cache_free: (jbd2_journal_stop+0x221) call_site=ffffffff8126ec61 ptr=0xffff88020dffe750 - firefox 954 [000] 29643.445477: kmem:kmem_cache_alloc_node: call_site=ffffffff8153c64e ptr=0xffff8801cecb4000 bytes_req=256 bytes_alloc=256 gfp_flags=GFP_KERNEL|GFP_REPEAT node=-1 + firefox 954 [000] 29643.445477: kmem:kmem_cache_alloc_node: (__alloc_skb+0x4e) call_site=ffffffff8153c64e ptr=0xffff8801cecb4000 bytes_req=256 bytes_alloc=256 gfp_flags=GFP_KERNEL|GFP_REPEAT node=-1 - perf 27846 [001] 29643.445510: kmem:kmalloc: call_site=ffffffff81250642 ptr=0xffff88020fd6c300 bytes_req=96 bytes_alloc=96 gfp_flags=GFP_NOFS|GFP_ZERO + perf 27846 [001] 29643.445510: kmem:kmalloc: (ext4_ext_find_extent+0x362) call_site=ffffffff81250642 ptr=0xffff88020fd6c300 bytes_req=96 bytes_alloc=96 gfp_flags=GFP_NOFS|GFP_ZERO - X 888 [002] 29643.445546: kmem:kmalloc_node: call_site=ffffffff8153c67e ptr=0xffff880103828e00 bytes_req=384 bytes_alloc=512 gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC node=-1 + X 888 [002] 29643.445546: kmem:kmalloc_node: (__alloc_skb+0x7e) call_site=ffffffff8153c67e ptr=0xffff880103828e00 bytes_req=384 bytes_alloc=512 gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC node=-1Signed-off-by Jiri Olsa <[email protected]>Cc Corey Ashford <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Namhyung Kim <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Steven Rostedt <[email protected]>Cc David Ahern <[email protected]>--- tools/lib/traceevent/Makefile | 1 + tools/lib/traceevent/plugin_kmem.c | 72 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 tools/lib/traceevent/plugin_kmem.ctools/lib/traceevent/Makefile +1
-0@@ -204,6 +204,7 @@ PEVENT_LIB_OBJS += kbuffer-parse.o PLUGIN_OBJS = plugin_jbd2.o PLUGIN_OBJS += plugin_hrtimer.o +PLUGIN_OBJS += plugin_kmem.o PLUGINS := $(PLUGIN_OBJS:.o=.so)tools/lib/traceevent/plugin_kmem.c new file +29
-0@@ -0,0 +1,72 @@ +/* +* Copyright (C) 2009 Red Hat Inc, Steven Rostedt <[email protected]> +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License (not later!) +* +* 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 Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program; if not, see <http://www.gnu.org/licenses> +* +* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "event-parse.h" + +static int call_site_handler (struct trace_seq *s,struct pevent_record *record, +struct event_format *event,void *context) +{ +struct format_field *field;
tools/lib/traceevent/plugin_kmem.c line 39
Quoted 10 lines
tools/lib/traceevent/plugin_kmem.c new file +10
-0+unsigned long long val, addr; +void *data = record->data; +const char *func; + + field =pevent_find_field (event,"call_site" ); +if (!field) +return 1 ; + +if (pevent_read_number_field (field, data, &val)) +return 1 ;
This was one of the older plugins. We can simplify this with:
if (pevent_get_field_val(s, event, "call_site", record, &val, 0)) return 1;
Would would replace the above two checks.
But we can fix this later. As I'm sure there's other places that can use these updates.
-- Steve
Quoted 33 lines
tools/lib/traceevent/plugin_kmem.c new file +33
-0+ + func =pevent_find_function (event->pevent, val); +if (!func) +return 1 ; + + addr =pevent_find_function_address (event->pevent, val); + +trace_seq_printf (s,"(%s+0x%x) " , func, (int )(val - addr)); +return 1 ; +} + +int PEVENT_PLUGIN_LOADER (struct pevent *pevent) +{ +pevent_register_event_handler (pevent,-1 ,"kmem" ,"kfree" , + call_site_handler,NULL ); + +pevent_register_event_handler (pevent,-1 ,"kmem" ,"kmalloc" , + call_site_handler,NULL ); + +pevent_register_event_handler (pevent,-1 ,"kmem" ,"kmalloc_node" , + call_site_handler,NULL ); + +pevent_register_event_handler (pevent,-1 ,"kmem" ,"kmem_cache_alloc" , + call_site_handler,NULL ); + +pevent_register_event_handler (pevent,-1 ,"kmem" , +"kmem_cache_alloc_node" , + call_site_handler,NULL ); + +pevent_register_event_handler (pevent,-1 ,"kmem" ,"kmem_cache_free" , + call_site_handler,NULL ); +return 0 ; +}
Namhyung Kim
maintainerRe: [PATCH 06/22] tools lib traceevent: Add kmem plugin
In reply to Jiri Olsa2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 21 lines
Backporting kmem plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds
call_sitefield resolving for following tracepoint events:
kmem:kfree
kmem:kmalloc
kmem:kmalloc_node
kmem:kmem_cache_alloc kmem:kmem_cache_alloc_node kmem:kmem_cache_freeThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kmem:*' -a')script.kmem.new renamed from script.kmem.old +1
-1- perf 27846 [001] 29643.403319: kmem:kfree: call_site=ffffffff810e64f6 ptr=(nil) + perf 27846 [001] 29643.403238: kmem:kfree: (__audit_syscall_exit+0x1f6) call_site=ffffffff810e64f6 ptr=(nil)
script.kmem.new
Quoted 10 lines
script.kmem.new renamed from script.kmem.old +5
-5- perf 27846 [001] 29643.403337: kmem:kmem_cache_alloc: call_site=ffffffff812ff0c5 ptr=0xffff88020e155630 bytes_req=560 bytes_alloc=568 gfp_flags=GFP_KERNEL + perf 27846 [001] 29643.403337: kmem:kmem_cache_alloc: (radix_tree_preload+0x35) call_site=ffffffff812ff0c5 ptr=0xffff88020e155630 bytes_req=560 bytes_alloc=568 gfp_flags=GFP_KERNEL - perf 27846 [001] 29643.403342: kmem:kmem_cache_free: call_site=ffffffff8126ec61 ptr=0xffff88020dffe750 + perf 27846 [001] 29643.403342: kmem:kmem_cache_free: (jbd2_journal_stop+0x221) call_site=ffffffff8126ec61 ptr=0xffff88020dffe750 - firefox 954 [000] 29643.445477: kmem:kmem_cache_alloc_node: call_site=ffffffff8153c64e ptr=0xffff8801cecb4000 bytes_req=256 bytes_alloc=256 gfp_flags=GFP_KERNEL|GFP_REPEAT node=-1 + firefox 954 [000] 29643.445477: kmem:kmem_cache_alloc_node: (__alloc_skb+0x4e) call_site=ffffffff8153c64e ptr=0xffff8801cecb4000 bytes_req=256 bytes_alloc=256 gfp_flags=GFP_KERNEL|GFP_REPEAT node=-1 - perf 27846 [001] 29643.445510: kmem:kmalloc: call_site=ffffffff81250642 ptr=0xffff88020fd6c300 bytes_req=96 bytes_alloc=96 gfp_flags=GFP_NOFS|GFP_ZERO + perf 27846 [001] 29643.445510: kmem:kmalloc: (ext4_ext_find_extent+0x362) call_site=ffffffff81250642 ptr=0xffff88020fd6c300 bytes_req=96 bytes_alloc=96 gfp_flags=GFP_NOFS|GFP_ZERO - X 888 [002] 29643.445546: kmem:kmalloc_node: call_site=ffffffff8153c67e ptr=0xffff880103828e00 bytes_req=384 bytes_alloc=512 gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC node=-1 + X 888 [002] 29643.445546: kmem:kmalloc_node: (__alloc_skb+0x7e) call_site=ffffffff8153c67e ptr=0xffff880103828e00 bytes_req=384 bytes_alloc=512 gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC node=-1
It'd be great if the "call_site" in the output changes to display function names instead of hex addresses directly.
Thanks,
Namhyung
Re: [PATCH 06/22] tools lib traceevent: Add kmem plugin
Quoted 27 lines · On Fri, 22 Nov 2013 23:38:17 +0900 Namhyung Kim <[email protected]> wrote:
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 26 lines
Backporting kmem plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds
call_sitefield resolving for following tracepoint events:
kmem:kfree
kmem:kmalloc
kmem:kmalloc_node
kmem:kmem_cache_alloc kmem:kmem_cache_alloc_node kmem:kmem_cache_freeThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kmem:*' -a')script.kmem.new renamed from script.kmem.old +3
-4- perf 27846 [001] 29643.403319: kmem:kfree: call_site=ffffffff810e64f6 ptr=(nil) + perf 27846 [001] 29643.403238: kmem:kfree: (__audit_syscall_exit+0x1f6) call_site=ffffffff810e64f6 ptr=(nil) - perf 27846 [001] 29643.403337: kmem:kmem_cache_alloc: call_site=ffffffff812ff0c5 ptr=0xffff88020e155630 bytes_req=560 bytes_alloc=568 gfp_flags=GFP_KERNEL + perf 27846 [001] 29643.403337: kmem:kmem_cache_alloc: (radix_tree_preload+0x35) call_site=ffffffff812ff0c5 ptr=0xffff88020e155630 bytes_req=560 bytes_alloc=568 gfp_flags=GFP_KERNEL - perf 27846 [001] 29643.403342: kmem:kmem_cache_free: call_site=ffffffff8126ec61 ptr=0xffff88020dffe750 + perf 27846 [001] 29643.403342: kmem:kmem_cache_free: (jbd2_journal_stop+0x221) call_site=ffffffff8126ec61 ptr=0xffff88020dffe750 - firefox 954 [000] 29643.445477: kmem:kmem_cache_alloc_node: call_site=ffffffff8153c64e ptr=0xffff8801cecb4000 bytes_req=256 bytes_alloc=256 gfp_flags=GFP_KERNEL|GFP_REPEAT node=-1
Quoted 9 lines
script.kmem.new
Quoted 5 lines
script.kmem.new renamed from script.kmem.old +3
-2+ firefox 954 [000] 29643.445477: kmem:kmem_cache_alloc_node: (__alloc_skb+0x4e) call_site=ffffffff8153c64e ptr=0xffff8801cecb4000 bytes_req=256 bytes_alloc=256 gfp_flags=GFP_KERNEL|GFP_REPEAT node=-1 - perf 27846 [001] 29643.445510: kmem:kmalloc: call_site=ffffffff81250642 ptr=0xffff88020fd6c300 bytes_req=96 bytes_alloc=96 gfp_flags=GFP_NOFS|GFP_ZERO + perf 27846 [001] 29643.445510: kmem:kmalloc: (ext4_ext_find_extent+0x362) call_site=ffffffff81250642 ptr=0xffff88020fd6c300 bytes_req=96 bytes_alloc=96 gfp_flags=GFP_NOFS|GFP_ZERO - X 888 [002] 29643.445546: kmem:kmalloc_node: call_site=ffffffff8153c67e ptr=0xffff880103828e00 bytes_req=384 bytes_alloc=512 gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC node=-1 + X 888 [002] 29643.445546: kmem:kmalloc_node: (__alloc_skb+0x7e) call_site=ffffffff8153c67e ptr=0xffff880103828e00 bytes_req=384 bytes_alloc=512 gfp_flags=GFP_KERNEL|GFP_NOWARN|GFP_REPEAT|GFP_NOMEMALLOC node=-1It'd be great if the "
call_site" in the output changes to display function names instead of hex addresses directly.
Actually, that's what's in the ().
kmem:kmalloc_node: (__alloc_skb+0x7e) call_site=ffffffff8153c67e
This uses a short cut, where we don't overwrite the entire handler, in case the TP_printk() gets new fields.
If the registered handler for an event, like "call_site_handler" (see how we use it for all of tracepoints) returns >0, that tells the library that we only added extra information, and to print the tracepoint as it is normally.
The better solution here is to use "%pS" or something in the actual tracepoint instead.
-- Steve
Namhyung Kim
maintainerRe: [PATCH 06/22] tools lib traceevent: Add kmem plugin
Quoted 10 lines · Steven Rostedt
Quoted 3 lines · On Fri, 22 Nov 2013 23:38:17 +0900 Namhyung Kim <[email protected]> wrote:
It'd be great if the "
call_site" in the output changes to display function names instead of hex addresses directly.Actually, that's what's in the ().
kmem:kmalloc_node: (__alloc_skb+0x7e) call_site=ffffffff8153c67e
Quoted 7 lines
This uses a short cut, where we don't overwrite the entire handler, in case the
TP_printk()gets new fields.If the registered handler for an event, like "
call_site_handler" (see how we use it for all of tracepoints) returns >0, that tells the library that we only added extra information, and to print the tracepoint as it is normally.
Yeah, I know. But just want to say that it'd be better if it's displayed like below.
kmem:kmalloc_node: call_site=__alloc_skb+0x7e ...
But it requires to write new handlers for each event..
Quoted 3 lines
The better solution here is to use "%pS" or something in the actual tracepoint instead.
Agreed.
Thanks,
Namhyung
PATCH 7/22 tools lib traceevent: Add kvm plugin
In reply to Jiri OlsaBackporting kvm plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
This plugin adds field resolving functions for following tracepoint events:
kvm:kvm_exit
kvm:kvm_emulate_insn
kvm:kvm_nested_vmexit kvm:kvm_nested_vmexit_inject kvmmmu:kvm_mmu_get_page kvmmmu:kvm_mmu_sync_page kvmmmu:kvm_mmu_unsync_page kvmmmu:kvm_mmu_zap_page kvmmmu:kvm_mmu_prepare_zap_page
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kvm:*,kvmmmu:*' -a')
--- script.kvm.old
+++ script.kvm.new
qemu-system-x86 17414 [000] 6868.995053: kvm:kvm_exit: reason EPT_VIOLATION rip 0xfff0 info 184 0 qemu-system-x86 17414 [000] 6868.995109: kvm:kvm_emulate_insn: f0000:c46b:e4 71 (real)
- qemu-system-x86 3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: [FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root_count=0 unsync=0 created=1 + qemu-system-x86 3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: new sp gfn 0 0/4 q0 direct --- !pge !nxe root 0 sync - qemu-system-x86 3006 [002] 10562.080502: kvmmmu:kvm_mmu_prepare_zap_page: [FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root_count=1 unsync=0 + qemu-system-x86 3006 [002] 10562.080502: kvmmmu:kvm_mmu_prepare_zap_page: 0/4 q0 direct --- !pge !nxe root 1 sync qemu-system-x86 3290 [002] 10708.755312: kvmmmu:fast_page_fault: [FAILED TO PARSE] vcpu_id=0 gva=4094486080 error_code=3 sptep=0xffff88019f1e3670 old_spte=336391285 new_spte=336391287 retry=1 - insmod 2576 [001] 781.731666: kvmmmu:kvm_mmu_sync_page: [FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count=10 unsync=1 + insmod 2576 [001] 781.731666: kvmmmu:kvm_mmu_sync_page: 3/0 q0 --- !pge !nxe root 10 unsync - insmod 2576 [001] 781.731668: kvmmmu:kvm_mmu_unsync_page: [FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count=10 unsync=1 + insmod 2576 [001] 781.731668: kvmmmu:kvm_mmu_unsync_page: 3/0 q0 --- !pge !nxe root 10 unsync
Note:
- kvm_mmu_zap_page is replaced by kvm_mmu_prepare_zap_page in current kernel, keeping it for backward compatibility
- some of the tracepoints keep the same output even with the plugin handling: kvm:kvm_exit, kvm:kvm_emulate_insn
- the 'kvmmmu:fast_page_fault' is still broken because of missing is_writable_pte function and is fixed in another patch
- ommited following tracepoints from backport because the output was buggy
kvm:kvm_nested_vmexit
kvm:kvm_nested_vmexit_inject
--- tools/lib/traceevent/Makefile | 1 + tools/lib/traceevent/plugin_kvm.c | 419 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 420 insertions(+) create mode 100644 tools/lib/traceevent/plugin_kvm.c
tools/lib/traceevent/Makefile +1 -0
@@ -205,6 +205,7 @@ PEVENT_LIB_OBJS += kbuffer-parse.o PLUGIN_OBJS = plugin_jbd2.o PLUGIN_OBJS += plugin_hrtimer.o PLUGIN_OBJS += plugin_kmem.o +PLUGIN_OBJS += plugin_kvm.o PLUGINS := $(PLUGIN_OBJS:.o=.so)
tools/lib/traceevent/plugin_kvm.c new file +419 -0
419 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 07/22] tools lib traceevent: Add kvm plugin
Quoted 46 lines · On Thu, 21 Nov 2013 12:01:05 +0100 Jiri Olsa <[email protected]> wrote:
Backporting kvm plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds field resolving functions for following tracepoint events:
kvm:kvm_exit
kvm:kvm_emulate_insn
kvm:kvm_nested_vmexit kvm:kvm_nested_vmexit_inject kvmmmu:kvm_mmu_get_page kvmmmu:kvm_mmu_sync_page kvmmmu:kvm_mmu_unsync_page kvmmmu:kvm_mmu_zap_page kvmmmu:kvm_mmu_prepare_zap_pageThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kvm:*,kvmmmu:*' -a')script.kvm.new renamed from script.kvm.old +4
-4qemu-system-x86 17414 [000] 6868.995053: kvm:kvm_exit: reason EPT_VIOLATION rip 0xfff0 info 184 0 qemu-system-x86 17414 [000] 6868.995109: kvm:kvm_emulate_insn: f0000:c46b:e4 71 (real) - qemu-system-x86 3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: [FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root_count=0 unsync=0 created=1 + qemu-system-x86 3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: new sp gfn 0 0/4 q0 direct --- !pge !nxe root 0 sync - qemu-system-x86 3006 [002] 10562.080502: kvmmmu:kvm_mmu_prepare_zap_page: [FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root_count=1 unsync=0 + qemu-system-x86 3006 [002] 10562.080502: kvmmmu:kvm_mmu_prepare_zap_page: 0/4 q0 direct --- !pge !nxe root 1 sync qemu-system-x86 3290 [002] 10708.755312: kvmmmu:fast_page_fault: [FAILED TO PARSE] vcpu_id=0 gva=4094486080 error_code=3 sptep=0xffff88019f1e3670 old_spte=336391285 new_spte=336391287 retry=1 - insmod 2576 [001] 781.731666: kvmmmu:kvm_mmu_sync_page: [FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count=10 unsync=1 + insmod 2576 [001] 781.731666: kvmmmu:kvm_mmu_sync_page: 3/0 q0 --- !pge !nxe root 10 unsync - insmod 2576 [001] 781.731668: kvmmmu:kvm_mmu_unsync_page: [FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count=10 unsync=1 + insmod 2576 [001] 781.731668: kvmmmu:kvm_mmu_unsync_page: 3/0 q0 --- !pge !nxe root 10 unsyncNote:
-kvm_mmu_zap_pageis replaced bykvm_mmu_prepare_zap_pagein current kernel, keeping it for backward compatibility
- some of the tracepoints keep the same output even with the plugin handling: kvm:kvm_exit, kvm:kvm_emulate_insn
- the 'kvmmmu:fast_page_fault' is still broken because of missingis_writable_ptefunction and is fixed in another patch
- ommited following tracepoints from backport because the output was buggy
kvm:kvm_nested_vmexit
kvm:kvm_nested_vmexit_inject
Quoted 9 lines
Signed-off-by Jiri Olsa <[email protected]>Cc Corey Ashford <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Namhyung Kim <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Steven Rostedt <[email protected]>
-- Steve
Quoted 2 lines
Cc David Ahern <[email protected]>---
Namhyung Kim
maintainerRe: [PATCH 07/22] tools lib traceevent: Add kvm plugin
In reply to Jiri Olsa2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 45 lines
Backporting kvm plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds field resolving functions for following tracepoint events:
kvm:kvm_exit
kvm:kvm_emulate_insn
kvm:kvm_nested_vmexit kvm:kvm_nested_vmexit_inject kvmmmu:kvm_mmu_get_page kvmmmu:kvm_mmu_sync_page kvmmmu:kvm_mmu_unsync_page kvmmmu:kvm_mmu_zap_page kvmmmu:kvm_mmu_prepare_zap_pageThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kvm:*,kvmmmu:*' -a')script.kvm.new renamed from script.kvm.old +4
-4qemu-system-x86 17414 [000] 6868.995053: kvm:kvm_exit: reason EPT_VIOLATION rip 0xfff0 info 184 0 qemu-system-x86 17414 [000] 6868.995109: kvm:kvm_emulate_insn: f0000:c46b:e4 71 (real) - qemu-system-x86 3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: [FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root_count=0 unsync=0 created=1 + qemu-system-x86 3006 [002] 10562.079422: kvmmmu:kvm_mmu_get_page: new sp gfn 0 0/4 q0 direct --- !pge !nxe root 0 sync - qemu-system-x86 3006 [002] 10562.080502: kvmmmu:kvm_mmu_prepare_zap_page: [FAILED TO PARSE] mmu_valid_gen=0x2 gfn=0 role=122884 root_count=1 unsync=0 + qemu-system-x86 3006 [002] 10562.080502: kvmmmu:kvm_mmu_prepare_zap_page: 0/4 q0 direct --- !pge !nxe root 1 sync qemu-system-x86 3290 [002] 10708.755312: kvmmmu:fast_page_fault: [FAILED TO PARSE] vcpu_id=0 gva=4094486080 error_code=3 sptep=0xffff88019f1e3670 old_spte=336391285 new_spte=336391287 retry=1 - insmod 2576 [001] 781.731666: kvmmmu:kvm_mmu_sync_page: [FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count=10 unsync=1 + insmod 2576 [001] 781.731666: kvmmmu:kvm_mmu_sync_page: 3/0 q0 --- !pge !nxe root 10 unsync - insmod 2576 [001] 781.731668: kvmmmu:kvm_mmu_unsync_page: [FAILED TO PARSE] mmu_valid_gen=0x1 gfn=2 role=24624 root_count=10 unsync=1 + insmod 2576 [001] 781.731668: kvmmmu:kvm_mmu_unsync_page: 3/0 q0 --- !pge !nxe root 10 unsyncNote:
-kvm_mmu_zap_pageis replaced bykvm_mmu_prepare_zap_pagein current kernel, keeping it for backward compatibility
- some of the tracepoints keep the same output even with the plugin handling: kvm:kvm_exit, kvm:kvm_emulate_insn
- the 'kvmmmu:fast_page_fault' is still broken because of missingis_writable_ptefunction and is fixed in another patch
- ommited following tracepoints from backport because the output was buggy
kvm:kvm_nested_vmexit
kvm:kvm_nested_vmexit_inject
[SNIP]
Quoted 28 lines
script.kvm.new renamed from script.kvm.old +28
-0+static int kvm_mmu_print_role(struct trace_seq *s, struct pevent_record *record, + struct event_format *event, void *context) +{ + unsigned long long val; + static const char *access_str[] = { + "---", "--x", "w--", "w-x", "-u-", "-ux", "wu-", "wux" + }; + union kvm_mmu_page_role role; + + if (pevent_get_field_val(s, event, "role", record, &val, 1) < 0) + return -1; + + role.word = (int)val; + + /* + * We can only use the structure if file is of the same + * endianess. + */ + if (pevent_is_file_bigendian(event->pevent) == + pevent_is_host_bigendian(event->pevent)) { + + trace_seq_printf(s, "%u/%u q%u%s %s%s %spge %snxe", + role.level, + role.glevels, + role.quadrant, + role.direct ? " direct" : "", + access_str[role.access], + role.invalid ? " invalid" : "",
script.kvm.new
Quoted 10 lines
script.kvm.new renamed from script.kvm.old +10
-0+ role.cr4_pge ? "" : "!", + role.nxe ? "" : "!"); + } else + trace_seq_printf(s, "WORD: %08x", role.word); + + pevent_print_num_field(s, " root %u ", event, + "root_count", record, 1); + + if (pevent_get_field_val(s, event, "unsync", record, &val, 1) < 0) + return -1;
Hmm.. it seems this returning from the middle of function can make output hard to parse. How about printing 'unknown' if the field not found?
script.kvm.new
Quoted 2 lines
script.kvm.new renamed from script.kvm.old +2
-0+ + trace_seq_printf(s, "%s%c", val ? "unsync" : "sync", 0);
Why did you print %c (0) at the end?
Thanks,
Namhyung
Quoted 2 lines
script.kvm.new renamed from script.kvm.old +2
-0+ return 0; +}
Re: [PATCH 07/22] tools lib traceevent: Add kvm plugin
Quoted 9 lines · On Fri, 22 Nov 2013 23:45:24 +0900 Namhyung Kim <[email protected]> wrote:
tools/lib/traceevent/plugin_kvm.c line 368
Quoted 5 lines
tools/lib/traceevent/plugin_kvm.c new file +5
-0+pevent_print_num_field (s," root %u " , event, +"root_count" , record,1 ); + +if (pevent_get_field_val (s, event,"unsync" , record, &val,1 ) <0 ) +return -1 ;Hmm.. it seems this returning from the middle of function can make output hard to parse. How about printing 'unknown' if the field not found?
I wasn't fully correct in my last email. If the handler returns anything but zero, the TP_print() will go in affect. Thus, if this fails, then the default print will happen anyway.
It shouldn't fail. But yeah, we could think of adding "unknow" and such too. That can go as a separate patch.
Quoted 5 lines
tools/lib/traceevent/plugin_kvm.c line 370
Quoted 3 lines
tools/lib/traceevent/plugin_kvm.c new file +2
-0+ +trace_seq_printf (s,"%s%c" , val ?"unsync" :"sync" ,0 );Why did you print %c (0) at the end?
I simulated exactly what was (and still is) in the kvm tracepoint:
arch/x86/kvm/mmutrace.h:
trace_seq_printf(p, "sp gfn %llx %u%s q%u%s %s%s" \
" %snxe root %u %s%c", \
__entry->gfn, role.level, \
role.cr4_pae ? " pae" : "", \
role.quadrant, \
role.direct ? " direct" : "", \
access_str[role.access], \
role.invalid ? " invalid" : "", \
role.nxe ? "" : "!", \
__entry->root_count, \
__entry->unsync ? "unsync" : "sync", 0); \-- Steve
Quoted 8 lines
Thanks,
NamhyungQuoted 2 lines
(quoted diff) +2
-0+ return 0; +}
PATCH 8/22 tools lib traceevent: Add mac80211 plugin
In reply to Jiri OlsaBackporting mac80211 plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
This plugin adds changed field resolving for mac80211:drv_bss_info_changed tracepoint event.
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'mac80211:drv_bss_info_changed' -a')
--- script.mac80211.old
+++ script.mac80211.new
- ifconfig 3711 [000] 1290.446492: mac80211:drv_bss_info_changed: phy0 vif:wlan0(2) changed:0x309f + ifconfig 3711 [000] 1290.446492: mac80211:drv_bss_info_changed: phy0 vif:wlan0(2) + assoc:0 aid:2 cts:0 shortpre:0 shortslot:0 dtimper:1 + bcnint:102 assoc_cap:0x431 basic_rates:0xf enable_beacon:0 + ht_operation_mode:0
Omitting the mac80211:drv_config tracepoint handling because the kernel tracepoint changed its prototype and the plugin handler is no longer working.
--- tools/lib/traceevent/Makefile | 1 + tools/lib/traceevent/plugin_mac80211.c | 95 ++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 tools/lib/traceevent/plugin_mac80211.c
tools/lib/traceevent/Makefile +1 -0
@@ -206,6 +206,7 @@ PLUGIN_OBJS = plugin_jbd2.o PLUGIN_OBJS += plugin_hrtimer.o PLUGIN_OBJS += plugin_kmem.o PLUGIN_OBJS += plugin_kvm.o +PLUGIN_OBJS += plugin_mac80211.o PLUGINS := $(PLUGIN_OBJS:.o=.so)
tools/lib/traceevent/plugin_mac80211.c new file +95 -0
95 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 9/22 tools lib traceevent: Add sched_switch plugin
In reply to Jiri OlsaBackporting sched_switch plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
This plugin adds fields resolving for sched:sched_switch tracepoint event.
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e sched:sched_switch -a')
--- script.sched_switch.old
+++ script.sched_switch.new
- perf 577 [002] 30965.311852: sched:sched_switch: prev_comm=perf prev_pid=577 prev_prio=120 prev_state=S ==> next_comm=swapper/2 next_pid=0 next_prio=120 + perf 577 [002] 30965.311852: sched:sched_switch: perf:577 [120] S ==> swapper/2:0 [120]
--- tools/lib/traceevent/Makefile | 1 + tools/lib/traceevent/plugin_sched_switch.c | 148 +++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 tools/lib/traceevent/plugin_sched_switch.c
tools/lib/traceevent/Makefile +1 -0
@@ -207,6 +207,7 @@ PLUGIN_OBJS += plugin_hrtimer.o PLUGIN_OBJS += plugin_kmem.o PLUGIN_OBJS += plugin_kvm.o PLUGIN_OBJS += plugin_mac80211.o +PLUGIN_OBJS += plugin_sched_switch.o PLUGINS := $(PLUGIN_OBJS:.o=.so)
tools/lib/traceevent/plugin_sched_switch.c new file +148 -0
148 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 09/22] tools lib traceevent: Add sched_switch plugin
Quoted 16 lines · On Thu, 21 Nov 2013 12:01:07 +0100 Jiri Olsa <[email protected]> wrote:
Backporting
sched_switchplugin.Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds fields resolving for sched:sched_switch tracepoint event.
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e sched:sched_switch -a')script.sched_switch.new renamed from script.sched_switch.old +1
-1- perf 577 [002] 30965.311852: sched:sched_switch: prev_comm=perf prev_pid=577 prev_prio=120 prev_state=S ==> next_comm=swapper/2 next_pid=0 next_prio=120 + perf 577 [002] 30965.311852: sched:sched_switch: perf:577 [120] S ==> swapper/2:0 [120]
Quoted 9 lines
Signed-off-by Jiri Olsa <[email protected]>Cc Corey Ashford <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Namhyung Kim <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Steven Rostedt <[email protected]>
-- Steve
Quoted 7 lines
Cc David Ahern <[email protected]>--- tools/lib/traceevent/Makefile | 1 + tools/lib/traceevent/plugin_sched_switch.c | 148 +++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 tools/lib/traceevent/plugin_sched_switch.c
A message that is not in the archive (sent off-list or not yet received): 1385132034.1747.58.camel@leonhard
Re: [PATCH 09/22] tools lib traceevent: Add sched_switch plugin
Quoted 46 lines · On Fri, 22 Nov 2013 23:53:54 +0900 Namhyung Kim <[email protected]> wrote:
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 15 lines
Backporting
sched_switchplugin.Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds fields resolving for
sched:sched_switch tracepoint event.The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e sched:sched_switch -a')script.sched_switch.new renamed from script.sched_switch.old +1
-1- perf 577 [002] 30965.311852: sched:sched_switch: prev_comm=perf prev_pid=577 prev_prio=120 prev_state=S ==> next_comm=swapper/2 next_pid=0 next_prio=120 + perf 577 [002] 30965.311852: sched:sched_switch: perf:577 [120] S ==> swapper/2:0 [120][SNIP]
Quoted 25 lines
script.sched_switch.new renamed from script.sched_switch.old +25
-0+ +static int sched_switch_handler(struct trace_seq *s, + struct pevent_record *record, + struct event_format *event, void *context) +{ + struct format_field *field; + unsigned long long val; + + if (pevent_get_field_val(s, event, "prev_pid", record, &val, 1)) + return trace_seq_putc(s, '!'); + + field = pevent_find_any_field(event, "prev_comm"); + if (field) { + write_and_save_comm(field, record, s, val); + trace_seq_putc(s, ':'); + } + trace_seq_printf(s, "%lld ", val); + + if (pevent_get_field_val(s, event, "prev_prio", record, &val, 0) == 0) + trace_seq_printf(s, "[%lld] ", val); + + if (pevent_get_field_val(s, event, "prev_state", record, &val, 0) == 0) + write_state(s, val); + + trace_seq_puts(s, " ==> ");
Quoted 9 lines
script.sched_switch.new
Quoted 3 lines
script.sched_switch.new renamed from script.sched_switch.old +3
-0+ + if (pevent_get_field_val(s, event, "next_pid", record, &val, 1)) + return trace_seq_putc(s, '!');Like I said in the previous reply, it'd better to avoid returning from the middle of function IMHO. If it's really critical info, check it at the beginning of the function and bail out before print anything.
Well, it shouldn't lose any data, as I said in a previous reply, it will print (reprint) the data as if the plugin didn't exist.
-- Steve
PATCH 10/22 tools lib traceevent: Add function plugin
In reply to Jiri OlsaBackporting function plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
This plugin adds function and parent function fields resolving for ftrace:function tracepoint event.
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e ftrace:function ls')
--- script.function.old
+++ script.function.new
- ls 10781 [001] 32667.291379: ftrace:function: ffffffff811adb80 <-- ffffffff811afc48 - ls 10781 [001] 32667.291379: ftrace:function: ffffffff811b35d0 <-- ffffffff811adb9b - ls 10781 [001] 32667.291380: ftrace:function: ffffffff811b3520 <-- ffffffff811b35e8 - ls 10781 [001] 32667.291380: ftrace:function: ffffffff811b2720 <-- ffffffff811b3549 - ls 10781 [001] 32667.291381: ftrace:function: ffffffff81297e10 <-- ffffffff811b356c - ls 10781 [001] 32667.291381: ftrace:function: ffffffff81298f40 <-- ffffffff81297e2c - ls 10781 [001] 32667.291382: ftrace:function: ffffffff81076160 <-- ffffffff811afbf0 - ls 10781 [001] 32667.291383: ftrace:function: ffffffff811c3eb0 <-- ffffffff811afbfc - ls 10781 [001] 32667.291383: ftrace:function: ffffffff8164e100 <-- ffffffff811c3ed8 - ls 10781 [001] 32667.291384: ftrace:function: ffffffff811a5d10 <-- ffffffff811c3f53 - ls 10781 [001] 32667.291384: ftrace:function: ffffffff811e8e70 <-- ffffffff811a5d58 - ls 10781 [001] 32667.291385: ftrace:function: ffffffff811f38e0 <-- ffffffff811a5d63 - ls 10781 [001] 32667.291385: ftrace:function: ffffffff811a9ff0 <-- ffffffff811a5d6b - ls 10781 [001] 32667.291386: ftrace:function: ffffffff811a9fa0 <-- ffffffff811aa015 - ls 10781 [001] 32667.291387: ftrace:function: ffffffff810851c0 <-- ffffffff811aa053 - ls 10781 [001] 32667.291387: ftrace:function: ffffffff81090e00 <-- ffffffff81085211 + ls 10781 [001] 32667.291379: ftrace:function: would_dump <-- setup_new_exec + ls 10781 [001] 32667.291379: ftrace:function: inode_permission <-- would_dump + ls 10781 [001] 32667.291380: ftrace:function: __inode_permission <-- inode_permission + ls 10781 [001] 32667.291380: ftrace:function: generic_permission <-- __inode_permission + ls 10781 [001] 32667.291381: ftrace:function: security_inode_permission <-- __inode_permission + ls 10781 [001] 32667.291381: ftrace:function: cap_inode_permission <-- security_inode_permission + ls 10781 [001] 32667.291382: ftrace:function: flush_signal_handlers <-- setup_new_exec + ls 10781 [001] 32667.291383: ftrace:function: do_close_on_exec <-- setup_new_exec + ls 10781 [001] 32667.291383: ftrace:function: _raw_spin_lock <-- do_close_on_exec + ls 10781 [001] 32667.291384: ftrace:function: filp_close <-- do_close_on_exec + ls 10781 [001] 32667.291384: ftrace:function: dnotify_flush <-- filp_close + ls 10781 [001] 32667.291385: ftrace:function: locks_remove_posix <-- filp_close + ls 10781 [001] 32667.291385: ftrace:function: fput <-- filp_close + ls 10781 [001] 32667.291386: ftrace:function: file_sb_list_del <-- fput + ls 10781 [001] 32667.291387: ftrace:function: task_work_add <-- fput + ls 10781 [001] 32667.291387: ftrace:function: kick_process <-- task_work_add
Removing options support as it's not backported yet. Currently this plugin supports 2 options:
'parent' to display parent function 'indent' to show function call indents
Enabling both of them by default.
--- tools/lib/traceevent/Makefile | 1 + tools/lib/traceevent/plugin_function.c | 151 +++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 tools/lib/traceevent/plugin_function.c
tools/lib/traceevent/Makefile +1 -0
@@ -208,6 +208,7 @@ PLUGIN_OBJS += plugin_kmem.o PLUGIN_OBJS += plugin_kvm.o PLUGIN_OBJS += plugin_mac80211.o PLUGIN_OBJS += plugin_sched_switch.o +PLUGIN_OBJS += plugin_function.o PLUGINS := $(PLUGIN_OBJS:.o=.so)
tools/lib/traceevent/plugin_function.c new file +151 -0
151 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH 10/22] tools lib traceevent: Add function plugin
Quoted 46 lines · On Thu, 21 Nov 2013 12:01:08 +0100 Jiri Olsa <[email protected]> wrote:
Backporting function plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds function and parent function fields resolving for ftrace:function tracepoint event.
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e ftrace:function ls')script.function.new renamed from script.function.old +16
-16- ls 10781 [001] 32667.291379: ftrace:function: ffffffff811adb80 <-- ffffffff811afc48 - ls 10781 [001] 32667.291379: ftrace:function: ffffffff811b35d0 <-- ffffffff811adb9b - ls 10781 [001] 32667.291380: ftrace:function: ffffffff811b3520 <-- ffffffff811b35e8 - ls 10781 [001] 32667.291380: ftrace:function: ffffffff811b2720 <-- ffffffff811b3549 - ls 10781 [001] 32667.291381: ftrace:function: ffffffff81297e10 <-- ffffffff811b356c - ls 10781 [001] 32667.291381: ftrace:function: ffffffff81298f40 <-- ffffffff81297e2c - ls 10781 [001] 32667.291382: ftrace:function: ffffffff81076160 <-- ffffffff811afbf0 - ls 10781 [001] 32667.291383: ftrace:function: ffffffff811c3eb0 <-- ffffffff811afbfc - ls 10781 [001] 32667.291383: ftrace:function: ffffffff8164e100 <-- ffffffff811c3ed8 - ls 10781 [001] 32667.291384: ftrace:function: ffffffff811a5d10 <-- ffffffff811c3f53 - ls 10781 [001] 32667.291384: ftrace:function: ffffffff811e8e70 <-- ffffffff811a5d58 - ls 10781 [001] 32667.291385: ftrace:function: ffffffff811f38e0 <-- ffffffff811a5d63 - ls 10781 [001] 32667.291385: ftrace:function: ffffffff811a9ff0 <-- ffffffff811a5d6b - ls 10781 [001] 32667.291386: ftrace:function: ffffffff811a9fa0 <-- ffffffff811aa015 - ls 10781 [001] 32667.291387: ftrace:function: ffffffff810851c0 <-- ffffffff811aa053 - ls 10781 [001] 32667.291387: ftrace:function: ffffffff81090e00 <-- ffffffff81085211 + ls 10781 [001] 32667.291379: ftrace:function: would_dump <-- setup_new_exec + ls 10781 [001] 32667.291379: ftrace:function: inode_permission <-- would_dump + ls 10781 [001] 32667.291380: ftrace:function: __inode_permission <-- inode_permission + ls 10781 [001] 32667.291380: ftrace:function: generic_permission <-- __inode_permission + ls 10781 [001] 32667.291381: ftrace:function: security_inode_permission <-- __inode_permission + ls 10781 [001] 32667.291381: ftrace:function: cap_inode_permission <-- security_inode_permission + ls 10781 [001] 32667.291382: ftrace:function: flush_signal_handlers <-- setup_new_exec + ls 10781 [001] 32667.291383: ftrace:function: do_close_on_exec <-- setup_new_exec + ls 10781 [001] 32667.291383: ftrace:function: _raw_spin_lock <-- do_close_on_exec + ls 10781 [001] 32667.291384: ftrace:function: filp_close <-- do_close_on_exec + ls 10781 [001] 32667.291384: ftrace:function: dnotify_flush <-- filp_close + ls 10781 [001] 32667.291385: ftrace:function: locks_remove_posix <-- filp_close + ls 10781 [001] 32667.291385: ftrace:function: fput <-- filp_close + ls 10781 [001] 32667.291386: ftrace:function: file_sb_list_del <-- fput + ls 10781 [001] 32667.291387: ftrace:function: task_work_add <-- fput + ls 10781 [001] 32667.291387: ftrace:function: kick_process <-- task_work_add
Quoted 3 lines
Removing options support as it's not backported yet. Currently this plugin supports 2 options:
'parent' to display parent function
The number of times I enabled the parent option, I should make it default too.
Thanks!
Quoted 4 lines
'indent' to show function call indents
Enabling both of them by default.
Quoted 9 lines
Signed-off-by Jiri Olsa <[email protected]>Cc Corey Ashford <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc Namhyung Kim <[email protected]>Cc Paul Mackerras <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Cc Steven Rostedt <[email protected]>
-- Steve
Quoted 7 lines
Cc David Ahern <[email protected]>--- tools/lib/traceevent/Makefile | 1 + tools/lib/traceevent/plugin_function.c | 151 +++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 tools/lib/traceevent/plugin_function.c
Namhyung Kim
maintainerRe: [PATCH 10/22] tools lib traceevent: Add function plugin
In reply to Jiri Olsa2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 52 lines
Backporting function plugin.
Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.gitThis plugin adds function and parent function fields resolving for ftrace:function tracepoint event.
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e ftrace:function ls')script.function.new renamed from script.function.old +16
-16- ls 10781 [001] 32667.291379: ftrace:function: ffffffff811adb80 <-- ffffffff811afc48 - ls 10781 [001] 32667.291379: ftrace:function: ffffffff811b35d0 <-- ffffffff811adb9b - ls 10781 [001] 32667.291380: ftrace:function: ffffffff811b3520 <-- ffffffff811b35e8 - ls 10781 [001] 32667.291380: ftrace:function: ffffffff811b2720 <-- ffffffff811b3549 - ls 10781 [001] 32667.291381: ftrace:function: ffffffff81297e10 <-- ffffffff811b356c - ls 10781 [001] 32667.291381: ftrace:function: ffffffff81298f40 <-- ffffffff81297e2c - ls 10781 [001] 32667.291382: ftrace:function: ffffffff81076160 <-- ffffffff811afbf0 - ls 10781 [001] 32667.291383: ftrace:function: ffffffff811c3eb0 <-- ffffffff811afbfc - ls 10781 [001] 32667.291383: ftrace:function: ffffffff8164e100 <-- ffffffff811c3ed8 - ls 10781 [001] 32667.291384: ftrace:function: ffffffff811a5d10 <-- ffffffff811c3f53 - ls 10781 [001] 32667.291384: ftrace:function: ffffffff811e8e70 <-- ffffffff811a5d58 - ls 10781 [001] 32667.291385: ftrace:function: ffffffff811f38e0 <-- ffffffff811a5d63 - ls 10781 [001] 32667.291385: ftrace:function: ffffffff811a9ff0 <-- ffffffff811a5d6b - ls 10781 [001] 32667.291386: ftrace:function: ffffffff811a9fa0 <-- ffffffff811aa015 - ls 10781 [001] 32667.291387: ftrace:function: ffffffff810851c0 <-- ffffffff811aa053 - ls 10781 [001] 32667.291387: ftrace:function: ffffffff81090e00 <-- ffffffff81085211 + ls 10781 [001] 32667.291379: ftrace:function: would_dump <-- setup_new_exec + ls 10781 [001] 32667.291379: ftrace:function: inode_permission <-- would_dump + ls 10781 [001] 32667.291380: ftrace:function: __inode_permission <-- inode_permission + ls 10781 [001] 32667.291380: ftrace:function: generic_permission <-- __inode_permission + ls 10781 [001] 32667.291381: ftrace:function: security_inode_permission <-- __inode_permission + ls 10781 [001] 32667.291381: ftrace:function: cap_inode_permission <-- security_inode_permission + ls 10781 [001] 32667.291382: ftrace:function: flush_signal_handlers <-- setup_new_exec + ls 10781 [001] 32667.291383: ftrace:function: do_close_on_exec <-- setup_new_exec + ls 10781 [001] 32667.291383: ftrace:function: _raw_spin_lock <-- do_close_on_exec + ls 10781 [001] 32667.291384: ftrace:function: filp_close <-- do_close_on_exec + ls 10781 [001] 32667.291384: ftrace:function: dnotify_flush <-- filp_close + ls 10781 [001] 32667.291385: ftrace:function: locks_remove_posix <-- filp_close + ls 10781 [001] 32667.291385: ftrace:function: fput <-- filp_close + ls 10781 [001] 32667.291386: ftrace:function: file_sb_list_del <-- fput + ls 10781 [001] 32667.291387: ftrace:function: task_work_add <-- fput + ls 10781 [001] 32667.291387: ftrace:function: kick_process <-- task_work_addRemoving options support as it's not backported yet. Currently this plugin supports 2 options:
'parent' to display parent function 'indent' to show function call indentsEnabling both of them by default.
[SNIP]
script.function.new
Quoted 2 lines
script.function.new renamed from script.function.old +2
-0+static struct func_stack { + int index;
It seems not used anywhere.
Quoted 10 lines
script.function.new renamed from script.function.old +10
-0+ int size; + char **stack; +} *fstack; + +static int cpus = -1; + +#define STK_BLK 10 + +static void add_child(struct func_stack *stack, const char *child, int pos) +{
script.function.new
Quoted 10 lines
script.function.new renamed from script.function.old +10
-0+ int i; + + if (!child) + return; + + if (pos < stack->size) + free(stack->stack[pos]); + else { + if (!stack->stack) + stack->stack = malloc_or_die(sizeof(char *) * STK_BLK);
Please do not use this function.
script.function.new
Quoted 3 lines
script.function.new renamed from script.function.old +3
-0+ else + stack->stack = realloc(stack->stack, sizeof(char *) * + (stack->size + STK_BLK));
It seems you need to use a local variable to check return value.
script.function.new
Quoted 9 lines
script.function.new renamed from script.function.old +9
-0+ for (i = stack->size; i < stack->size + STK_BLK; i++) + stack->stack[i] = NULL; + stack->size += STK_BLK; + } + + stack->stack[pos] = strdup(child); +} + +static int get_index(const char *parent, const char *child, int cpu)
It seems this function does not only to get index but also to add function stack. So how about renaming it to something like add_and_get_index()?
script.function.new
Quoted 11 lines
script.function.new renamed from script.function.old +11
-0+{ + int i; + + if (cpu < 0) + return 0; + + if (cpu > cpus) { + if (fstack) + fstack = realloc(fstack, sizeof(*fstack) * (cpu + 1)); + else + fstack = malloc_or_die(sizeof(*fstack) * (cpu + 1));
It seems it has same problem as above function.
Quoted 34 lines
script.function.new renamed from script.function.old +34
-0+ + /* Account for holes in the cpu count */ + for (i = cpus + 1; i <= cpu; i++) + memset(&fstack[i], 0, sizeof(fstack[i])); + cpus = cpu; + } + + for (i = 0; i < fstack[cpu].size && fstack[cpu].stack[i]; i++) { + if (strcmp(parent, fstack[cpu].stack[i]) == 0) { + add_child(&fstack[cpu], child, i+1); + return i; + } + } + + /* Not found */ + add_child(&fstack[cpu], parent, 0); + add_child(&fstack[cpu], child, 1); + return 0; +} + +static int function_handler(struct trace_seq *s, struct pevent_record *record, + struct event_format *event, void *context) +{ + struct pevent *pevent = event->pevent; + unsigned long long function; + unsigned long long pfunction; + const char *func; + const char *parent; + int i, index; + + if (pevent_get_field_val(s, event, "ip", record, &function, 1)) + return trace_seq_putc(s, '!'); + + func = pevent_find_function(pevent, function);
script.function.new
Quoted 10 lines
script.function.new renamed from script.function.old +10
-0+ + if (pevent_get_field_val(s, event, "parent_ip", record, &pfunction, 1)) + return trace_seq_putc(s, '!'); + + parent = pevent_find_function(pevent, pfunction); + + index = get_index(parent, func, record->cpu); + + for (i = 0; i < index; i++) + trace_seq_printf(s, " ");
What about this?
trace_seq_printf(s, "%*s", index*3, "");
Thanks,
Namhyung
Quoted 36 lines
script.function.new renamed from script.function.old +36
-0+ + if (func) + trace_seq_printf(s, "%s", func); + else + trace_seq_printf(s, "0x%llx", function); + + trace_seq_printf(s, " <-- "); + if (parent) + trace_seq_printf(s, "%s", parent); + else + trace_seq_printf(s, "0x%llx", pfunction); + + return 0; +} + +int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +{ + pevent_register_event_handler(pevent, -1, "ftrace", "function", + function_handler, NULL); + return 0; +} + +void PEVENT_PLUGIN_UNLOADER(void) +{ + int i, x; + + for (i = 0; i <= cpus; i++) { + for (x = 0; x < fstack[i].size && fstack[i].stack[x]; x++) + free(fstack[i].stack[x]); + free(fstack[i].stack); + } + + free(fstack); + fstack = NULL; + cpus = -1; +}
Re: [PATCH 10/22] tools lib traceevent: Add function plugin
Quoted 5 lines · On Sat, 23 Nov 2013 00:03:51 +0900 Namhyung Kim <[email protected]> wrote:
Quoted 5 lines
Removing options support as it's not backported yet. Currently this plugin supports 2 options:
'parent' to display parent function 'indent' to show function call indents
Quoted 7 lines
Quoted 1 line
Enabling both of them by default.
[SNIP]
tools/lib/traceevent/plugin_function.c line 28
Quoted 2 lines
tools/lib/traceevent/plugin_function.c new file +2
-0+static struct func_stack { + int index;It seems not used anywhere.
You're right, it's not! Not sure why I added that. Oh well, again, lets add that as a clean up and keep the backport separate.
Quoted 16 lines
Quoted 16 lines
tools/lib/traceevent/plugin_function.c new file +14
-0+int size; +char **stack; +} *fstack; + +static int cpus =-1 ; + +#define STK_BLK 10 + +static void add_child (struct func_stack *stack,const char *child,int pos) +{ +int i; + +if (!child) +return ;
Quoted 8 lines
tools/lib/traceevent/plugin_function.c line 48
Quoted 6 lines
tools/lib/traceevent/plugin_function.c new file +6
-0+ +if (pos < stack->size) +free (stack->stack[pos]); +else { +if (!stack->stack) + stack->stack =malloc_or_die (sizeof (char *) *STK_BLK );Please do not use this function.
Again, added as a separate patch (do I hear a theme ;-)
Quoted 84 lines
tools/lib/traceevent/plugin_function.c line 51
Quoted 5 lines
tools/lib/traceevent/plugin_function.c new file +3
-0+else + stack->stack =realloc (stack->stack,sizeof (char *) * + (stack->size +STK_BLK ));It seems you need to use a local variable to check return value.
tools/lib/traceevent/plugin_function.c line 60
Quoted 9 lines
tools/lib/traceevent/plugin_function.c new file +9
-0+for (i = stack->size; i < stack->size +STK_BLK ; i++) + stack->stack[i] =NULL ; + stack->size +=STK_BLK ; + } + + stack->stack[pos] =strdup (child); +} + +static int get_index (const char *parent,const char *child,int cpu)It seems this function does not only to get index but also to add function stack. So how about renaming it to something like
add_and_get_index()?tools/lib/traceevent/plugin_function.c line 71
Quoted 11 lines
tools/lib/traceevent/plugin_function.c new file +11
-0+{ +int i; + +if (cpu <0 ) +return 0 ; + +if (cpu > cpus) { +if (fstack) + fstack =realloc (fstack,sizeof (*fstack) * (cpu +1 )); +else + fstack =malloc_or_die (sizeof (*fstack) * (cpu +1 ));It seems it has same problem as above function.
Quoted 34 lines
tools/lib/traceevent/plugin_function.c new file +34
-0+ +/* Account for holes in the cpu count */ +for (i = cpus +1 ; i <= cpu; i++) +memset (&fstack[i],0 ,sizeof (fstack[i])); + cpus = cpu; + } + +for (i =0 ; i < fstack[cpu].size && fstack[cpu].stack[i]; i++) { +if (strcmp (parent, fstack[cpu].stack[i]) ==0 ) { +add_child (&fstack[cpu], child, i+1 ); +return i; + } + } + +/* Not found */ +add_child (&fstack[cpu], parent,0 ); +add_child (&fstack[cpu], child,1 ); +return 0 ; +} + +static int function_handler (struct trace_seq *s,struct pevent_record *record, +struct event_format *event,void *context) +{ +struct pevent *pevent = event->pevent; +unsigned long long function; +unsigned long long pfunction; +const char *func; +const char *parent; +int i, index; + +if (pevent_get_field_val (s, event,"ip" , record, &function,1 )) +return trace_seq_putc (s,'!' ); + + func =pevent_find_function (pevent, function);tools/lib/traceevent/plugin_function.c line 115
Quoted 10 lines
tools/lib/traceevent/plugin_function.c new file +10
-0+ +if (pevent_get_field_val (s, event,"parent_ip" , record, &pfunction,1 )) +return trace_seq_putc (s,'!' ); + + parent =pevent_find_function (pevent, pfunction); + + index =get_index (parent, func, record->cpu); + +for (i =0 ; i < index; i++) +trace_seq_printf (s," " );What about this?
Quoted 1 line
trace_seq_printf(s, "%*s", index*3, "");
Nice trick ;-)
I'm fine with all the updates, but lets make that a patch on top.
Thanks,
-- Steve
Quoted 42 lines
Thanks,
NamhyungQuoted 36 lines
tools/lib/traceevent/plugin_function.c new file +36
-0+ +if (func) +trace_seq_printf (s,"%s" , func); +else +trace_seq_printf (s,"0x%llx" , function); + +trace_seq_printf (s," <-- " ); +if (parent) +trace_seq_printf (s,"%s" , parent); +else +trace_seq_printf (s,"0x%llx" , pfunction); + +return 0 ; +} + +int PEVENT_PLUGIN_LOADER (struct pevent *pevent) +{ +pevent_register_event_handler (pevent,-1 ,"ftrace" ,"function" , + function_handler,NULL ); +return 0 ; +} + +void PEVENT_PLUGIN_UNLOADER (void ) +{ +int i, x; + +for (i =0 ; i <= cpus; i++) { +for (x =0 ; x < fstack[i].size && fstack[i].stack[x]; x++) +free (fstack[i].stack[x]); +free (fstack[i].stack); + } + +free (fstack); + fstack =NULL ; + cpus =-1 ; +}
PATCH 11/22 tools lib traceevent: Add xen plugin
In reply to Jiri OlsaAdding xen plugin.
This plugin adds fields resolving for following tracepoint events:
xen:xen_mc_entry xen:xen_mc_extend_args
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'xen:*' ls')
--- script.xen.old
+++ script.xen.new
- swapper 0 [002] 136.267492: xen:xen_mc_entry: [FAILED TO PARSE] op=3 nargs=2 args=ARRAY[18, 00, 00, 00, 00, 00, 00, 00, 00, e0, d4, 4b, 04, 88, ff, ff, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00] + swapper 0 [002] 136.267492: xen:xen_mc_entry: op 3(stack_switch) args [18, 0, 0, 0, 0, 0] - perf 1970 [008] 136.273319: xen:xen_mc_extend_args: [FAILED TO PARSE] op=1 args=16 res=1 + perf 1970 [008] 136.273319: xen:xen_mc_extend_args: extending op 1(mmu_update) by 16 bytes res ???
NOTE We still do not handle the 'sizeof' and fail to parse following xen tracepoints:
xen:xen_mmu_set_pte xen:xen_mmu_set_pte_atomic xen:xen_mmu_set_domain_pte xen:xen_mmu_set_pte_at xen:xen_mmu_set_pmd
xen:xen_mmu_set_pud
xen:xen_mmu_set_pgd xen:xen_mmu_ptep_modify_prot_start xen:xen_mmu_ptep_modify_prot_commit
--- tools/lib/traceevent/Makefile | 1 + tools/lib/traceevent/plugin_xen.c | 130 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 tools/lib/traceevent/plugin_xen.c
tools/lib/traceevent/Makefile +1 -0
@@ -209,6 +209,7 @@ PLUGIN_OBJS += plugin_kvm.o PLUGIN_OBJS += plugin_mac80211.o PLUGIN_OBJS += plugin_sched_switch.o PLUGIN_OBJS += plugin_function.o +PLUGIN_OBJS += plugin_xen.o PLUGINS := $(PLUGIN_OBJS:.o=.so)
tools/lib/traceevent/plugin_xen.c new file +130 -0
130 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 11/22] tools lib traceevent: Add xen plugin
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 29 lines
Adding xen plugin.
This plugin adds fields resolving for
following tracepoint events:
xen:xen_mc_entry
xen:xen_mc_extend_argsThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'xen:*' ls')script.xen.new renamed from script.xen.old +2
-2- swapper 0 [002] 136.267492: xen:xen_mc_entry: [FAILED TO PARSE] op=3 nargs=2 args=ARRAY[18, 00, 00, 00, 00, 00, 00, 00, 00, e0, d4, 4b, 04, 88, ff, ff, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00] + swapper 0 [002] 136.267492: xen:xen_mc_entry: op 3(stack_switch) args [18, 0, 0, 0, 0, 0] - perf 1970 [008] 136.273319: xen:xen_mc_extend_args: [FAILED TO PARSE] op=1 args=16 res=1 + perf 1970 [008] 136.273319: xen:xen_mc_extend_args: extending op 1(mmu_update) by 16 bytes res ???NOTE We still do not handle the 'sizeof' and fail
to parse following xen tracepoints:
xen:xen_mmu_set_pte
xen:xen_mmu_set_pte_atomic
xen:xen_mmu_set_domain_pte
xen:xen_mmu_set_pte_at
xen:xen_mmu_set_pmd
xen:xen_mmu_set_pud
xen:xen_mmu_set_pgd
xen:xen_mmu_ptep_modify_prot_start
xen:xen_mmu_ptep_modify_prot_commit
[SNIP]
script.xen.new
Quoted 7 lines
script.xen.new renamed from script.xen.old +7
-0+static const char *xen_hypercall_name(unsigned op) +{ + if (op < ARRAY_SIZE(xen_hypercall_names) && + xen_hypercall_names[op] != NULL) + return xen_hypercall_names[op]; + + return "";
How about defaults to "unknown" if not found?
Thanks
Namhyung
Quoted 21 lines
script.xen.new renamed from script.xen.old +21
-0+} + +unsigned long long process_xen_hypercall_name(struct trace_seq *s, + unsigned long long *args) +{ + unsigned int op = args[0]; + + trace_seq_printf(s, "%s", xen_hypercall_name(op)); + return 0; +} + +int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +{ + pevent_register_print_function(pevent, + process_xen_hypercall_name, + PEVENT_FUNC_ARG_STRING, + "xen_hypercall_name", + PEVENT_FUNC_ARG_INT, + PEVENT_FUNC_ARG_VOID); + return 0; +}
Re: [PATCH 11/22] tools lib traceevent: Add xen plugin
Quoted 32 lines · Namhyung Kim
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 29 lines
Adding xen plugin.
This plugin adds fields resolving for
following tracepoint events:
xen:xen_mc_entry
xen:xen_mc_extend_argsThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'xen:*' ls')script.xen.new renamed from script.xen.old +2
-2- swapper 0 [002] 136.267492: xen:xen_mc_entry: [FAILED TO PARSE] op=3 nargs=2 args=ARRAY[18, 00, 00, 00, 00, 00, 00, 00, 00, e0, d4, 4b, 04, 88, ff, ff, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00] + swapper 0 [002] 136.267492: xen:xen_mc_entry: op 3(stack_switch) args [18, 0, 0, 0, 0, 0] - perf 1970 [008] 136.273319: xen:xen_mc_extend_args: [FAILED TO PARSE] op=1 args=16 res=1 + perf 1970 [008] 136.273319: xen:xen_mc_extend_args: extending op 1(mmu_update) by 16 bytes res ???NOTE We still do not handle the 'sizeof' and fail
to parse following xen tracepoints:
xen:xen_mmu_set_pte
xen:xen_mmu_set_pte_atomic
xen:xen_mmu_set_domain_pte
xen:xen_mmu_set_pte_at
xen:xen_mmu_set_pmd
xen:xen_mmu_set_pud
xen:xen_mmu_set_pgd
xen:xen_mmu_ptep_modify_prot_start
xen:xen_mmu_ptep_modify_prot_commit[SNIP]
Quoted 10 lines
script.xen.new
Quoted 7 lines
script.xen.new renamed from script.xen.old +7
-0+static const char *xen_hypercall_name(unsigned op) +{ + if (op < ARRAY_SIZE(xen_hypercall_names) && + xen_hypercall_names[op] != NULL) + return xen_hypercall_names[op]; + + return "";How about defaults to "unknown" if not found?
That's how the kernel 'xen_hypercall_name' handles it.
I dont mind, but I guess we want to change both sides. I've already included Jeremy (kernel side author), so I guess it's up to him ;-)
jirka
PATCH 12/22 tools lib traceevent: Add scsi plugin
In reply to Jiri OlsaAdding scsi plugin.
This plugin adds fields resolving fucntions for following tracepoint events:
scsi:scsi_dispatch_cmd_start scsi:scsi_dispatch_cmd_error scsi:scsi_dispatch_cmd_done scsi:scsi_dispatch_cmd_timeout
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'scsi:scsi_dispatch_cmd*' -a)
- swapper 0 [000] 6620.491019: scsi:scsi_dispatch_cmd_done: [FAILED TO PARSE] host_no=0 channel=0 id=0 lun=0 result=0 opcode=53 cmd_len=10 data_sglen=0 prot_sglen=0 prot_op=0 cmnd=5 + swapper 0 [000] 6620.491019: scsi:scsi_dispatch_cmd_done: host_no=0 channel=0 id=0 lun=0 data_sgl=0 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(SYNCHRONIZE_CACHE - raw=35 00 00 00 00 00 00 00 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD) - kworker/0:0 21554 [000] 6620.491126: scsi:scsi_dispatch_cmd_start: [FAILED TO PARSE] host_no=0 channel=0 id=0 lun=0 opcode=42 cmd_len=10 data_sglen=1 prot_sglen=0 prot_op=0 cmnd=* + kworker/0:0 21554 [000] 6620.491126: scsi:scsi_dispatch_cmd_start: host_no=0 channel=0 id=0 lun=0 data_sgl=1 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=570899168 txlen=8 protect=0 raw=2a 00 22 07 3a e0 00 00 08 00) - jbd2/dm-3-8 593 [002] 6621.607992: scsi:scsi_dispatch_cmd_error: [FAILED TO PARSE] host_no=0 channel=0 id=0 lun=0 rtn=4182 opcode=53 cmd_len=10 data_sglen=0 prot_sglen=0 prot_op=0 cmnd=5 + jbd2/dm-3-8 593 [002] 6621.607992: scsi:scsi_dispatch_cmd_error: host_no=0 channel=0 id=0 lun=0 data_sgl=0 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(SYNCHRONIZE_CACHE - raw=35 00 00 00 00 00 00 00 00 00) rtn=4182
NOTE I couldn't generated scsi_dispatch_cmd_timeout tracepoint,
but it's similar to the rest, so I believe it's ok.
--- tools/lib/traceevent/Makefile | 1 + tools/lib/traceevent/plugin_scsi.c | 423 +++++++++++++++++++++++++++++++++++++ 2 files changed, 424 insertions(+) create mode 100644 tools/lib/traceevent/plugin_scsi.c
tools/lib/traceevent/Makefile +1 -0
@@ -210,6 +210,7 @@ PLUGIN_OBJS += plugin_mac80211.o PLUGIN_OBJS += plugin_sched_switch.o PLUGIN_OBJS += plugin_function.o PLUGIN_OBJS += plugin_xen.o +PLUGIN_OBJS += plugin_scsi.o PLUGINS := $(PLUGIN_OBJS:.o=.so)
tools/lib/traceevent/plugin_scsi.c new file +423 -0
423 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 12/22] tools lib traceevent: Add scsi plugin
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 21 lines
Adding scsi plugin.
This plugin adds fields resolving fucntions for following tracepoint events:
scsi:scsi_dispatch_cmd_start scsi:scsi_dispatch_cmd_error scsi:scsi_dispatch_cmd_done scsi:scsi_dispatch_cmd_timeoutThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'scsi:scsi_dispatch_cmd*' -a)(quoted diff) +3
-3- swapper 0 [000] 6620.491019: scsi:scsi_dispatch_cmd_done: [FAILED TO PARSE] host_no=0 channel=0 id=0 lun=0 result=0 opcode=53 cmd_len=10 data_sglen=0 prot_sglen=0 prot_op=0 cmnd=5 + swapper 0 [000] 6620.491019: scsi:scsi_dispatch_cmd_done: host_no=0 channel=0 id=0 lun=0 data_sgl=0 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(SYNCHRONIZE_CACHE - raw=35 00 00 00 00 00 00 00 00 00) result=(driver=DRIVER_OK host=DID_OK message=COMMAND_COMPLETE status=SAM_STAT_GOOD) - kworker/0:0 21554 [000] 6620.491126: scsi:scsi_dispatch_cmd_start: [FAILED TO PARSE] host_no=0 channel=0 id=0 lun=0 opcode=42 cmd_len=10 data_sglen=1 prot_sglen=0 prot_op=0 cmnd=* + kworker/0:0 21554 [000] 6620.491126: scsi:scsi_dispatch_cmd_start: host_no=0 channel=0 id=0 lun=0 data_sgl=1 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(WRITE_10 lba=570899168 txlen=8 protect=0 raw=2a 00 22 07 3a e0 00 00 08 00) - jbd2/dm-3-8 593 [002] 6621.607992: scsi:scsi_dispatch_cmd_error: [FAILED TO PARSE] host_no=0 channel=0 id=0 lun=0 rtn=4182 opcode=53 cmd_len=10 data_sglen=0 prot_sglen=0 prot_op=0 cmnd=5 + jbd2/dm-3-8 593 [002] 6621.607992: scsi:scsi_dispatch_cmd_error: host_no=0 channel=0 id=0 lun=0 data_sgl=0 prot_sgl=0 prot_op=SCSI_PROT_NORMAL cmnd=(SYNCHRONIZE_CACHE - raw=35 00 00 00 00 00 00 00 00 00) rtn=4182NOTE I couldn't generated
scsi_dispatch_cmd_timeouttracepoint,
but it's similar to the rest, so I believe it's ok.
[SNIP]
Quoted 4 lines
tools/lib/traceevent/plugin_scsi.c new file +4
-0+static const char * +scsi_trace_rw6 (struct trace_seq *p,unsigned char *cdb,int len) +{ +const char *ret = p->buffer + p->len;
tools/lib/traceevent/plugin_scsi.c line 164
Quoted 10 lines
tools/lib/traceevent/plugin_scsi.c new file +10
-0+sector_t lba =0 , txlen =0 ; + + lba |= ((cdb[1 ] &0x1F ) <<16 ); + lba |= (cdb[2 ] <<8 ); + lba |= cdb[3 ]; + txlen = cdb[4 ]; + +trace_seq_printf (p,"lba=%llu txlen=%llu" , + (unsigned long long )lba, (unsigned long long )txlen); +trace_seq_putc (p,0 );
Why is this _putc(0) needed? It seems you added it to all other functions too.
Quoted 3 lines
tools/lib/traceevent/plugin_scsi.c new file +3
-0+return ret; +} +
Re: [PATCH 12/22] tools lib traceevent: Add scsi plugin
Quoted 10 lines · On Sat, 23 Nov 2013 00:24:50 +0900 Namhyung Kim <[email protected]> wrote:
[SNIP]
Quoted 9 lines
tools/lib/traceevent/plugin_scsi.c new file +9
-0+static const char * +scsi_trace_rw6 (struct trace_seq *p,unsigned char *cdb,int len) +{ +const char *ret = p->buffer + p->len; +sector_t lba =0 , txlen =0 ; + + lba |= ((cdb[1 ] &0x1F ) <<16 ); + lba |= (cdb[2 ] <<8 ); + lba |= cdb[3 ];
Quoted 8 lines
tools/lib/traceevent/plugin_scsi.c line 164
Quoted 5 lines
tools/lib/traceevent/plugin_scsi.c new file +5
-0+ txlen = cdb[4 ]; + +trace_seq_printf (p,"lba=%llu txlen=%llu" , + (unsigned long long )lba, (unsigned long long )txlen); +trace_seq_putc (p,0 );Why is this
_putc(0)needed? It seems you added it to all other functions too.
This is because these are copied directly from the kernel, and the kernel versions use the putc(0) too. But there, it is needed, as its up to the helper function to terminate the trace_seq.
I need to add trace_seq_terminate() in the kernel (it's in libtraceevent), so that we can replace the putc(0) with terminate, and not truncate the seq early.
-- Steve
Quoted 7 lines
Quoted 5 lines
tools/lib/traceevent/plugin_scsi.c new file +3
-0+return ret; +} +
PATCH 13/22 tools lib traceevent: Add cfg80211 plugin
In reply to Jiri OlsaAdding cfg80211 plugin.
This plugin adds handler for __le16_to_cpup function t properly parse following tracepoint events:
cfg80211:cfg80211_tx_mlme_mgmt cfg80211:cfg80211_rx_mlme_mgmt cfg80211:cfg80211_rx_unprot_mlme_mgmt
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'cfg80211:*' -a')
--- script.cfg80211.old
+++ script.cfg80211.new
- ifconfig 2705 [003] 662.896560: cfg80211:cfg80211_tx_mlme_mgmt: [FAILED TO PARSE] name=wlan0 ifindex=3 frame=ARRAY[c0, 00, 00, 00, 00, 3a, 98, a0, 30, 51, 10, 0b, a9, c6, f4, 74, 00, 3a, 98, a0, 30, 51, 00, 00, 03, 00] + ifconfig 2705 [003] 662.896560: cfg80211:cfg80211_tx_mlme_mgmt: netdev:wlan0(3), ftype:0xc0 - kworker/u16:0 1697 [002] 664.808210: cfg80211:cfg80211_rx_mlme_mgmt: [FAILED TO PARSE] name=wlan0 ifindex=3 frame=ARRAY[b0, 00, da, 00, 10, 0b, a9, c6, f4, 74, d8, 24, bd, a1, 26, 31, d8, 24, bd, a1, 26, 31, 10, b7, 00, 00, 02, 00, 00, 00] + kworker/u16:0 1697 [002] 664.808210: cfg80211:cfg80211_rx_mlme_mgmt: netdev:wlan0(3), ftype:0xb0
--- tools/lib/traceevent/Makefile | 1 + tools/lib/traceevent/plugin_cfg80211.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tools/lib/traceevent/plugin_cfg80211.c
tools/lib/traceevent/Makefile +1 -0
@@ -211,6 +211,7 @@ PLUGIN_OBJS += plugin_sched_switch.o PLUGIN_OBJS += plugin_function.o PLUGIN_OBJS += plugin_xen.o PLUGIN_OBJS += plugin_scsi.o +PLUGIN_OBJS += plugin_cfg80211.o PLUGINS := $(PLUGIN_OBJS:.o=.so)
tools/lib/traceevent/plugin_cfg80211.c new file +23 -0
@@ -0,0 +1,23 @@ +#include <stdio.h> +#include <string.h> +#include <inttypes.h> +#include <endian.h> +#include "event-parse.h" + +unsigned long long process___le16_to_cpup (struct trace_seq *s, +unsigned long long *args) +{ +uint16_t *val = (uint16_t *) args[0 ]; +return val ? (long long )le16toh (*val) :0 ; +} + +int PEVENT_PLUGIN_LOADER (struct pevent *pevent) +{ +pevent_register_print_function (pevent, + process___le16_to_cpup, +PEVENT_FUNC_ARG_INT , +"__le16_to_cpup" , +PEVENT_FUNC_ARG_PTR , +PEVENT_FUNC_ARG_VOID ); +return 0 ; +}
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 13/22] tools lib traceevent: Add cfg80211 plugin
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 17 lines
Adding cfg80211 plugin.
This plugin adds handler for
__le16_to_cpupfunction t properly parse following tracepoint events:
cfg80211:cfg80211_tx_mlme_mgmt cfg80211:cfg80211_rx_mlme_mgmt cfg80211:cfg80211_rx_unprot_mlme_mgmtThe diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'cfg80211:*' -a')script.cfg80211.new renamed from script.cfg80211.old +2
-2- ifconfig 2705 [003] 662.896560: cfg80211:cfg80211_tx_mlme_mgmt: [FAILED TO PARSE] name=wlan0 ifindex=3 frame=ARRAY[c0, 00, 00, 00, 00, 3a, 98, a0, 30, 51, 10, 0b, a9, c6, f4, 74, 00, 3a, 98, a0, 30, 51, 00, 00, 03, 00] + ifconfig 2705 [003] 662.896560: cfg80211:cfg80211_tx_mlme_mgmt: netdev:wlan0(3), ftype:0xc0 - kworker/u16:0 1697 [002] 664.808210: cfg80211:cfg80211_rx_mlme_mgmt: [FAILED TO PARSE] name=wlan0 ifindex=3 frame=ARRAY[b0, 00, da, 00, 10, 0b, a9, c6, f4, 74, d8, 24, bd, a1, 26, 31, d8, 24, bd, a1, 26, 31, 10, b7, 00, 00, 02, 00, 00, 00] + kworker/u16:0 1697 [002] 664.808210: cfg80211:cfg80211_rx_mlme_mgmt: netdev:wlan0(3), ftype:0xb0
[SNIP]
script.cfg80211.new
Quoted 12 lines
script.cfg80211.new renamed from script.cfg80211.old +12
-0+unsigned long long process___le16_to_cpup(struct trace_seq *s, + unsigned long long *args) +{ + uint16_t *val = (uint16_t *) args[0]; + return val ? (long long) le16toh(*val) : 0; +} + +int PEVENT_PLUGIN_LOADER(struct pevent *pevent) +{ + pevent_register_print_function(pevent, + process___le16_to_cpup, + PEVENT_FUNC_ARG_INT,
Just a nitpick. The function should return int or the return type should be _LONG for consistency.
Thanks,
Namhyung
Quoted 5 lines
script.cfg80211.new renamed from script.cfg80211.old +5
-0+ "__le16_to_cpup", + PEVENT_FUNC_ARG_PTR, + PEVENT_FUNC_ARG_VOID); + return 0; +}
Re: [PATCH 13/22] tools lib traceevent: Add cfg80211 plugin
Quoted 16 lines · On Sat, 23 Nov 2013 00:16:14 +0900 Namhyung Kim <[email protected]> wrote:
[SNIP]
tools/lib/traceevent/plugin_cfg80211.c line 18
Quoted 12 lines
tools/lib/traceevent/plugin_cfg80211.c new file +12
-0+unsigned long long process___le16_to_cpup (struct trace_seq *s, +unsigned long long *args) +{ +uint16_t *val = (uint16_t *) args[0 ]; +return val ? (long long )le16toh (*val) :0 ; +} + +int PEVENT_PLUGIN_LOADER (struct pevent *pevent) +{ + pevent_register_print_function(pevent, + process___le16_to_cpup, + PEVENT_FUNC_ARG_INT,Just a nitpick. The function should return int or the return type should be
_LONGfor consistency.
As stated in another reply, the return type is not for the callback, but instead for the function it is representing.
-- Steve
Quoted 11 lines
Thanks,
NamhyungQuoted 5 lines
tools/lib/traceevent/plugin_cfg80211.c new file +5
-0+"__le16_to_cpup" , +PEVENT_FUNC_ARG_PTR , + PEVENT_FUNC_ARG_VOID); +return 0 ; +}
PATCH 14/22 tools lib traceevent: Update kvm plugin with is_writable_pte helper
In reply to Jiri OlsaAdding is_writable_pte print helper function, so the kvmmmu:fast_page_fault print format gets resolved properly.
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kvm:*,kvmmmu:*' -a')
--- script.kvm.old
+++ script.kvm.new
- qemu-system-x86 3290 [002] 10708.755312: kvmmmu:fast_page_fault: [FAILED TO PARSE] vcpu_id=0 gva=4094486080 error_code=3 sptep=0xffff88019f1e3670 old_spte=336391285 new_spte=336391287 retry=1
+ qemu-system-x86 3290 [002] 10708.755312: kvmmmu:fast_page_fault: vcpu 0 gva f40ce640 error_code P|W sptep 0xffff88019f1e3670 old 0x140cec75 new 140cec77 spurious 0 fixed 1
--- tools/lib/traceevent/plugin_kvm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
tools/lib/traceevent/plugin_kvm.c +17 -0
@@ -389,6 +389,16 @@ static int kvm_mmu_get_page_handler(struct trace_seq *s,return kvm_mmu_print_role (s, record, event, context); } +#define PT_WRITABLE_SHIFT 1 +#define PT_WRITABLE_MASK (1ULL << PT_WRITABLE_SHIFT) + +unsigned long long process_is_writable_pte (struct trace_seq *s, +unsigned long long *args) +{ +unsigned long pte = args[0 ]; +return pte &PT_WRITABLE_MASK ; +} +int PEVENT_PLUGIN_LOADER (struct pevent *pevent) {init_disassembler ();
@@ -415,5 +425,12 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)pevent_register_event_handler (pevent,-1 ,"kvmmmu" ,"kvm_mmu_prepare_zap_page" , kvm_mmu_print_role,NULL ); + +pevent_register_print_function (pevent, + process_is_writable_pte, +PEVENT_FUNC_ARG_INT , +"is_writable_pte" , +PEVENT_FUNC_ARG_LONG , +PEVENT_FUNC_ARG_VOID );return 0 ; }
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 14/22] tools lib traceevent: Update kvm plugin with is_writable_pte helper
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 10 lines
Adding
is_writable_pteprint helper function, so the kvmmmu:fast_page_fault print format gets resolved properly.The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kvm:*,kvmmmu:*' -a')script.kvm.new renamed from script.kvm.old +1
-1- qemu-system-x86 3290 [002] 10708.755312: kvmmmu:fast_page_fault: [FAILED TO PARSE] vcpu_id=0 gva=4094486080 error_code=3 sptep=0xffff88019f1e3670 old_spte=336391285 new_spte=336391287 retry=1 + qemu-system-x86 3290 [002] 10708.755312: kvmmmu:fast_page_fault: vcpu 0 gva f40ce640 error_code P|W sptep 0xffff88019f1e3670 old 0x140cec75 new 140cec77 spurious 0 fixed 1
[SNIP]
Quoted 11 lines
script.kvm.new renamed from script.kvm.old +7
-0+unsigned long long process_is_writable_pte(struct trace_seq *s, + unsigned long long *args) +{ + unsigned long pte = args[0]; + return pte & PT_WRITABLE_MASK; +} + int PEVENT_PLUGIN_LOADER(struct pevent *pevent) { init_disassembler();
script.kvm.new int PEVENT_PLUGIN_LOADER(struct pevent *pevent) · line 431
Quoted 7 lines
script.kvm.new renamed from script.kvm.old +4
-0@@ -415,5 +425,12 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_prepare_zap_page", kvm_mmu_print_role, NULL); + + pevent_register_print_function(pevent, + process_is_writable_pte, + PEVENT_FUNC_ARG_INT,
Same as the previous reply - return type of the function is inconsistent.
And please also consider making the function static.
Thanks,
Namhyung
Quoted 5 lines
script.kvm.new renamed from script.kvm.old +3
-0+ "is_writable_pte", + PEVENT_FUNC_ARG_LONG, + PEVENT_FUNC_ARG_VOID); return 0; }
Re: [PATCH 14/22] tools lib traceevent: Update kvm plugin with is_writable_pte helper
Quoted 26 lines · On Sat, 23 Nov 2013 00:19:48 +0900 Namhyung Kim <[email protected]> wrote:
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 10 lines
Adding
is_writable_pteprint helper function, so the kvmmmu:fast_page_fault print format gets resolved properly.The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e 'kvm:*,kvmmmu:*' -a')script.kvm.new renamed from script.kvm.old +1
-1- qemu-system-x86 3290 [002] 10708.755312: kvmmmu:fast_page_fault: [FAILED TO PARSE] vcpu_id=0 gva=4094486080 error_code=3 sptep=0xffff88019f1e3670 old_spte=336391285 new_spte=336391287 retry=1 + qemu-system-x86 3290 [002] 10708.755312: kvmmmu:fast_page_fault: vcpu 0 gva f40ce640 error_code P|W sptep 0xffff88019f1e3670 old 0x140cec75 new 140cec77 spurious 0 fixed 1[SNIP]
Quoted 13 lines
script.kvm.new renamed from script.kvm.old +7
-0+unsigned long long process_is_writable_pte(struct trace_seq *s, + unsigned long long *args) +{ + unsigned long pte = args[0]; + return pte & PT_WRITABLE_MASK; +} + int PEVENT_PLUGIN_LOADER(struct pevent *pevent) { init_disassembler();@@ -415,5 +425,12 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent) pevent_register_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_prepare_zap_page", kvm_mmu_print_role,
Quoted 8 lines
script.kvm.new int PEVENT_PLUGIN_LOADER(struct pevent *pevent) · line 431
Quoted 5 lines
script.kvm.new renamed from script.kvm.old +4
-0NULL); + + pevent_register_print_function(pevent, + process_is_writable_pte, + PEVENT_FUNC_ARG_INT,Same as the previous reply - return type of the function is inconsistent.
Actually it's not.
Quoted 2 lines
And please also consider making the function static.
Agreed.
-- Steve
Quoted 12 lines
Thanks,
NamhyungQuoted 5 lines
script.kvm.new renamed from script.kvm.old +3
-0+ "is_writable_pte", + PEVENT_FUNC_ARG_LONG, + PEVENT_FUNC_ARG_VOID); return 0; }
PATCH 15/22 tools lib traceevent: Change pevent_parse_event to return event format
In reply to Jiri OlsaChanging pevent_parse_event to return 'struct event_format', for the parsed event if the return pointer is specified.
This way we can remove pevent_parse_format which does the same stuff just without 'struct pevent' object.
The ultimate goal is to always use pevent object when dealing with traceevent library. The reason is that we might need additional processing (like plugins), which is not possible otherwise.
Patches follow to make this happen completely.
--- tools/lib/traceevent/event-parse.c | 32 +++++++++++--------------------- tools/lib/traceevent/event-parse.h | 7 ++++--- tools/perf/util/evsel.c | 2 +- tools/perf/util/trace-event-parse.c | 4 ++-- 4 files changed, 18 insertions(+), 27 deletions(-)
tools/lib/traceevent/event-parse.c +11 -21
@@ -5130,27 +5130,9 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp, }/** -* pevent_parse_format - parse the event format -* @buf: the buffer storing the event format string -* @size: the size of @buf -* @sys: the system the event belongs to -* -* This parses the event format and creates an event structure -* to quickly parse raw data for a given event. -* -* These files currently come from: -* -* /sys/kernel/debug/tracing/events/.../.../format -*/ -enum pevent_errno pevent_parse_format (struct event_format **eventp,const char *buf, -unsigned long size,const char *sys) -{ -return __pevent_parse_format (eventp,NULL , buf, size, sys); -} - -/** * pevent_parse_event - parse the event format * @pevent: the handle to the pevent +* @format: event format object for passed format * @buf: the buffer storing the event format string * @size: the size of @buf * @sys: the system the event belongs to
@@ -5158,11 +5140,16 @@ enum pevent_errno pevent_parse_format(struct event_format **eventp, const char ** This parses the event format and creates an event structure * to quickly parse raw data for a given event. * +* Returns event format object in @format parameter if +* specified. +* * These files currently come from: * * /sys/kernel/debug/tracing/events/.../.../format */ -enum pevent_errno pevent_parse_event (struct pevent *pevent,const char *buf, +enum pevent_errno pevent_parse_event (struct pevent *pevent, +struct event_format **format, +const char *buf,unsigned long size,const char *sys) {struct event_format *event =NULL ;
@@ -5171,7 +5158,7 @@ enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,if (event ==NULL )return ret; -if (add_event (pevent, event)) { +if (pevent &&add_event (pevent, event)) { ret =PEVENT_ERRNO__MEM_ALLOC_FAILED ; goto event_add_failed; }
@@ -5180,6 +5167,9 @@ enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,if (PRINT_ARGS && event->print_fmt.args)print_args (event->print_fmt.args); +if (format) + *format = event; +return 0 ; event_add_failed:
tools/lib/traceevent/event-parse.h +4 -3
@@ -559,10 +559,11 @@ void pevent_print_event(struct pevent *pevent, struct trace_seq *s,int pevent_parse_header_page (struct pevent *pevent,char *buf,unsigned long size,int long_size); -enum pevent_errno pevent_parse_event (struct pevent *pevent,const char *buf, +enum pevent_errno pevent_parse_event (struct pevent *pevent, +struct event_format **format, +const char *buf,unsigned long size,const char *sys); -enum pevent_errno pevent_parse_format (struct event_format **eventp,const char *buf, -unsigned long size,const char *sys); +void pevent_free_format (struct event_format *event); void *pevent_get_field_raw(struct trace_seq *s, struct event_format *event,
tools/perf/util/evsel.c +1 -1
@@ -208,7 +208,7 @@ struct event_format *event_format__new(const char *sys, const char *name) size += n; }while (n >0 ); -pevent_parse_format (&format, bf, size, sys); +pevent_parse_event (NULL , &format, bf, size, sys); out_free_bf:free (bf);
tools/perf/util/trace-event-parse.c +2 -2
@@ -198,13 +198,13 @@ void parse_ftrace_printk(struct pevent *pevent,int parse_ftrace_file (struct pevent *pevent,char *buf,unsigned long size) { -return pevent_parse_event (pevent, buf, size,"ftrace" ); +return pevent_parse_event (pevent,NULL , buf, size,"ftrace" ); }int parse_event_file (struct pevent *pevent,char *buf,unsigned long size,char *sys) { -return pevent_parse_event (pevent, buf, size, sys); +return pevent_parse_event (pevent,NULL , buf, size, sys); } struct event_format *trace_find_next_event(struct pevent *pevent,
Signature · 1 line
1.8.3.1
Re: [PATCH 15/22] tools lib traceevent: Change pevent_parse_event to return event format
Quoted 2 lines · On Thu, 21 Nov 2013 12:01:13 +0100 Jiri Olsa <[email protected]> wrote:
Changing
pevent_parse_eventto return 'structevent_format', for the parsed event if the return pointer is specified.
Can we not change the API of pevent_parse_event(), I use it quite a bit.
And yes, I'm working hard to keep what's in trace-cmd and the kernel identical.
Quoted 3 lines
This way we can remove
pevent_parse_formatwhich does the same stuff just without 'struct pevent' object.
Actually, I don't use pevent_parse_format() at all. What about changing that one to include the pevent?
Quoted 5 lines
The ultimate goal is to always use pevent object when dealing with traceevent library. The reason is that we might need additional processing (like plugins), which is not possible otherwise.
Right, so add a pevent to the pevent_parse_format() and leave the pevent_parse_event() alone. That should make everyone happy :-)
Thanks!
-- Steve
Re: [PATCH 15/22] tools lib traceevent: Change pevent_parse_event to return event format
Quoted 20 lines · Steven Rostedt
Quoted 2 lines · On Thu, 21 Nov 2013 12:01:13 +0100 Jiri Olsa <[email protected]> wrote:
Changing
pevent_parse_eventto return 'structevent_format', for the parsed event if the return pointer is specified.Can we not change the API of
pevent_parse_event(), I use it quite a bit.And yes, I'm working hard to keep what's in trace-cmd and the kernel identical.
Quoted 3 lines
This way we can remove
pevent_parse_formatwhich does the same stuff just without 'struct pevent' object.Actually, I don't use
pevent_parse_format()at all. What about changing that one to include the pevent?Quoted 1 line
Quoted 7 lines
Quoted 4 lines
The ultimate goal is to always use pevent object when dealing with traceevent library. The reason is that we might need additional processing (like plugins), which is not possible otherwise.
Right, so add a pevent to the
pevent_parse_format()and leave thepevent_parse_event()alone. That should make everyone happy :-)
ook, np ;-)
thanks,
jirka
PATCH 16/22 tools lib traceevent: Harmonize the install messages in lib-traceevent
In reply to Jiri OlsaRemoving the 'to ...' part out of the install message, because it does not fit to the rest of the build messages we use.
Before:
INSTALL plugin_hrtimer.so to /home/jolsa/libexec/perf-core/traceevent/plugins INSTALL plugin_jbd2.so to /home/jolsa/libexec/perf-core/traceevent/plugins INSTALL plugin_kmem.so to /home/jolsa/libexec/perf-core/traceevent/plugins INSTALL plugin_kvm.so to /home/jolsa/libexec/perf-core/traceevent/plugins INSTALL plugin_mac80211.so to /home/jolsa/libexec/perf-core/traceevent/plugins INSTALL plugin_sched_switch.so to /home/jolsa/libexec/perf-core/traceevent/plugins INSTALL plugin_function.so to /home/jolsa/libexec/perf-core/traceevent/plugins INSTALL plugin_xen.so to /home/jolsa/libexec/perf-core/traceevent/plugins INSTALL plugin_scsi.so to /home/jolsa/libexec/perf-core/traceevent/plugins
Now:
INSTALL plugin_jbd2.so INSTALL plugin_hrtimer.so INSTALL plugin_kmem.so INSTALL plugin_kvm.so INSTALL plugin_mac80211.so INSTALL plugin_sched_switch.so INSTALL plugin_function.so INSTALL plugin_xen.so INSTALL plugin_scsi.so
--- tools/lib/traceevent/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/Makefile +1 -1
@@ -156,7 +156,7 @@ else print_plugin_obj_compile = echo ' CC FPIC '$(OBJ); print_plugin_build = echo ' BUILD PLUGIN '$(OBJ); print_static_lib_build = echo ' BUILD STATIC LIB '$(OBJ); - print_install = echo ' INSTALL '$1' to $(DESTDIR_SQ)$2'; + print_install = echo ' INSTALL '$1; endif do_fpic_compile = \
Signature · 1 line
1.8.3.1
PATCH 17/22 perf tools: Add build and install plugins targets
In reply to Jiri OlsaAdding 'plugins' target along with the libtraceevent.a, so plugins are built together with traceevent library.
Adding 'install-traceevent-plugins' Makefile install target, instructing perf to install plugins into:
$(HOME)/libexec/perf-core/traceevent/plugins
- if installed localy under $HOME
$(DESTDIR)/$(prefix)/$(perfexecdir)/traceevent/plugins
- if installed globally
--- tools/perf/Makefile.perf | 15 ++++++++++----- tools/perf/config/Makefile | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-)
tools/perf/Makefile.perf +10 -5
@@ -105,7 +105,7 @@ ifeq ($(config),1) include config/Makefile endif -export prefix bindir sharedir sysconfdir +export prefix bindir sharedir sysconfdir DESTDIR # sparse is architecture-neutral, which means that we need to tell it # explicitly what architecture to check for. Fix this up for yours..
@@ -710,13 +710,18 @@ $(LIB_FILE): $(LIB_OBJS) # libtraceevent.a TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch]) -$(LIBTRACEEVENT): $(TE_SOURCES) - $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS)" libtraceevent.a +LIBTRACEEVENT_FLAGS=$(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS)" plugin_dir=$(plugindir_SQ) + +$(LIBTRACEEVENT): $(TE_SOURCES) $(OUTPUT)PERF-CFLAGS + $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) libtraceevent.a plugins $(LIBTRACEEVENT)-clean: $(call QUIET_CLEAN, libtraceevent) @$(MAKE) -C $(TRACE_EVENT_DIR) O=$(OUTPUT) clean >/dev/null +install-traceevent-plugins: + $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) install_plugins + LIBLK_SOURCES = $(wildcard $(LK_PATH)*.[ch]) # if subdir is set, we've been called from above so target has been built
@@ -785,7 +790,7 @@ cscope: ### Detect prefix changes TRACK_CFLAGS = $(subst ','\'',$(CFLAGS)):\ - $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ) + $(bindir_SQ):$(perfexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):$(plugindir_SQ) $(OUTPUT)PERF-CFLAGS: .FORCE-PERF-CFLAGS @FLAGS='$(TRACK_CFLAGS)'; \
@@ -849,7 +854,7 @@ endif $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \ $(INSTALL) tests/attr/* '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr' -install: install-bin try-install-man +install: install-bin try-install-man install-traceevent-plugins install-python_ext: $(PYTHON_WORD) util/setup.py --quiet install --root='/$(DESTDIR_SQ)'
tools/perf/config/Makefile +2 -0
@@ -578,6 +578,7 @@ else lib = lib endif libdir = $(prefix)/$(lib) +plugindir=$(perfexecdir)/traceevent/plugins # Shell quote (do not use $(call) to accommodate ancient setups); ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
@@ -598,3 +599,4 @@ else perfexec_instdir = $(prefix)/$(perfexecdir) endif perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) +plugindir_SQ= $(subst ','\'',$(prefix)/$(plugindir))
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 17/22] perf tools: Add build and install plugins targets
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 9 lines
Adding 'plugins' target along with the libtraceevent.a, so plugins are built together with traceevent library.
Adding 'install-traceevent-plugins'
Makefileinstall target, instructing perf to install plugins into:
$(HOME)/libexec/perf-core/traceevent/plugins
- if installed localy under $HOME
$(DESTDIR)/$(prefix)/$(perfexecdir)/traceevent/plugins
- if installed globally
[SNIP]
tools/perf/config/Makefile else · line 581
Quoted 7 lines
tools/perf/config/Makefile +1
-0@@ -578,6 +578,7 @@ else lib = lib endif libdir = $(prefix)/$(lib) +plugindir=$(perfexecdir)/traceevent/plugins
Hmm.. it puts traceevent plugins under the perf directory. But I don't think it's a good idea since libtraceevent can be used independently.
What about something like this?
plugindir = $(perfexecdir)/../traceevent/plugins
Thanks,
Namhyung
Re: [PATCH 17/22] perf tools: Add build and install plugins targets
Quoted 23 lines · Namhyung Kim
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 9 lines
Adding 'plugins' target along with the libtraceevent.a, so plugins are built together with traceevent library.
Adding 'install-traceevent-plugins'
Makefileinstall target, instructing perf to install plugins into:
$(HOME)/libexec/perf-core/traceevent/plugins
- if installed localy under $HOME
$(DESTDIR)/$(prefix)/$(perfexecdir)/traceevent/plugins
- if installed globally[SNIP]
tools/perf/config/Makefile else · line 581
Quoted 7 lines
tools/perf/config/Makefile +1
-0@@ -578,6 +578,7 @@ else lib = lib endif libdir = $(prefix)/$(lib) +plugindir=$(perfexecdir)/traceevent/pluginsHmm.. it puts traceevent plugins under the perf directory. But I don't think it's a good idea since libtraceevent can be used independently.
Quoted 3 lines
What about something like this?
plugindir = $(perfexecdir)/../traceevent/plugins
this is where trace-cmd stores them:
$(HOME)/.trace-cmd/plugins $(prefix)/$(libdir)/trace-cmd/plugins
but I guess we want global place to install plugins, the traceevent by default uses:
$(HOME)/.traceevent/plugins $(prefix)/lib/traceevent/plugins
How about that?
thanks,
jirka
Namhyung Kim
maintainerRe: [PATCH 17/22] perf tools: Add build and install plugins targets
Hi Jiri,
Quoted 33 lines · Jiri Olsa
Quoted 23 lines · Namhyung Kim
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 9 lines
Adding 'plugins' target along with the libtraceevent.a, so plugins are built together with traceevent library.
Adding 'install-traceevent-plugins'
Makefileinstall target, instructing perf to install plugins into:
$(HOME)/libexec/perf-core/traceevent/plugins
- if installed localy under $HOME
$(DESTDIR)/$(prefix)/$(perfexecdir)/traceevent/plugins
- if installed globally[SNIP]
tools/perf/config/Makefile else · line 581
Quoted 7 lines
tools/perf/config/Makefile +1
-0@@ -578,6 +578,7 @@ else lib = lib endif libdir = $(prefix)/$(lib) +plugindir=$(perfexecdir)/traceevent/pluginsHmm.. it puts traceevent plugins under the perf directory. But I don't think it's a good idea since libtraceevent can be used independently.
Quoted 3 lines
What about something like this?
plugindir = $(perfexecdir)/../traceevent/pluginsthis is where trace-cmd stores them:
$(HOME)/.trace-cmd/plugins $(prefix)/$(libdir)/trace-cmd/plugins
Quoted 7 lines
but I guess we want global place to install plugins, the traceevent by default uses:
$(HOME)/.traceevent/plugins $(prefix)/lib/traceevent/pluginsHow about that?
Looks good to me.
Thanks,
Namhyung
PATCH 18/22 perf tools: Add udis86 disassembler feature check
In reply to Jiri OlsaAdding udis86 disassembler feature check which support is needed for kvm:kvm_emulate_insn tracepoint.
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e kvm:kvm_emulate_insn -a')
--- script.kvm.old
+++ script.kvm.new
- qemu-system-x86 15519 [003] 5332.470049: kvm:kvm_emulate_insn: 0:ffffffff8103c596:89 b7 00 80 5f ff (prot64)
+ qemu-system-x86 15519 [003] 5332.470049: kvm:kvm_emulate_insn: 0:ffffffff8103c596: mov %esi, -0xa08000(%rdi)
--- tools/perf/Makefile.perf | 2 +- tools/perf/config/Makefile | 8 ++++++++ tools/perf/config/feature-checks/Makefile | 6 +++++- tools/perf/config/feature-checks/test-all.c | 5 +++++ tools/perf/config/feature-checks/test-udis86.c | 11 +++++++++++ 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tools/perf/config/feature-checks/test-udis86.c
tools/perf/Makefile.perf +1 -1
@@ -710,7 +710,7 @@ $(LIB_FILE): $(LIB_OBJS) # libtraceevent.a TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch]) -LIBTRACEEVENT_FLAGS=$(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS)" plugin_dir=$(plugindir_SQ) +LIBTRACEEVENT_FLAGS=$(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS) $(LIBTRACEEVENT_CFLAGS)" plugin_dir=$(plugindir_SQ) $(LIBTRACEEVENT): $(TE_SOURCES) $(OUTPUT)PERF-CFLAGS $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) libtraceevent.a plugins
tools/perf/config/Makefile +8 -0
@@ -418,6 +418,14 @@ else msg := $(warning No timerfd support. Disables 'perf kvm stat live'); endif +$(call feature_check,udis86) +ifeq ($(feature-udis86), 1) + LIBTRACEEVENT_CFLAGS += -DHAVE_UDIS86 + EXTLIBS += -ludis86 +else + msg := $(warning No udis86 support.); +endif + disable-python = $(eval $(disable-python_code)) define disable-python_code CFLAGS += -DNO_LIBPYTHON
tools/perf/config/feature-checks/Makefile +5 -1
@@ -27,7 +27,8 @@ FILES= \ test-on-exit \ test-stackprotector-all \ test-stackprotector \ - test-timerfd + test-timerfd \ + test-udis86 CC := $(CC) -MD
@@ -144,6 +145,9 @@ test-backtrace: test-timerfd: $(BUILD) +test-udis86: + $(BUILD) -DHAVE_UDIS86 -ludis86 + -include *.d ###############################
tools/perf/config/feature-checks/test-all.c +5 -0
@@ -85,6 +85,10 @@# include "test-timerfd.c" #undef main +#define main main_test_udis86 +# include "test-udis86.c" +#undef main +int main (int argc,char *argv[]) {main_test_libpython ();
@@ -106,6 +110,7 @@ int main(int argc, char *argv[])main_test_backtrace ();main_test_libnuma ();main_test_timerfd (); +main_test_udis86 ();return 0 ; }
tools/perf/config/feature-checks/test-udis86.c new file +11 -0
@@ -0,0 +1,11 @@ + +/* +* test for udis86 functions used by plugin_kvm.c +*/ + +#include <udis86.h> + +int main (void ) +{ +return puts ("hi" ); +}
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 18/22] perf tools: Add udis86 disassembler feature check
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 10 lines
Adding udis86 disassembler feature check which support is needed for kvm:kvm_emulate_insn tracepoint.
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e kvm:kvm_emulate_insn -a')script.kvm.new renamed from script.kvm.old +1
-1- qemu-system-x86 15519 [003] 5332.470049: kvm:kvm_emulate_insn: 0:ffffffff8103c596:89 b7 00 80 5f ff (prot64) + qemu-system-x86 15519 [003] 5332.470049: kvm:kvm_emulate_insn: 0:ffffffff8103c596: mov %esi, -0xa08000(%rdi)
[SNIP]
tools/perf/Makefile.perf $(LIB_FILE): $(LIB_OBJS) · line 713
Quoted 8 lines
tools/perf/Makefile.perf +1
-1@@ -710,7 +710,7 @@ $(LIB_FILE): $(LIB_OBJS) # libtraceevent.a TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch]) -LIBTRACEEVENT_FLAGS=$(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS)" plugin_dir=$(plugindir_SQ) +LIBTRACEEVENT_FLAGS=$(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS) $(LIBTRACEEVENT_CFLAGS)" plugin_dir=$(plugindir_SQ)
What about breaking the line with "+="?
Quoted 8 lines
tools/perf/Makefile.perf +0
-0$(LIBTRACEEVENT): $(TE_SOURCES) $(OUTPUT)PERF-CFLAGS $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) libtraceevent.a pluginstools/perf/config/Makefile +0
-0
tools/perf/config/Makefile else · line 427
Quoted 10 lines
tools/perf/config/Makefile +7
-0@@ -418,6 +418,14 @@ else msg := $(warning No timerfd support. Disables 'perf kvm stat live'); endif +$(call feature_check,udis86) +ifeq ($(feature-udis86), 1) + LIBTRACEEVENT_CFLAGS += -DHAVE_UDIS86 + EXTLIBS += -ludis86 +else + msg := $(warning No udis86 support.); +endif
I think we can just use libbfd for this eventually. But it can be a later work. :)
Thanks,
Namhyung
Re: [PATCH 18/22] perf tools: Add udis86 disassembler feature check
Quoted 19 lines · Namhyung Kim
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 10 lines
Adding udis86 disassembler feature check which support is needed for kvm:kvm_emulate_insn tracepoint.
The diff of 'perf script' output generated by old and new code:
(data was generated by 'perf record -e kvm:kvm_emulate_insn -a')script.kvm.new renamed from script.kvm.old +1
-1- qemu-system-x86 15519 [003] 5332.470049: kvm:kvm_emulate_insn: 0:ffffffff8103c596:89 b7 00 80 5f ff (prot64) + qemu-system-x86 15519 [003] 5332.470049: kvm:kvm_emulate_insn: 0:ffffffff8103c596: mov %esi, -0xa08000(%rdi)[SNIP]
Quoted 6 lines
tools/perf/Makefile.perf +0
-0@@ -710,7 +710,7 @@ $(LIB_FILE): $(LIB_OBJS) # libtraceevent.a TE_SOURCES = $(wildcard $(TRACE_EVENT_DIR)*.[ch])
Quoted 4 lines
tools/perf/Makefile.perf $(LIB_FILE): $(LIB_OBJS) · line 713
Quoted 2 lines
tools/perf/Makefile.perf +1
-1-LIBTRACEEVENT_FLAGS=$(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS)" plugin_dir=$(plugindir_SQ) +LIBTRACEEVENT_FLAGS=$(QUIET_SUBDIR1) O=$(OUTPUT) CFLAGS="-g -Wall $(EXTRA_CFLAGS) $(LIBTRACEEVENT_CFLAGS)" plugin_dir=$(plugindir_SQ)What about breaking the line with "+="?
ok
thanks,
jirka
PATCH 19/22 perf tools: Add filename__read_str util function
In reply to Jiri OlsaAdding filename__read_str util function to read text file and return it in the char array.
The interface is:
int filename__read_str(const char *filename, char **buf, size_t *sizep)
Returns 0/-1 if the read suceeded/fail respectively.
buf - place to store the data pointer size - place to store data size
--- tools/perf/util/util.c | 41 +++++++++++++++++++++++++++++++++++++++++ tools/perf/util/util.h | 1 + 2 files changed, 42 insertions(+)
tools/perf/util/util.c +41 -0
@@ -413,3 +413,44 @@ int filename__read_int(const char *filename, int *value)close (fd);return err; } + +int filename__read_str (const char *filename,char **buf,size_t *sizep) +{ +size_t size =0 , alloc_size =0 ; +void *bf =NULL , *nbf; +int fd, n, err =0 ; + + fd =open (filename,O_RDONLY ); +if (fd <0 ) +return -errno; + +do { +if (size == alloc_size) { + alloc_size +=BUFSIZ ; + nbf =realloc (bf, alloc_size); +if (!nbf) { + err = -ENOMEM ; +break ; + } + + bf = nbf; + } + + n =read (fd, bf + size,BUFSIZ ); +if (n <0 ) { + err =0 ; +break ; + } + + size += n; + }while (n >0 ); + +if (!err) { + *sizep = size; + *buf = bf; + }else +free (bf); + +close (fd); +return err; +}
tools/perf/util/util.h +1 -0
@@ -307,4 +307,5 @@ char *get_srcline(struct dso *dso, unsigned long addr);void free_srcline (char *srcline);int filename__read_int (const char *filename,int *value); +int filename__read_str (const char *filename,char **buf,size_t *sizep);#endif /* GIT_COMPAT_UTIL_H */
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 19/22] perf tools: Add filename__read_str util function
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 10 lines
Adding
filename__read_strutil function to read
text file and return it in the char array.The interface is:
intfilename__read_str(const char *filename, char **buf, size_t *sizep)Returns 0/-1 if the read suceeded/fail respectively.
buf - place to store the data pointer
size - place to store data size
[SNIP]
Quoted 13 lines
tools/perf/util/util.c +13
-0+int filename__read_str (const char *filename,char **buf,size_t *sizep) +{ +size_t size =0 , alloc_size =0 ; +void *bf =NULL , *nbf; +int fd, n, err =0 ; + + fd =open (filename,O_RDONLY ); +if (fd <0 ) +return -errno; + + do { + if (size == alloc_size) { + alloc_size += BUFSIZ;
tools/perf/util/util.c int filename__read_int(const char *filename, int *value) · line 439
Quoted 10 lines
tools/perf/util/util.c +10
-0+ nbf =realloc (bf, alloc_size); +if (!nbf) { + err = -ENOMEM ; +break ; + } + + bf = nbf; + } + + n =read (fd, bf + size,BUFSIZ );
Shouldn't it be "read(fd, bf + size, alloc_size - size)"? Otherwise there might be a problem if read() returned early for some reason with small size and then retry with a full BUFSIZ..
tools/perf/util/util.c int filename__read_int(const char *filename, int *value) · line 441
Quoted 2 lines
tools/perf/util/util.c +2
-0+if (n <0 ) { + err =0 ;
I think it needs to check the size also since read() might fail at the first invocation. What about this?
if (n < 0) {
if (size)
err = 0;
else
err = -errno;Thanks,
Namhyung
Quoted 15 lines
tools/perf/util/util.c +15
-0+break ; + } + + size += n; + }while (n >0 ); + +if (!err) { + *sizep = size; + *buf = bf; + }else +free (bf); + +close (fd); +return err; +}
Re: [PATCH 19/22] perf tools: Add filename__read_str util function
Quoted 48 lines · Namhyung Kim
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 10 lines
Adding
filename__read_strutil function to read
text file and return it in the char array.The interface is:
intfilename__read_str(const char *filename, char **buf, size_t *sizep)Returns 0/-1 if the read suceeded/fail respectively.
buf - place to store the data pointer
size - place to store data size[SNIP]
Quoted 13 lines
tools/perf/util/util.c +13
-0+int filename__read_str (const char *filename,char **buf,size_t *sizep) +{ +size_t size =0 , alloc_size =0 ; +void *bf =NULL , *nbf; +int fd, n, err =0 ; + + fd =open (filename,O_RDONLY ); +if (fd <0 ) +return -errno; + + do { + if (size == alloc_size) { + alloc_size += BUFSIZ;tools/perf/util/util.c int filename__read_int(const char *filename, int *value) · line 439
Quoted 10 lines
tools/perf/util/util.c +10
-0+ nbf =realloc (bf, alloc_size); +if (!nbf) { + err = -ENOMEM ; +break ; + } + + bf = nbf; + } + + n =read (fd, bf + size,BUFSIZ );Shouldn't it be "
read(fd, bf + size, alloc_size - size)"? Otherwise there might be a problem ifread()returned early for some reason with small size and then retry with a full BUFSIZ..tools/perf/util/util.c int filename__read_int(const char *filename, int *value) · line 441
Quoted 2 lines
tools/perf/util/util.c +2
-0+if (n <0 ) { + err =0 ;I think it needs to check the size also since
read()might fail at the first invocation. What about this?
Quoted 6 lines
if (n < 0) {
if (size)
err = 0;
else
err = -errno;ok, added.. plus warning in the 'if (size)' leg,
because we're returning data even if we failed.
thanks,
jirka
PATCH 20/22 perf tools: Add trace-event object
In reply to Jiri OlsaAdd trace-event object to keep together 'struct pevent' object with its loaded plugins with following interface:
int trace_event__init(struct trace_event *t);
- initalizes 'struct pevent' object and loads plugins for it
void trace_event__cleanup(struct trace_event *t);
- cleanups both 'struct pevent' and plugins
--- tools/perf/Makefile.perf | 1 + tools/perf/builtin-script.c | 2 +- tools/perf/util/header.c | 8 ++++---- tools/perf/util/python-ext-sources | 1 + tools/perf/util/session.h | 3 ++- tools/perf/util/trace-event-parse.c | 13 ------------- tools/perf/util/trace-event-read.c | 20 +++++++++++--------- tools/perf/util/trace-event.c | 21 +++++++++++++++++++++ tools/perf/util/trace-event.h | 13 ++++++++++--- 9 files changed, 51 insertions(+), 31 deletions(-) create mode 100644 tools/perf/util/trace-event.c
tools/perf/Makefile.perf +1 -0
@@ -353,6 +353,7 @@ LIB_OBJS += $(OUTPUT)util/pmu-bison.o LIB_OBJS += $(OUTPUT)util/trace-event-read.o LIB_OBJS += $(OUTPUT)util/trace-event-info.o LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o +LIB_OBJS += $(OUTPUT)util/trace-event.o LIB_OBJS += $(OUTPUT)util/svghelper.o LIB_OBJS += $(OUTPUT)util/sort.o LIB_OBJS += $(OUTPUT)util/hist.o
tools/perf/builtin-script.c +1 -1
@@ -1587,7 +1587,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)return -1 ; } - err = scripting_ops->generate_script (session->pevent, + err = scripting_ops->generate_script (session->tevent.pevent,"perf-script" ); goto out; }
tools/perf/util/header.c +4 -4
@@ -2834,11 +2834,11 @@ int perf_session__read_header(struct perf_session *session) symbol_conf.nr_events = nr_attrs; -perf_header__process_sections (header, fd, &session->pevent, +perf_header__process_sections (header, fd, &session->tevent, perf_file_section__process);if (perf_evlist__prepare_tracepoint_events (session->evlist, - session->pevent)) + session->tevent.pevent)) goto out_delete_evlist;return 0 ;
@@ -3003,7 +3003,7 @@ int perf_event__process_tracing_data(struct perf_tool *tool __maybe_unused,lseek (fd, offset +sizeof (struct tracing_data_event ),SEEK_SET ); - size_read =trace_report (fd, &session->pevent, + size_read =trace_report (fd, &session->tevent, session->repipe); padding =PERF_ALIGN (size_read,sizeof (u64)) - size_read;
@@ -3025,7 +3025,7 @@ int perf_event__process_tracing_data(struct perf_tool *tool __maybe_unused, }perf_evlist__prepare_tracepoint_events (session->evlist, - session->pevent); + session->tevent.pevent);return size_read + padding; }
tools/perf/util/python-ext-sources +1 -0
@@ -18,4 +18,5 @@ util/cgroup.c util/rblist.c util/strlist.c util/fs.c +util/trace-event.c ../../lib/rbtree.c
tools/perf/util/session.h +2 -1
@@ -1,6 +1,7 @@#ifndef __PERF_SESSION_H#define __PERF_SESSION_H +#include "trace-event.h" #include "hist.h" #include "event.h" #include "header.h"
@@ -32,7 +33,7 @@ struct perf_session {struct perf_header header;struct machines machines;struct perf_evlist *evlist; -struct pevent *pevent; +struct trace_event tevent;struct events_stats stats;bool repipe;struct ordered_samples ordered_samples;
tools/perf/util/trace-event-parse.c +0 -13
@@ -28,19 +28,6 @@#include "util.h" #include "trace-event.h" -struct pevent *read_trace_init (int file_bigendian,int host_bigendian) -{ -struct pevent *pevent =pevent_alloc (); - -if (pevent !=NULL ) { -pevent_set_flag (pevent,PEVENT_NSEC_OUTPUT ); -pevent_set_file_bigendian (pevent, file_bigendian); -pevent_set_host_bigendian (pevent, host_bigendian); - } - -return pevent; -} -static int get_common_field (struct scripting_context *context,int *offset,int *size,const char *type) {
tools/perf/util/trace-event-read.c +11 -9
@@ -343,7 +343,7 @@ static int read_event_files(struct pevent *pevent)return 0 ; } -ssize_t trace_report (int fd,struct pevent **ppevent,bool __repipe) +ssize_t trace_report (int fd,struct trace_event *tevent,bool __repipe) {char buf[BUFSIZ ];char test[] = {23 ,8 ,68 };
@@ -356,11 +356,9 @@ ssize_t trace_report(int fd, struct pevent **ppevent, bool __repipe)int host_bigendian;int file_long_size;int file_page_size; -struct pevent *pevent; +struct pevent *pevent =NULL ;int err; - *ppevent =NULL ; - repipe = __repipe; input_fd = fd;
@@ -390,12 +388,17 @@ ssize_t trace_report(int fd, struct pevent **ppevent, bool __repipe) file_bigendian = buf[0 ]; host_bigendian =bigendian (); - pevent =read_trace_init (file_bigendian, host_bigendian); -if (pevent ==NULL ) { -pr_debug ("read_trace_init failed" ); +if (trace_event__init (tevent)) { +pr_debug ("trace_event__init failed" ); goto out; } + pevent = tevent->pevent; + +pevent_set_flag (pevent,PEVENT_NSEC_OUTPUT ); +pevent_set_file_bigendian (pevent, file_bigendian); +pevent_set_host_bigendian (pevent, host_bigendian); +if (do_read (buf,1 ) <0 ) goto out; file_long_size = buf[0 ];
@@ -432,11 +435,10 @@ ssize_t trace_report(int fd, struct pevent **ppevent, bool __repipe)pevent_print_printk (pevent); } - *ppevent = pevent; pevent =NULL ; out:if (pevent) -pevent_free (pevent); +trace_event__cleanup (tevent);return size; }
tools/perf/util/trace-event.c new file +21 -0
@@ -0,0 +1,21 @@ + +#include <traceevent/event-parse.h> +#include "trace-event.h" + +int trace_event__init (struct trace_event *t) +{ +struct pevent *pevent =pevent_alloc (); + +if (pevent) { + t->plugin_list =traceevent_load_plugins (pevent); + t->pevent = pevent; + } + +return pevent ?0 :-1 ; +} + +void trace_event__cleanup (struct trace_event *t) +{ +pevent_free (t->pevent); +traceevent_unload_plugins (t->plugin_list); +}
tools/perf/util/trace-event.h +10 -3
@@ -3,17 +3,24 @@#include <traceevent/event-parse.h> #include "parse-events.h" -#include "session.h" struct machine ;struct perf_sample ;union perf_event ;struct perf_tool ;struct thread ; +struct plugin_list ; + +struct trace_event { +struct pevent *pevent; +struct plugin_list *plugin_list; +}; + +int trace_event__init (struct trace_event *t); +void trace_event__cleanup (struct trace_event *t);int bigendian (void ); -struct pevent *read_trace_init (int file_bigendian,int host_bigendian);void event_format__print (struct event_format *event,int cpu,void *data,int size);
@@ -27,7 +34,7 @@ raw_field_value(struct event_format *event, const char *name, void *data);void parse_proc_kallsyms (struct pevent *pevent,char *file,unsigned int size);void parse_ftrace_printk (struct pevent *pevent,char *file,unsigned int size); -ssize_t trace_report (int fd,struct pevent **pevent,bool repipe); +ssize_t trace_report (int fd,struct trace_event *tevent,bool repipe);struct event_format *trace_find_next_event (struct pevent *pevent,struct event_format *event);
Signature · 1 line
1.8.3.1
PATCH 21/22 perf tools: Add trace-event global object for tracepoint interface
In reply to Jiri OlsaIn order to get the proper plugins processing we need to use full trace-event interface when creating tracepoint events. So far we were using shortcut to get the parsed format.
Moving current 'event_format__new' function into trace-event object as 'trace_event__tp_format'.
This function uses properly initialized global trace-event object, ensuring proper plugins processing.
--- tools/perf/builtin-trace.c | 5 ++-- tools/perf/util/evsel.c | 44 ++----------------------------- tools/perf/util/trace-event.c | 61 +++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/trace-event.h | 2 ++ 4 files changed, 68 insertions(+), 44 deletions(-)
tools/perf/builtin-trace.c +3 -2
@@ -11,6 +11,7 @@#include "util/intlist.h" #include "util/thread_map.h" #include "util/stat.h" +#include "trace-event.h" #include <libaudit.h> #include <stdlib.h>
@@ -1430,11 +1431,11 @@ static int trace__read_syscall_info(struct trace *trace, int id) sc->fmt =syscall_fmt__find (sc->name);snprintf (tp_name,sizeof (tp_name),"sys_enter_%s" , sc->name); - sc->tp_format =event_format__new ("syscalls" , tp_name); + sc->tp_format =trace_event__tp_format ("syscalls" , tp_name);if (sc->tp_format ==NULL && sc->fmt && sc->fmt->alias) {snprintf (tp_name,sizeof (tp_name),"sys_enter_%s" , sc->fmt->alias); - sc->tp_format =event_format__new ("syscalls" , tp_name); + sc->tp_format =trace_event__tp_format ("syscalls" , tp_name); }if (sc->tp_format ==NULL )
tools/perf/util/evsel.c +2 -42
62 lines not on this page · raw message
tools/perf/util/trace-event.c +61 -0
70 lines not on this page · raw message
tools/perf/util/trace-event.h +2 -0
@@ -18,6 +18,8 @@ struct trace_event {int trace_event__init (struct trace_event *t);void trace_event__cleanup (struct trace_event *t); +struct event_format * +trace_event__tp_format (const char *sys,const char *name);int bigendian (void );
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 21/22] perf tools: Add trace-event global object for tracepoint interface
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 10 lines
In order to get the proper plugins processing we need to use full trace-event interface when creating tracepoint events. So far we were using shortcut to get the parsed format.
Moving current '
event_format__new' function into trace-event object as 'trace_event__tp_format'.This function uses properly initialized global trace-event object, ensuring proper plugins processing.
I see this when I compile it on my old ubuntu 10.04 box (with gcc 4.4.3)
CC util/trace-event.o
cc1: warnings being treated as errors util/trace-event.c: In function 'trace_event__tp_format':util/trace-event.c:63: error: not protecting function: no buffer at least 8 bytes long
make[1]: *** [util/trace-event.o] Error 1
Thanks,
Namhyung
Re: [PATCH 21/22] perf tools: Add trace-event global object for tracepoint interface
Quoted 12 lines · Namhyung Kim
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 10 lines
In order to get the proper plugins processing we need to use full trace-event interface when creating tracepoint events. So far we were using shortcut to get the parsed format.
Moving current '
event_format__new' function into trace-event object as 'trace_event__tp_format'.This function uses properly initialized global trace-event object, ensuring proper plugins processing.
Quoted 8 lines
I see this when I compile it on my old ubuntu 10.04 box (with gcc 4.4.3)
CC
util/trace-event.o
cc1: warnings being treated as errorsutil/trace-event.c: In function 'trace_event__tp_format':util/trace-event.c:63: error: not protecting function: no buffer at least 8 bytes long
make[1]: *** [util/trace-event.o] Error 1
hum, what was the stackprotector status?
... stackprotector: [ on ]
... stackprotector-all: [ on ]
thanks,
jirka
Namhyung Kim
maintainerRe: [PATCH 21/22] perf tools: Add trace-event global object for tracepoint interface
Hi Jiri,
2013-11-25 (월), 17:03 +0100, Jiri Olsa:
Quoted 22 lines · Namhyung Kim
Quoted 12 lines
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 10 lines
In order to get the proper plugins processing we need to use full trace-event interface when creating tracepoint events. So far we were using shortcut to get the parsed format.
Moving current '
event_format__new' function into trace-event object as 'trace_event__tp_format'.This function uses properly initialized global trace-event object, ensuring proper plugins processing.
Quoted 8 lines
I see this when I compile it on my old ubuntu 10.04 box (with gcc 4.4.3)
CC
util/trace-event.o
cc1: warnings being treated as errorsutil/trace-event.c: In function 'trace_event__tp_format':util/trace-event.c:63: error: not protecting function: no buffer at least 8 bytes long
make[1]: *** [util/trace-event.o] Error 1
Quoted 4 lines
hum, what was the stackprotector status?
... stackprotector: [ on ]
... stackprotector-all: [ on ]
Right. Both of them were turned on.
Auto-detecting system features:
... backtrace: [ on ] ... dwarf: [ on ] ... fortify-source: [ on ] ... glibc: [ on ] ... gtk2: [ on ] ... gtk2-infobar: [ on ] ... libaudit: [ on ] ... libbfd: [ on ] ... libelf: [ on ] ... libelf-getphdrnum: [ OFF ] ... libelf-mmap: [ on ] ... libnuma: [ OFF ] ... libperl: [ on ] ... libpython: [ on ] ... libpython-version: [ on ] ... libslang: [ on ] ... libunwind: [ OFF ] ... on-exit: [ on ] ... stackprotector: [ on ] ... stackprotector-all: [ on ] ... timerfd: [ on ]
Thanks,
Namhyung
Re: [PATCH 21/22] perf tools: Add trace-event global object for tracepoint interface
Quoted 46 lines · Namhyung Kim
Hi Jiri,
2013-11-25 (월), 17:03 +0100, Jiri Olsa:
Quoted 22 lines · Namhyung Kim
Quoted 12 lines
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 10 lines
In order to get the proper plugins processing we need to use full trace-event interface when creating tracepoint events. So far we were using shortcut to get the parsed format.
Moving current '
event_format__new' function into trace-event object as 'trace_event__tp_format'.This function uses properly initialized global trace-event object, ensuring proper plugins processing.
Quoted 8 lines
I see this when I compile it on my old ubuntu 10.04 box (with gcc 4.4.3)
CC
util/trace-event.o
cc1: warnings being treated as errorsutil/trace-event.c: In function 'trace_event__tp_format':util/trace-event.c:63: error: not protecting function: no buffer at least 8 bytes long
make[1]: *** [util/trace-event.o] Error 1Quoted 4 lines
hum, what was the stackprotector status?
... stackprotector: [ on ]
... stackprotector-all: [ on ]Right. Both of them were turned on.
Auto-detecting system features:
... backtrace: [ on ] ... dwarf: [ on ] ... fortify-source: [ on ] ... glibc: [ on ] ... gtk2: [ on ] ... gtk2-infobar: [ on ] ... libaudit: [ on ] ... libbfd: [ on ] ... libelf: [ on ] ... libelf-getphdrnum: [ OFF ] ... libelf-mmap: [ on ] ... libnuma: [ OFF ] ... libperl: [ on ]
Quoted 8 lines
... libpython: [ on ] ... libpython-version: [ on ] ... libslang: [ on ] ... libunwind: [ OFF ] ... on-exit: [ on ] ... stackprotector: [ on ] ... stackprotector-all: [ on ] ... timerfd: [ on ]
I found that -fstack-protector might not always work:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
they say it was fixed in gcc 4.5.0 which I was not able to prove in gcc release notes..
we could disable the warning like in the below
for gcc < 4.5.0, could you please test?
any other idea? ;-)
thanks,
jirka
---
tools/perf/config/feature-checks/test-stackprotector.c +8 -0
@@ -1,5 +1,13 @@#include <stdio.h> +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +#if GCC_VERSION <40500 +#error "failed" +#endif +int main (void ) {return puts ("hi" );
Re: [PATCH 21/22] perf tools: Add trace-event global object for tracepoint interface
Quoted 59 lines · Jiri Olsa
Quoted 46 lines · Namhyung Kim
Hi Jiri,
2013-11-25 (월), 17:03 +0100, Jiri Olsa:
Quoted 22 lines · Namhyung Kim
Quoted 12 lines
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 10 lines
In order to get the proper plugins processing we need to use full trace-event interface when creating tracepoint events. So far we were using shortcut to get the parsed format.
Moving current '
event_format__new' function into trace-event object as 'trace_event__tp_format'.This function uses properly initialized global trace-event object, ensuring proper plugins processing.
Quoted 8 lines
I see this when I compile it on my old ubuntu 10.04 box (with gcc 4.4.3)
CC
util/trace-event.o
cc1: warnings being treated as errorsutil/trace-event.c: In function 'trace_event__tp_format':util/trace-event.c:63: error: not protecting function: no buffer at least 8 bytes long
make[1]: *** [util/trace-event.o] Error 1Quoted 4 lines
hum, what was the stackprotector status?
... stackprotector: [ on ]
... stackprotector-all: [ on ]Right. Both of them were turned on.
Auto-detecting system features:
... backtrace: [ on ] ... dwarf: [ on ] ... fortify-source: [ on ] ... glibc: [ on ] ... gtk2: [ on ] ... gtk2-infobar: [ on ] ... libaudit: [ on ] ... libbfd: [ on ] ... libelf: [ on ] ... libelf-getphdrnum: [ OFF ] ... libelf-mmap: [ on ] ... libnuma: [ OFF ] ... libperl: [ on ]Quoted 8 lines
... libpython: [ on ] ... libpython-version: [ on ] ... libslang: [ on ] ... libunwind: [ OFF ] ... on-exit: [ on ] ... stackprotector: [ on ] ... stackprotector-all: [ on ] ... timerfd: [ on ]I found that -fstack-protector might not always work:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
Quoted 7 lines
they say it was fixed in gcc 4.5.0 which I was not able to prove in gcc release notes..
we could disable the warning like in the below
for gcc < 4.5.0, could you please test?any other idea? ;-)
or remove -Wstack-protector option completely, as it's just informative seems there's nothing you could do about the warning anyway
jirka
Namhyung Kim
maintainerRe: [PATCH 21/22] perf tools: Add trace-event global object for tracepoint interface
2013-11-27 (수), 16:27 +0100, Jiri Olsa:
Quoted 57 lines · Jiri Olsa
Quoted 56 lines · Namhyung Kim
Quoted 54 lines
Hi Jiri,
2013-11-25 (월), 17:03 +0100, Jiri Olsa:
Quoted 22 lines · Namhyung Kim
Quoted 12 lines
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 10 lines
In order to get the proper plugins processing we need to use full trace-event interface when creating tracepoint events. So far we were using shortcut to get the parsed format.
Moving current '
event_format__new' function into trace-event object as 'trace_event__tp_format'.This function uses properly initialized global trace-event object, ensuring proper plugins processing.
Quoted 8 lines
I see this when I compile it on my old ubuntu 10.04 box (with gcc 4.4.3)
CC
util/trace-event.o
cc1: warnings being treated as errorsutil/trace-event.c: In function 'trace_event__tp_format':util/trace-event.c:63: error: not protecting function: no buffer at least 8 bytes long
make[1]: *** [util/trace-event.o] Error 1Quoted 4 lines
hum, what was the stackprotector status?
... stackprotector: [ on ]
... stackprotector-all: [ on ]Right. Both of them were turned on.
Auto-detecting system features:
... backtrace: [ on ] ... dwarf: [ on ] ... fortify-source: [ on ] ... glibc: [ on ] ... gtk2: [ on ] ... gtk2-infobar: [ on ] ... libaudit: [ on ] ... libbfd: [ on ] ... libelf: [ on ] ... libelf-getphdrnum: [ OFF ] ... libelf-mmap: [ on ] ... libnuma: [ OFF ] ... libperl: [ on ] ... libpython: [ on ] ... libpython-version: [ on ] ... libslang: [ on ] ... libunwind: [ OFF ] ... on-exit: [ on ] ... stackprotector: [ on ] ... stackprotector-all: [ on ] ... timerfd: [ on ]
Quoted 8 lines
Quoted 8 lines
I found that -fstack-protector might not always work:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722they say it was fixed in gcc 4.5.0 which I was not able to prove in gcc release notes..
we could disable the warning like in the below
for gcc < 4.5.0, could you please test?
Works well for me, thanks.
Quoted 5 lines
Quoted 2 lines
any other idea? ;-)
or remove -Wstack-protector option completely, as it's just informative seems there's nothing you could do about the warning anyway
Agreed. It seems just adding -fstack-protector is enough.
Thanks,
Namhyung
PATCH 22/22 perf tools: Overload pr_stat traceevent print function
In reply to Jiri OlsaThe traceevent lib uses pr_stat to display all standard info. It's defined as __weak. Overloading it with perf version plugged into perf output system logic.
Displaying the pr_stat stuff under '-v' option.
--- tools/perf/util/debug.c | 16 ++++++++++++++++ tools/perf/util/debug.h | 2 ++ 2 files changed, 18 insertions(+)
tools/perf/util/debug.c +16 -0
@@ -33,6 +33,22 @@ int eprintf(int level, const char *fmt, ...)return ret; } +/* +* Overloading libtraceevent standard info print +* function, display with -v in perf. +*/ +void pr_stat (const char *fmt, ...) +{ +va_list args; + +if (verbose >=1 ) { +va_start (args, fmt); +vfprintf (stderr, fmt, args); +fprintf (stderr,"\n" ); +va_end (args); + } +} +int dump_printf (const char *fmt, ...) {va_list args;
tools/perf/util/debug.h +2 -0
@@ -17,4 +17,6 @@ void trace_event(union perf_event *event);int ui__error (const char *format, ...) __attribute__((format (printf,1 ,2 )));int ui__warning (const char *format, ...) __attribute__((format (printf,1 ,2 ))); +void pr_stat (const char *fmt, ...); +#endif /* __PERF_DEBUG_H */
Signature · 1 line
1.8.3.1
Namhyung Kim
maintainerRe: [PATCH 22/22] perf tools: Overload pr_stat traceevent print function
2013-11-21 (목), 12:01 +0100, Jiri Olsa:
Quoted 5 lines
The traceevent lib uses
pr_statto display all standard info. It's defined as__weak. Overloading it with perf version plugged into perf output system logic.Displaying the
pr_statstuff under '-v' option.
[SNIP]
Quoted 6 lines
tools/perf/util/debug.c +5
-0+/* +* Overloading libtraceevent standard info print +* function, display with -v in perf. +*/ +void pr_stat (const char *fmt, ...)
tools/perf/util/debug.c int eprintf(int level, const char *fmt, ...) · line 50
Quoted 10 lines
tools/perf/util/debug.c +10
-0+{ +va_list args; + +if (verbose >=1 ) { +va_start (args, fmt); +vfprintf (stderr, fmt, args); +fprintf (stderr,"\n" ); +va_end (args); + } +}
It'd be better if it use or does same as eprintf() like other pr_* functions does.
Thanks,
Namhyung