Skip to content

Commit 45e6af0

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf improvements and fixes from Arnaldo Carvalho de Melo: Infrastructure changes: * Improve callchain processing by removing unnecessary work. (Frederic Weisbecker) * Fix comm override error handling (Frederic Weisbecker) * Improve 'perf probe' exit path, release resources (Masami Hiramatsu) * Improve libtraceevent plugins exit path, allowing the registering of an unregister handler to be called at exit time (Namhyung Kim) * Add an alias to the build test makefile (make -C tools/perf build-test) (Namhyung Kim) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
2 parents 3e7e09d + 2a29190 commit 45e6af0

23 files changed

+389
-112
lines changed

tools/lib/traceevent/event-parse.c

Lines changed: 122 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5560,6 +5560,52 @@ int pevent_register_print_function(struct pevent *pevent,
55605560
return ret;
55615561
}
55625562

5563+
/**
5564+
* pevent_unregister_print_function - unregister a helper function
5565+
* @pevent: the handle to the pevent
5566+
* @func: the function to process the helper function
5567+
* @name: the name of the helper function
5568+
*
5569+
* This function removes existing print handler for function @name.
5570+
*
5571+
* Returns 0 if the handler was removed successully, -1 otherwise.
5572+
*/
5573+
int pevent_unregister_print_function(struct pevent *pevent,
5574+
pevent_func_handler func, char *name)
5575+
{
5576+
struct pevent_function_handler *func_handle;
5577+
5578+
func_handle = find_func_handler(pevent, name);
5579+
if (func_handle && func_handle->func == func) {
5580+
remove_func_handler(pevent, name);
5581+
return 0;
5582+
}
5583+
return -1;
5584+
}
5585+
5586+
static struct event_format *pevent_search_event(struct pevent *pevent, int id,
5587+
const char *sys_name,
5588+
const char *event_name)
5589+
{
5590+
struct event_format *event;
5591+
5592+
if (id >= 0) {
5593+
/* search by id */
5594+
event = pevent_find_event(pevent, id);
5595+
if (!event)
5596+
return NULL;
5597+
if (event_name && (strcmp(event_name, event->name) != 0))
5598+
return NULL;
5599+
if (sys_name && (strcmp(sys_name, event->system) != 0))
5600+
return NULL;
5601+
} else {
5602+
event = pevent_find_event_by_name(pevent, sys_name, event_name);
5603+
if (!event)
5604+
return NULL;
5605+
}
5606+
return event;
5607+
}
5608+
55635609
/**
55645610
* pevent_register_event_handler - register a way to parse an event
55655611
* @pevent: the handle to the pevent
@@ -5584,20 +5630,9 @@ int pevent_register_event_handler(struct pevent *pevent, int id,
55845630
struct event_format *event;
55855631
struct event_handler *handle;
55865632

5587-
if (id >= 0) {
5588-
/* search by id */
5589-
event = pevent_find_event(pevent, id);
5590-
if (!event)
5591-
goto not_found;
5592-
if (event_name && (strcmp(event_name, event->name) != 0))
5593-
goto not_found;
5594-
if (sys_name && (strcmp(sys_name, event->system) != 0))
5595-
goto not_found;
5596-
} else {
5597-
event = pevent_find_event_by_name(pevent, sys_name, event_name);
5598-
if (!event)
5599-
goto not_found;
5600-
}
5633+
event = pevent_search_event(pevent, id, sys_name, event_name);
5634+
if (event == NULL)
5635+
goto not_found;
56015636

56025637
pr_stat("overriding event (%d) %s:%s with new print handler",
56035638
event->id, event->system, event->name);
@@ -5637,6 +5672,79 @@ int pevent_register_event_handler(struct pevent *pevent, int id,
56375672
return -1;
56385673
}
56395674

