perf: Remove match callback for auxiliary events processing
PATCH 1/1 perf: Remove match callback for auxiliary events processing
Removing match callback for auxiliary events processing with following benefits:
- only one function pointer is passed along the way
- the match function is called within output function and could be inlined by compiler
--- kernel/events/core.c | 79 ++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 40 deletions(-)
kernel/events/core.c +39 -40
@@ -4658,12 +4658,10 @@ perf_event_read_event(struct perf_event *event,perf_output_end (&handle); } -typedef int (perf_event_aux_match_cb )(struct perf_event *event,void *data);typedef void (perf_event_aux_output_cb )(struct perf_event *event,void *data);static void perf_event_aux_ctx (struct perf_event_context *ctx, -perf_event_aux_match_cb match,perf_event_aux_output_cb output,void *data) {
@@ -4674,15 +4672,12 @@ perf_event_aux_ctx(struct perf_event_context *ctx,continue ;if (!event_filter_match (event))continue ; -if (match (event, data)) -output (event, data); +output (event, data); } }static void -perf_event_aux (perf_event_aux_match_cb match, -perf_event_aux_output_cb output, -void *data, +perf_event_aux (perf_event_aux_output_cb output,void *data,struct perf_event_context *task_ctx) {struct perf_cpu_context *cpuctx;
@@ -4695,7 +4690,7 @@ perf_event_aux(perf_event_aux_match_cb match, cpuctx =get_cpu_ptr (pmu->pmu_cpu_context);if (cpuctx->unique_pmu != pmu) goto next; -perf_event_aux_ctx (&cpuctx->ctx, match, output, data); +perf_event_aux_ctx (&cpuctx->ctx, output, data);if (task_ctx) goto next; ctxn = pmu->task_ctx_nr;
@@ -4703,14 +4698,14 @@ perf_event_aux(perf_event_aux_match_cb match, goto next; ctx =rcu_dereference (current->perf_event_ctxp[ctxn]);if (ctx) -perf_event_aux_ctx (ctx, match, output, data); +perf_event_aux_ctx (ctx, output, data); next:put_cpu_ptr (pmu->pmu_cpu_context); }if (task_ctx) {preempt_disable (); -perf_event_aux_ctx (task_ctx, match, output, data); +perf_event_aux_ctx (task_ctx, output, data);preempt_enable (); }rcu_read_unlock ();
@@ -4737,6 +4732,12 @@ struct perf_task_event { } event_id; }; +static int perf_event_task_match (struct perf_event *event) +{ +return event->attr.comm || event->attr.mmap || + event->attr.mmap_data || event->attr.task; +} +static void perf_event_task_output (struct perf_event *event,void *data) {
@@ -4746,6 +4747,9 @@ static void perf_event_task_output(struct perf_event *event,struct task_struct *task = task_event->task;int ret, size = task_event->event_id.header.size; +if (!perf_event_task_match (event)) +return ; +perf_event_header__init_id (&task_event->event_id.header, &sample, event); ret = perf_output_begin(&handle, event,
@@ -4768,13 +4772,6 @@ out: task_event->event_id.header.size = size; } -static int perf_event_task_match (struct perf_event *event, -void *data__maybe_unused ) -{ -return event->attr.comm || event->attr.mmap || - event->attr.mmap_data || event->attr.task; -} -static void perf_event_task (struct task_struct *task,struct perf_event_context *task_ctx,int new)
@@ -4803,8 +4800,7 @@ static void perf_event_task(struct task_struct *task, }, }; -perf_event_aux (perf_event_task_match, - perf_event_task_output, +perf_event_aux (perf_event_task_output, &task_event, task_ctx); }
@@ -4831,6 +4827,11 @@ struct perf_comm_event { } event_id; }; +static int perf_event_comm_match (struct perf_event *event) +{ +return event->attr.comm; +} +static void perf_event_comm_output (struct perf_event *event,void *data) {
@@ -4840,6 +4841,9 @@ static void perf_event_comm_output(struct perf_event *event,int size = comm_event->event_id.header.size;int ret; +if (!perf_event_comm_match (event)) +return ; +perf_event_header__init_id (&comm_event->event_id.header, &sample, event); ret =perf_output_begin (&handle, event, comm_event->event_id.header.size);
@@ -4861,12 +4865,6 @@ out: comm_event->event_id.header.size = size; } -static int perf_event_comm_match (struct perf_event *event, -void *data__maybe_unused ) -{ -return event->attr.comm; -} -static void perf_event_comm_event (struct perf_comm_event *comm_event) {char comm[TASK_COMM_LEN ];
@@ -4881,8 +4879,7 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event) comm_event->event_id.header.size =sizeof (comm_event->event_id) + size; -perf_event_aux (perf_event_comm_match, - perf_event_comm_output, +perf_event_aux (perf_event_comm_output, comm_event,NULL ); }
@@ -4945,6 +4942,17 @@ struct perf_mmap_event { } event_id; }; +static int perf_event_mmap_match (struct perf_event *event, +void *data) +{ +struct perf_mmap_event *mmap_event = data; +struct vm_area_struct *vma = mmap_event->vma; +int executable = vma->vm_flags &VM_EXEC ; + +return (!executable && event->attr.mmap_data) || + (executable && event->attr.mmap); +} +static void perf_event_mmap_output (struct perf_event *event,void *data) {
@@ -4954,6 +4962,9 @@ static void perf_event_mmap_output(struct perf_event *event,int size = mmap_event->event_id.header.size;int ret; +if (!perf_event_mmap_match (event, data)) +return ; +perf_event_header__init_id (&mmap_event->event_id.header, &sample, event); ret =perf_output_begin (&handle, event, mmap_event->event_id.header.size);
@@ -4974,17 +4985,6 @@ out: mmap_event->event_id.header.size = size; } -static int perf_event_mmap_match (struct perf_event *event, -void *data) -{ -struct perf_mmap_event *mmap_event = data; -struct vm_area_struct *vma = mmap_event->vma; -int executable = vma->vm_flags &VM_EXEC ; - -return (!executable && event->attr.mmap_data) || - (executable && event->attr.mmap); -} -static void perf_event_mmap_event (struct perf_mmap_event *mmap_event) {struct vm_area_struct *vma = mmap_event->vma;
@@ -5048,8 +5048,7 @@ got_name: mmap_event->event_id.header.size =sizeof (mmap_event->event_id) + size; -perf_event_aux (perf_event_mmap_match, - perf_event_mmap_output, +perf_event_aux (perf_event_mmap_output, mmap_event,NULL );
Signature · 1 line
1.7.11.7
Peter Zijlstra
maintainerQuoted 6 lines · Jiri Olsa
Removing match callback for auxiliary events processing with following benefits:
- only one function pointer is passed along the way
- the match function is called within output function and could be inlined by compiler
Quoted 9 lines
Suggested-by Peter Zijlstra <[email protected]>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]>
Thanks!
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf: Remove the 'match' callback for auxiliary events processing
In reply to Jiri Olsaperf: Remove the 'match' callback for auxiliary events processing
Commit-ID: 67516844625f45f0ce148a01c27bf41f591872b2 Gitweb: http://git.kernel.org/tip/67516844625f45f0ce148a01c27bf41f591872b2 Author: Jiri Olsa <[email protected]> AuthorDate: Tue, 9 Jul 2013 18:56:31 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 12 Jul 2013 13:50:36 +0200
perf: Remove the 'match' callback for auxiliary events processing
It gives the following benefits:
- only one function pointer is passed along the way
- the 'match' function is called within output function and could be inlined by the compiler
--- kernel/events/core.c | 79 ++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 40 deletions(-)
kernel/events/core.c +39 -40
@@ -4680,12 +4680,10 @@ perf_event_read_event(struct perf_event *event,perf_output_end (&handle); } -typedef int (perf_event_aux_match_cb )(struct perf_event *event,void *data);typedef void (perf_event_aux_output_cb )(struct perf_event *event,void *data);static void perf_event_aux_ctx (struct perf_event_context *ctx, -perf_event_aux_match_cb match,perf_event_aux_output_cb output,void *data) {
@@ -4696,15 +4694,12 @@ perf_event_aux_ctx(struct perf_event_context *ctx,continue ;if (!event_filter_match (event))continue ; -if (match (event, data)) -output (event, data); +output (event, data); } }static void -perf_event_aux (perf_event_aux_match_cb match, -perf_event_aux_output_cb output, -void *data, +perf_event_aux (perf_event_aux_output_cb output,void *data,struct perf_event_context *task_ctx) {struct perf_cpu_context *cpuctx;
@@ -4717,7 +4712,7 @@ perf_event_aux(perf_event_aux_match_cb match, cpuctx =get_cpu_ptr (pmu->pmu_cpu_context);if (cpuctx->unique_pmu != pmu) goto next; -perf_event_aux_ctx (&cpuctx->ctx, match, output, data); +perf_event_aux_ctx (&cpuctx->ctx, output, data);if (task_ctx) goto next; ctxn = pmu->task_ctx_nr;
@@ -4725,14 +4720,14 @@ perf_event_aux(perf_event_aux_match_cb match, goto next; ctx =rcu_dereference (current->perf_event_ctxp[ctxn]);if (ctx) -perf_event_aux_ctx (ctx, match, output, data); +perf_event_aux_ctx (ctx, output, data); next:put_cpu_ptr (pmu->pmu_cpu_context); }if (task_ctx) {preempt_disable (); -perf_event_aux_ctx (task_ctx, match, output, data); +perf_event_aux_ctx (task_ctx, output, data);preempt_enable (); }rcu_read_unlock ();
@@ -4759,6 +4754,12 @@ struct perf_task_event { } event_id; }; +static int perf_event_task_match (struct perf_event *event) +{ +return event->attr.comm || event->attr.mmap || + event->attr.mmap_data || event->attr.task; +} +static void perf_event_task_output (struct perf_event *event,void *data) {
@@ -4768,6 +4769,9 @@ static void perf_event_task_output(struct perf_event *event,struct task_struct *task = task_event->task;int ret, size = task_event->event_id.header.size; +if (!perf_event_task_match (event)) +return ; +perf_event_header__init_id (&task_event->event_id.header, &sample, event); ret = perf_output_begin(&handle, event,
@@ -4790,13 +4794,6 @@ out: task_event->event_id.header.size = size; } -static int perf_event_task_match (struct perf_event *event, -void *data__maybe_unused ) -{ -return event->attr.comm || event->attr.mmap || - event->attr.mmap_data || event->attr.task; -} -static void perf_event_task (struct task_struct *task,struct perf_event_context *task_ctx,int new)
@@ -4825,8 +4822,7 @@ static void perf_event_task(struct task_struct *task, }, }; -perf_event_aux (perf_event_task_match, - perf_event_task_output, +perf_event_aux (perf_event_task_output, &task_event, task_ctx); }
@@ -4853,6 +4849,11 @@ struct perf_comm_event { } event_id; }; +static int perf_event_comm_match (struct perf_event *event) +{ +return event->attr.comm; +} +static void perf_event_comm_output (struct perf_event *event,void *data) {
@@ -4862,6 +4863,9 @@ static void perf_event_comm_output(struct perf_event *event,int size = comm_event->event_id.header.size;int ret; +if (!perf_event_comm_match (event)) +return ; +perf_event_header__init_id (&comm_event->event_id.header, &sample, event); ret =perf_output_begin (&handle, event, comm_event->event_id.header.size);
@@ -4883,12 +4887,6 @@ out: comm_event->event_id.header.size = size; } -static int perf_event_comm_match (struct perf_event *event, -void *data__maybe_unused ) -{ -return event->attr.comm; -} -static void perf_event_comm_event (struct perf_comm_event *comm_event) {char comm[TASK_COMM_LEN ];
@@ -4903,8 +4901,7 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event) comm_event->event_id.header.size =sizeof (comm_event->event_id) + size; -perf_event_aux (perf_event_comm_match, - perf_event_comm_output, +perf_event_aux (perf_event_comm_output, comm_event,NULL ); }
@@ -4967,6 +4964,17 @@ struct perf_mmap_event { } event_id; }; +static int perf_event_mmap_match (struct perf_event *event, +void *data) +{ +struct perf_mmap_event *mmap_event = data; +struct vm_area_struct *vma = mmap_event->vma; +int executable = vma->vm_flags &VM_EXEC ; + +return (!executable && event->attr.mmap_data) || + (executable && event->attr.mmap); +} +static void perf_event_mmap_output (struct perf_event *event,void *data) {
@@ -4976,6 +4984,9 @@ static void perf_event_mmap_output(struct perf_event *event,int size = mmap_event->event_id.header.size;int ret; +if (!perf_event_mmap_match (event, data)) +return ; +perf_event_header__init_id (&mmap_event->event_id.header, &sample, event); ret =perf_output_begin (&handle, event, mmap_event->event_id.header.size);
@@ -4996,17 +5007,6 @@ out: mmap_event->event_id.header.size = size; } -static int perf_event_mmap_match (struct perf_event *event, -void *data) -{ -struct perf_mmap_event *mmap_event = data; -struct vm_area_struct *vma = mmap_event->vma; -int executable = vma->vm_flags &VM_EXEC ; - -return (!executable && event->attr.mmap_data) || - (executable && event->attr.mmap); -} -static void perf_event_mmap_event (struct perf_mmap_event *mmap_event) {struct vm_area_struct *vma = mmap_event->vma;
@@ -5070,8 +5070,7 @@ got_name: mmap_event->event_id.header.size =sizeof (mmap_event->event_id) + size; -perf_event_aux (perf_event_mmap_match, - perf_event_mmap_output, +perf_event_aux (perf_event_mmap_output, mmap_event,NULL );