5675+
static int handle_matches(struct event_handler *handler, int id,
5676+
const char *sys_name, const char *event_name,
5677+
pevent_event_handler_func func, void *context)
5678+
{
5679+
if (id >= 0 && id != handler->id)
5680+
return 0;
5681+
5682+
if (event_name && (strcmp(event_name, handler->event_name) != 0))
5683+
return 0;
5684+
5685+
if (sys_name && (strcmp(sys_name, handler->sys_name) != 0))
5686+
return 0;
5687+
5688+
if (func != handler->func || context != handler->context)
5689+
return 0;
5690+
5691+
return 1;
5692+
}
5693+
5694+
/**
5695+
* pevent_unregister_event_handler - unregister an existing event handler
5696+
* @pevent: the handle to the pevent
5697+
* @id: the id of the event to unregister
5698+
* @sys_name: the system name the handler belongs to
5699+
* @event_name: the name of the event handler
5700+
* @func: the function to call to parse the event information
5701+
* @context: the data to be passed to @func
5702+
*
5703+
* This function removes existing event handler (parser).
5704+
*
5705+
* If @id is >= 0, then it is used to find the event.
5706+
* else @sys_name and @event_name are used.
5707+
*
5708+
* Returns 0 if handler was removed successfully, -1 if event was not found.
5709+
*/
5710+
int pevent_unregister_event_handler(struct pevent *pevent, int id,
5711+
const char *sys_name, const char *event_name,
5712+
pevent_event_handler_func func, void *context)
5713+
{
5714+
struct event_format *event;
5715+
struct event_handler *handle;
5716+
struct event_handler **next;
5717+
5718+
event = pevent_search_event(pevent, id, sys_name, event_name);
5719+
if (event == NULL)
5720+
goto not_found;
5721+
5722+
if (event->handler == func && event->context == context) {
5723+
pr_stat("removing override handler for event (%d) %s:%s. Going back to default handler.",
5724+
event->id, event->system, event->name);
5725+
5726+
event->handler = NULL;
5727+
event->context = NULL;
5728+
return 0;
5729+
}
5730+
5731+
not_found:
5732+
for (next = &pevent->handlers; *next; next = &(*next)->next) {
5733+
handle = *next;
5734+
if (handle_matches(handle, id, sys_name, event_name,
5735+
func, context))
5736+
break;
5737+
}
5738+
5739+
if (!(*next))
5740+
return -1;
5741+
5742+
*next = handle->next;
5743+
free_handler(handle);
5744+
5745+
return 0;
5746+
}
5747+
56405748
/**
56415749
* pevent_alloc - create a pevent handle
56425750
*/

tools/lib/traceevent/event-parse.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,10 +624,15 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt,
624624
int pevent_register_event_handler(struct pevent *pevent, int id,
625625
const char *sys_name, const char *event_name,
626626
pevent_event_handler_func func, void *context);
627+
int pevent_unregister_event_handler(struct pevent *pevent, int id,
628+
const char *sys_name, const char *event_name,
629+
pevent_event_handler_func func, void *context);
627630
int pevent_register_print_function(struct pevent *pevent,
628631
pevent_func_handler func,
629632
enum pevent_func_arg_type ret_type,
630633
char *name, ...);
634+
int pevent_unregister_print_function(struct pevent *pevent,
635+
pevent_func_handler func, char *name);
631636

632637
struct format_field *pevent_find_common_field(struct event_format *event, const char *name);
633638
struct format_field *pevent_find_field(struct event_format *event, const char *name);

tools/lib/traceevent/plugin_cfg80211.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
2222
PEVENT_FUNC_ARG_VOID);
2323
return 0;
2424
}
25+
26+
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
27+
{
28+
pevent_unregister_print_function(pevent, process___le16_to_cpup,
29+
"__le16_to_cpup");
30+
}

tools/lib/traceevent/plugin_function.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
148148
{
149149
int i, x;
150150

151+
pevent_unregister_event_handler(pevent, -1, "ftrace", "function",
152+
function_handler, NULL);
153+
151154
for (i = 0; i <= cpus; i++) {
152155
for (x = 0; x < fstack[i].size && fstack[i].stack[x]; x++)
153156
free(fstack[i].stack[x]);

tools/lib/traceevent/plugin_hrtimer.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,13 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
7676
timer_start_handler, NULL);
7777
return 0;
7878
}
79+
80+
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
81+
{
82+
pevent_unregister_event_handler(pevent, -1,
83+
"timer", "hrtimer_expire_entry",
84+
timer_expire_handler, NULL);
85+
86+
pevent_unregister_event_handler(pevent, -1, "timer", "hrtimer_start",
87+
timer_start_handler, NULL);
88+
}

tools/lib/traceevent/plugin_jbd2.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,12 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
6666
PEVENT_FUNC_ARG_VOID);
6767
return 0;
6868
}
69+
70+
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
71+
{
72+
pevent_unregister_print_function(pevent, process_jbd2_dev_to_name,
73+
"jbd2_dev_to_name");
74+
75+
pevent_unregister_print_function(pevent, process_jiffies_to_msecs,
76+
"jiffies_to_msecs");
77+
}

tools/lib/traceevent/plugin_kmem.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,25 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
7070
call_site_handler, NULL);
7171
return 0;
7272
}
73+
74+
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
75+
{
76+
pevent_unregister_event_handler(pevent, -1, "kmem", "kfree",
77+
call_site_handler, NULL);
78+
79+
pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc",
80+
call_site_handler, NULL);
81+
82+
pevent_unregister_event_handler(pevent, -1, "kmem", "kmalloc_node",
83+
call_site_handler, NULL);
84+
85+
pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_alloc",
86+
call_site_handler, NULL);
87+
88+
pevent_unregister_event_handler(pevent, -1, "kmem",
89+
"kmem_cache_alloc_node",
90+
call_site_handler, NULL);
91+
92+
pevent_unregister_event_handler(pevent, -1, "kmem", "kmem_cache_free",
93+
call_site_handler, NULL);
94+
}

tools/lib/traceevent/plugin_kvm.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,3 +434,32 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
434434
PEVENT_FUNC_ARG_VOID);
435435
return 0;
436436
}
437+
438+
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
439+
{
440+
pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_exit",
441+
kvm_exit_handler, NULL);
442+
443+
pevent_unregister_event_handler(pevent, -1, "kvm", "kvm_emulate_insn",
444+
kvm_emulate_insn_handler, NULL);
445+
446+
pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_get_page",
447+
kvm_mmu_get_page_handler, NULL);
448+
449+
pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_sync_page",
450+
kvm_mmu_print_role, NULL);
451+
452+
pevent_unregister_event_handler(pevent, -1,
453+
"kvmmmu", "kvm_mmu_unsync_page",
454+
kvm_mmu_print_role, NULL);
455+
456+
pevent_unregister_event_handler(pevent, -1, "kvmmmu", "kvm_mmu_zap_page",
457+
kvm_mmu_print_role, NULL);
458+
459+
pevent_unregister_event_handler(pevent, -1, "kvmmmu",
460+
"kvm_mmu_prepare_zap_page", kvm_mmu_print_role,
461+
NULL);
462+
463+
pevent_unregister_print_function(pevent, process_is_writable_pte,
464+
"is_writable_pte");
465+
}

tools/lib/traceevent/plugin_mac80211.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,10 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
9393
drv_bss_info_changed, NULL);
9494
return 0;
9595
}
96+
97+
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
98+
{
99+
pevent_unregister_event_handler(pevent, -1, "mac80211",
100+
"drv_bss_info_changed",
101+
drv_bss_info_changed, NULL);
102+
}

tools/lib/traceevent/plugin_sched_switch.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,15 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
146146
sched_wakeup_handler, NULL);
147147
return 0;
148148
}
149+
150+
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
151+
{
152+
pevent_unregister_event_handler(pevent, -1, "sched", "sched_switch",
153+
sched_switch_handler, NULL);
154+
155+
pevent_unregister_event_handler(pevent, -1, "sched", "sched_wakeup",
156+
sched_wakeup_handler, NULL);
157+
158+
pevent_unregister_event_handler(pevent, -1, "sched", "sched_wakeup_new",
159+
sched_wakeup_handler, NULL);
160+
}

tools/lib/traceevent/plugin_scsi.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,3 +421,9 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
421421
PEVENT_FUNC_ARG_VOID);
422422
return 0;
423423
}
424+
425+
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
426+
{
427+
pevent_unregister_print_function(pevent, process_scsi_trace_parse_cdb,
428+
"scsi_trace_parse_cdb");
429+
}

tools/lib/traceevent/plugin_xen.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,9 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
128128
PEVENT_FUNC_ARG_VOID);
129129
return 0;
130130
}
131+
132+
void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
133+
{
134+
pevent_unregister_print_function(pevent, process_xen_hypercall_name,
135+
"xen_hypercall_name");
136+
}

tools/perf/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ all tags TAGS:
7474
clean:
7575
$(make)
7676

77+
#
78+
# The build-test target is not really parallel, don't print the jobs info:
79+
#
80+
build-test:
81+
@$(MAKE) -f tests/make --no-print-directory
82+
7783
#
7884
# All other targets get passed through:
7985
#

0 commit comments

Comments
 (0)