* [PATCH 1/3] perf script: Remove default_scripting_ops
@ 2015-11-26 13:55 Jiri Olsa
2015-11-26 13:55 ` [PATCH 2/3] perf script: Pass perf_script into process_event Jiri Olsa
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Jiri Olsa @ 2015-11-26 13:55 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra
The default script handler (the one that displays samples on screen)
is implemented scripting_ops instance with process_event callback.
This way we can't pass any script config into display function,
because we don't want perl or python handlers to be depended on
perf script internals.
Removing the default_scripting_ops and calling process event
function directly. This way it's possible to pass perf_script
struct and process configuration data in following commit.
Link: http://lkml.kernel.org/n/tip-emel4exb5d0930e3h588iidi@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-script.c | 43 +++++++------------------------------------
1 file changed, 7 insertions(+), 36 deletions(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 72b5deb4bd79..8e3f8048d2d0 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -643,57 +643,24 @@ static void process_event(union perf_event *event, struct perf_sample *sample,
printf("\n");
}
-static int default_start_script(const char *script __maybe_unused,
- int argc __maybe_unused,
- const char **argv __maybe_unused)
-{
- return 0;
-}
-
-static int default_flush_script(void)
-{
- return 0;
-}
-
-static int default_stop_script(void)
-{
- return 0;
-}
-
-static int default_generate_script(struct pevent *pevent __maybe_unused,
- const char *outfile __maybe_unused)
-{
- return 0;
-}
-
-static struct scripting_ops default_scripting_ops = {
- .start_script = default_start_script,
- .flush_script = default_flush_script,
- .stop_script = default_stop_script,
- .process_event = process_event,
- .generate_script = default_generate_script,
-};
-
static struct scripting_ops *scripting_ops;
static void setup_scripting(void)
{
setup_perl_scripting();
setup_python_scripting();
-
- scripting_ops = &default_scripting_ops;
}
static int flush_scripting(void)
{
- return scripting_ops->flush_script();
+ return scripting_ops ? scripting_ops->flush_script() : 0;
}
static int cleanup_scripting(void)
{
pr_debug("\nperf script stopped\n");
- return scripting_ops->stop_script();
+ return scripting_ops ? scripting_ops->stop_script() : 0;
}
static int process_sample_event(struct perf_tool *tool __maybe_unused,
@@ -727,7 +694,11 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
goto out_put;
- scripting_ops->process_event(event, sample, evsel, &al);
+ if (scripting_ops)
+ scripting_ops->process_event(event, sample, evsel, &al);
+ else
+ process_event(event, sample, evsel, &al);
+
out_put:
addr_location__put(&al);
return 0;
--
2.4.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] perf script: Pass perf_script into process_event
2015-11-26 13:55 [PATCH 1/3] perf script: Remove default_scripting_ops Jiri Olsa
@ 2015-11-26 13:55 ` Jiri Olsa
2015-11-26 16:22 ` Arnaldo Carvalho de Melo
2015-11-26 13:55 ` [PATCH 3/3] perf script: Align event name properly Jiri Olsa
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: Jiri Olsa @ 2015-11-26 13:55 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra
Passing perf_script struct into process_event function.
Link: http://lkml.kernel.org/n/tip-jad0bjspvazzf5v4bsnz74ax@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-script.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 8e3f8048d2d0..3c3f8d0e3064 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -588,8 +588,17 @@ static void print_sample_flags(u32 flags)
printf(" %-4s ", str);
}
-static void process_event(union perf_event *event, struct perf_sample *sample,
- struct perf_evsel *evsel, struct addr_location *al)
+struct perf_script {
+ struct perf_tool tool;
+ struct perf_session *session;
+ bool show_task_events;
+ bool show_mmap_events;
+ bool show_switch_events;
+};
+
+static void process_event(struct perf_script *script __maybe_unused, union perf_event *event,
+ struct perf_sample *sample, struct perf_evsel *evsel,
+ struct addr_location *al)
{
struct thread *thread = al->thread;
struct perf_event_attr *attr = &evsel->attr;
@@ -663,12 +672,13 @@ static int cleanup_scripting(void)
return scripting_ops ? scripting_ops->stop_script() : 0;
}
-static int process_sample_event(struct perf_tool *tool __maybe_unused,
+static int process_sample_event(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
struct machine *machine)
{
+ struct perf_script *scr = container_of(tool, struct perf_script, tool);
struct addr_location al;
if (debug_mode) {
@@ -697,21 +707,13 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
if (scripting_ops)
scripting_ops->process_event(event, sample, evsel, &al);
else
- process_event(event, sample, evsel, &al);
+ process_event(scr, event, sample, evsel, &al);
out_put:
addr_location__put(&al);
return 0;
}
-struct perf_script {
- struct perf_tool tool;
- struct perf_session *session;
- bool show_task_events;
- bool show_mmap_events;
- bool show_switch_events;
-};
-
static int process_attr(struct perf_tool *tool, union perf_event *event,
struct perf_evlist **pevlist)
{
--
2.4.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/3] perf script: Align event name properly
2015-11-26 13:55 [PATCH 1/3] perf script: Remove default_scripting_ops Jiri Olsa
2015-11-26 13:55 ` [PATCH 2/3] perf script: Pass perf_script into process_event Jiri Olsa
@ 2015-11-26 13:55 ` Jiri Olsa
2015-11-26 14:25 ` David Ahern
2015-11-26 16:33 ` [PATCH 1/3] perf script: Remove default_scripting_ops Arnaldo Carvalho de Melo
2015-11-27 7:43 ` [tip:perf/core] " tip-bot for Jiri Olsa
3 siblings, 1 reply; 12+ messages in thread
From: Jiri Olsa @ 2015-11-26 13:55 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra
Adding code to align event names, so we get aligned output
in case of multiple events with different names.
Before:
$ perf script
:13757 13757 163918.230829: cpu/mem-snp-none/P: ffff88085f20d010
:13757 13757 163918.230832: cpu/mem-loads,ldlat=30/P: 7f5a5f719f00
:13757 13757 163918.230835: cpu/mem-loads,ldlat=30/P: 7f5a5f719f00
:13758 13758 163918.230838: cpu/mem-snp-none/P: ffff88085f4ad810
:13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28
:13757 13757 163918.155264: cpu/mem-snp-hitm/P: 601080
...
After:
$ perf script
:13757 13757 163918.228831: cpu/mem-snp-none/P: ffffffff81a841c0
:13757 13757 163918.228834: cpu/mem-loads,ldlat=30/P: 7f5a5f719f08
:13757 13757 163918.228837: cpu/mem-loads,ldlat=30/P: 7f5a5f719f08
:13758 13758 163918.228837: cpu/mem-snp-none/P: ffff88085f4ad800
:13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28
:13757 13757 163918.155264: cpu/mem-snp-hitm/P: 601080
...
Link: http://lkml.kernel.org/n/tip-hsrwmiogt9menjsg7uaxqvq2@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-script.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 3c3f8d0e3064..10a96da0ea56 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -594,9 +594,24 @@ struct perf_script {
bool show_task_events;
bool show_mmap_events;
bool show_switch_events;
+ int name_width;
};
-static void process_event(struct perf_script *script __maybe_unused, union perf_event *event,
+static int perf_evlist__max_name_len(struct perf_evlist *evlist)
+{
+ struct perf_evsel *evsel;
+ int max = 0;
+
+ evlist__for_each(evlist, evsel) {
+ int len = strlen(perf_evsel__name(evsel));
+
+ max = MAX(len, max);
+ }
+
+ return max;
+}
+
+static void process_event(struct perf_script *script, union perf_event *event,
struct perf_sample *sample, struct perf_evsel *evsel,
struct addr_location *al)
{
@@ -613,7 +628,12 @@ static void process_event(struct perf_script *script __maybe_unused, union perf_
if (PRINT_FIELD(EVNAME)) {
const char *evname = perf_evsel__name(evsel);
- printf("%s: ", evname ? evname : "[unknown]");
+
+ if (!script->name_width)
+ script->name_width = perf_evlist__max_name_len(script->session->evlist);
+
+ printf("%*s: ", script->name_width,
+ evname ? evname : "[unknown]");
}
if (print_flags)
--
2.4.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] perf script: Align event name properly
2015-11-26 13:55 ` [PATCH 3/3] perf script: Align event name properly Jiri Olsa
@ 2015-11-26 14:25 ` David Ahern
2015-11-26 14:30 ` Jiri Olsa
2015-12-27 11:59 ` Jiri Olsa
0 siblings, 2 replies; 12+ messages in thread
From: David Ahern @ 2015-11-26 14:25 UTC (permalink / raw)
To: Jiri Olsa, Arnaldo Carvalho de Melo
Cc: lkml, Ingo Molnar, Namhyung Kim, Peter Zijlstra
On 11/26/15 6:55 AM, Jiri Olsa wrote:
> Adding code to align event names, so we get aligned output
> in case of multiple events with different names.
>
> Before:
> $ perf script
> :13757 13757 163918.230829: cpu/mem-snp-none/P: ffff88085f20d010
> :13757 13757 163918.230832: cpu/mem-loads,ldlat=30/P: 7f5a5f719f00
> :13757 13757 163918.230835: cpu/mem-loads,ldlat=30/P: 7f5a5f719f00
> :13758 13758 163918.230838: cpu/mem-snp-none/P: ffff88085f4ad810
> :13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28
> :13757 13757 163918.155264: cpu/mem-snp-hitm/P: 601080
> ...
>
What's up with the ":13757" for the process name?
Patches LGTM
Acked-by: David Ahern <dsahern@gmail.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] perf script: Align event name properly
2015-11-26 14:25 ` David Ahern
@ 2015-11-26 14:30 ` Jiri Olsa
2015-11-26 14:34 ` David Ahern
2015-12-27 11:59 ` Jiri Olsa
1 sibling, 1 reply; 12+ messages in thread
From: Jiri Olsa @ 2015-11-26 14:30 UTC (permalink / raw)
To: David Ahern
Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, Ingo Molnar,
Namhyung Kim, Peter Zijlstra
On Thu, Nov 26, 2015 at 07:25:17AM -0700, David Ahern wrote:
> On 11/26/15 6:55 AM, Jiri Olsa wrote:
> >Adding code to align event names, so we get aligned output
> >in case of multiple events with different names.
> >
> >Before:
> > $ perf script
> > :13757 13757 163918.230829: cpu/mem-snp-none/P: ffff88085f20d010
> > :13757 13757 163918.230832: cpu/mem-loads,ldlat=30/P: 7f5a5f719f00
> > :13757 13757 163918.230835: cpu/mem-loads,ldlat=30/P: 7f5a5f719f00
> > :13758 13758 163918.230838: cpu/mem-snp-none/P: ffff88085f4ad810
> > :13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28
> > :13757 13757 163918.155264: cpu/mem-snp-hitm/P: 601080
> > ...
> >
>
> What's up with the ":13757" for the process name?
hum, fallback if the name's not resolved? I'll check..
thanks,
jirka
>
> Patches LGTM
>
> Acked-by: David Ahern <dsahern@gmail.com>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] perf script: Align event name properly
2015-11-26 14:30 ` Jiri Olsa
@ 2015-11-26 14:34 ` David Ahern
0 siblings, 0 replies; 12+ messages in thread
From: David Ahern @ 2015-11-26 14:34 UTC (permalink / raw)
To: Jiri Olsa
Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, Ingo Molnar,
Namhyung Kim, Peter Zijlstra
On 11/26/15 7:30 AM, Jiri Olsa wrote:
> On Thu, Nov 26, 2015 at 07:25:17AM -0700, David Ahern wrote:
>> On 11/26/15 6:55 AM, Jiri Olsa wrote:
>>> Adding code to align event names, so we get aligned output
>>> in case of multiple events with different names.
>>>
>>> Before:
>>> $ perf script
>>> :13757 13757 163918.230829: cpu/mem-snp-none/P: ffff88085f20d010
>>> :13757 13757 163918.230832: cpu/mem-loads,ldlat=30/P: 7f5a5f719f00
>>> :13757 13757 163918.230835: cpu/mem-loads,ldlat=30/P: 7f5a5f719f00
>>> :13758 13758 163918.230838: cpu/mem-snp-none/P: ffff88085f4ad810
>>> :13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28
>>> :13757 13757 163918.155264: cpu/mem-snp-hitm/P: 601080
>>> ...
>>>
>>
>> What's up with the ":13757" for the process name?
>
> hum, fallback if the name's not resolved? I'll check..
right, but I thought those were fixed. How is there a SAMPLE for a task
without a COMM.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] perf script: Pass perf_script into process_event
2015-11-26 13:55 ` [PATCH 2/3] perf script: Pass perf_script into process_event Jiri Olsa
@ 2015-11-26 16:22 ` Arnaldo Carvalho de Melo
2015-11-26 17:55 ` [PATCHv2 " Jiri Olsa
0 siblings, 1 reply; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-11-26 16:22 UTC (permalink / raw)
To: Jiri Olsa; +Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra
Em Thu, Nov 26, 2015 at 02:55:24PM +0100, Jiri Olsa escreveu:
> Passing perf_script struct into process_event function.
For? Please write the motivation for a patch.
- Arnaldo
> Link: http://lkml.kernel.org/n/tip-jad0bjspvazzf5v4bsnz74ax@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> tools/perf/builtin-script.c | 26 ++++++++++++++------------
> 1 file changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index 8e3f8048d2d0..3c3f8d0e3064 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -588,8 +588,17 @@ static void print_sample_flags(u32 flags)
> printf(" %-4s ", str);
> }
>
> -static void process_event(union perf_event *event, struct perf_sample *sample,
> - struct perf_evsel *evsel, struct addr_location *al)
> +struct perf_script {
> + struct perf_tool tool;
> + struct perf_session *session;
> + bool show_task_events;
> + bool show_mmap_events;
> + bool show_switch_events;
> +};
> +
> +static void process_event(struct perf_script *script __maybe_unused, union perf_event *event,
> + struct perf_sample *sample, struct perf_evsel *evsel,
> + struct addr_location *al)
> {
> struct thread *thread = al->thread;
> struct perf_event_attr *attr = &evsel->attr;
> @@ -663,12 +672,13 @@ static int cleanup_scripting(void)
> return scripting_ops ? scripting_ops->stop_script() : 0;
> }
>
> -static int process_sample_event(struct perf_tool *tool __maybe_unused,
> +static int process_sample_event(struct perf_tool *tool,
> union perf_event *event,
> struct perf_sample *sample,
> struct perf_evsel *evsel,
> struct machine *machine)
> {
> + struct perf_script *scr = container_of(tool, struct perf_script, tool);
> struct addr_location al;
>
> if (debug_mode) {
> @@ -697,21 +707,13 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
> if (scripting_ops)
> scripting_ops->process_event(event, sample, evsel, &al);
> else
> - process_event(event, sample, evsel, &al);
> + process_event(scr, event, sample, evsel, &al);
>
> out_put:
> addr_location__put(&al);
> return 0;
> }
>
> -struct perf_script {
> - struct perf_tool tool;
> - struct perf_session *session;
> - bool show_task_events;
> - bool show_mmap_events;
> - bool show_switch_events;
> -};
> -
> static int process_attr(struct perf_tool *tool, union perf_event *event,
> struct perf_evlist **pevlist)
> {
> --
> 2.4.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] perf script: Remove default_scripting_ops
2015-11-26 13:55 [PATCH 1/3] perf script: Remove default_scripting_ops Jiri Olsa
2015-11-26 13:55 ` [PATCH 2/3] perf script: Pass perf_script into process_event Jiri Olsa
2015-11-26 13:55 ` [PATCH 3/3] perf script: Align event name properly Jiri Olsa
@ 2015-11-26 16:33 ` Arnaldo Carvalho de Melo
2015-11-27 7:43 ` [tip:perf/core] " tip-bot for Jiri Olsa
3 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-11-26 16:33 UTC (permalink / raw)
To: Jiri Olsa; +Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra
Em Thu, Nov 26, 2015 at 02:55:23PM +0100, Jiri Olsa escreveu:
> The default script handler (the one that displays samples on screen)
> is implemented scripting_ops instance with process_event callback.
>
> This way we can't pass any script config into display function,
> because we don't want perl or python handlers to be depended on
> perf script internals.
>
> Removing the default_scripting_ops and calling process event
> function directly. This way it's possible to pass perf_script
> struct and process configuration data in following commit.
>
> Link: http://lkml.kernel.org/n/tip-emel4exb5d0930e3h588iidi@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Applied, with David's ack.
- Arnaldo
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCHv2 2/3] perf script: Pass perf_script into process_event
2015-11-26 16:22 ` Arnaldo Carvalho de Melo
@ 2015-11-26 17:55 ` Jiri Olsa
2015-11-27 7:45 ` [tip:perf/core] " tip-bot for Jiri Olsa
0 siblings, 1 reply; 12+ messages in thread
From: Jiri Olsa @ 2015-11-26 17:55 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra
On Thu, Nov 26, 2015 at 01:22:26PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Nov 26, 2015 at 02:55:24PM +0100, Jiri Olsa escreveu:
> > Passing perf_script struct into process_event function.
>
> For? Please write the motivation for a patch.
for patch 3 ;-) attached with new changelog
perf/fixes branch is updated
thanks,
jirka
---
Passing perf_script struct into process_event function,
so we could process configuration data for event printing.
It will be used in following patch to get event name
string width.
Link: http://lkml.kernel.org/n/tip-jad0bjspvazzf5v4bsnz74ax@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-script.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 8e3f8048d2d0..3c3f8d0e3064 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -588,8 +588,17 @@ static void print_sample_flags(u32 flags)
printf(" %-4s ", str);
}
-static void process_event(union perf_event *event, struct perf_sample *sample,
- struct perf_evsel *evsel, struct addr_location *al)
+struct perf_script {
+ struct perf_tool tool;
+ struct perf_session *session;
+ bool show_task_events;
+ bool show_mmap_events;
+ bool show_switch_events;
+};
+
+static void process_event(struct perf_script *script __maybe_unused, union perf_event *event,
+ struct perf_sample *sample, struct perf_evsel *evsel,
+ struct addr_location *al)
{
struct thread *thread = al->thread;
struct perf_event_attr *attr = &evsel->attr;
@@ -663,12 +672,13 @@ static int cleanup_scripting(void)
return scripting_ops ? scripting_ops->stop_script() : 0;
}
-static int process_sample_event(struct perf_tool *tool __maybe_unused,
+static int process_sample_event(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
struct machine *machine)
{
+ struct perf_script *scr = container_of(tool, struct perf_script, tool);
struct addr_location al;
if (debug_mode) {
@@ -697,21 +707,13 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
if (scripting_ops)
scripting_ops->process_event(event, sample, evsel, &al);
else
- process_event(event, sample, evsel, &al);
+ process_event(scr, event, sample, evsel, &al);
out_put:
addr_location__put(&al);
return 0;
}
-struct perf_script {
- struct perf_tool tool;
- struct perf_session *session;
- bool show_task_events;
- bool show_mmap_events;
- bool show_switch_events;
-};
-
static int process_attr(struct perf_tool *tool, union perf_event *event,
struct perf_evlist **pevlist)
{
--
2.4.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [tip:perf/core] perf script: Remove default_scripting_ops
2015-11-26 13:55 [PATCH 1/3] perf script: Remove default_scripting_ops Jiri Olsa
` (2 preceding siblings ...)
2015-11-26 16:33 ` [PATCH 1/3] perf script: Remove default_scripting_ops Arnaldo Carvalho de Melo
@ 2015-11-27 7:43 ` tip-bot for Jiri Olsa
3 siblings, 0 replies; 12+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-11-27 7:43 UTC (permalink / raw)
To: linux-tip-commits
Cc: hpa, acme, tglx, jolsa, a.p.zijlstra, dsahern, namhyung, mingo,
linux-kernel
Commit-ID: 2aaecfc51bc65532152e141df3268fda06cae029
Gitweb: http://git.kernel.org/tip/2aaecfc51bc65532152e141df3268fda06cae029
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Thu, 26 Nov 2015 14:55:23 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 26 Nov 2015 13:33:00 -0300
perf script: Remove default_scripting_ops
The default script handler (the one that displays samples on screen) is
implemented scripting_ops instance with process_event callback.
This way we can't pass any script config into display function, because
we don't want perl or python handlers to be depended on perf script
internals.
Removing the default_scripting_ops and calling process event function
directly. This way it's possible to pass perf_script struct and process
configuration data in following commit.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1448546125-29245-1-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-script.c | 43 +++++++------------------------------------
1 file changed, 7 insertions(+), 36 deletions(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 72b5deb..8e3f804 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -643,57 +643,24 @@ static void process_event(union perf_event *event, struct perf_sample *sample,
printf("\n");
}
-static int default_start_script(const char *script __maybe_unused,
- int argc __maybe_unused,
- const char **argv __maybe_unused)
-{
- return 0;
-}
-
-static int default_flush_script(void)
-{
- return 0;
-}
-
-static int default_stop_script(void)
-{
- return 0;
-}
-
-static int default_generate_script(struct pevent *pevent __maybe_unused,
- const char *outfile __maybe_unused)
-{
- return 0;
-}
-
-static struct scripting_ops default_scripting_ops = {
- .start_script = default_start_script,
- .flush_script = default_flush_script,
- .stop_script = default_stop_script,
- .process_event = process_event,
- .generate_script = default_generate_script,
-};
-
static struct scripting_ops *scripting_ops;
static void setup_scripting(void)
{
setup_perl_scripting();
setup_python_scripting();
-
- scripting_ops = &default_scripting_ops;
}
static int flush_scripting(void)
{
- return scripting_ops->flush_script();
+ return scripting_ops ? scripting_ops->flush_script() : 0;
}
static int cleanup_scripting(void)
{
pr_debug("\nperf script stopped\n");
- return scripting_ops->stop_script();
+ return scripting_ops ? scripting_ops->stop_script() : 0;
}
static int process_sample_event(struct perf_tool *tool __maybe_unused,
@@ -727,7 +694,11 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
goto out_put;
- scripting_ops->process_event(event, sample, evsel, &al);
+ if (scripting_ops)
+ scripting_ops->process_event(event, sample, evsel, &al);
+ else
+ process_event(event, sample, evsel, &al);
+
out_put:
addr_location__put(&al);
return 0;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [tip:perf/core] perf script: Pass perf_script into process_event
2015-11-26 17:55 ` [PATCHv2 " Jiri Olsa
@ 2015-11-27 7:45 ` tip-bot for Jiri Olsa
0 siblings, 0 replies; 12+ messages in thread
From: tip-bot for Jiri Olsa @ 2015-11-27 7:45 UTC (permalink / raw)
To: linux-tip-commits
Cc: hpa, linux-kernel, dsahern, jolsa, jolsa, mingo, namhyung, acme,
a.p.zijlstra, tglx
Commit-ID: 809e9423d7bc72e50d94d8267bab010a007a6137
Gitweb: http://git.kernel.org/tip/809e9423d7bc72e50d94d8267bab010a007a6137
Author: Jiri Olsa <jolsa@redhat.com>
AuthorDate: Thu, 26 Nov 2015 18:55:21 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 26 Nov 2015 16:06:16 -0300
perf script: Pass perf_script into process_event
Passing perf_script struct into process_event function, so we could
process configuration data for event printing.
It will be used in following patch to get event name string width.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20151126175521.GA18979@krava.brq.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-script.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 8e3f804..3c3f8d0 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -588,8 +588,17 @@ static void print_sample_flags(u32 flags)
printf(" %-4s ", str);
}
-static void process_event(union perf_event *event, struct perf_sample *sample,
- struct perf_evsel *evsel, struct addr_location *al)
+struct perf_script {
+ struct perf_tool tool;
+ struct perf_session *session;
+ bool show_task_events;
+ bool show_mmap_events;
+ bool show_switch_events;
+};
+
+static void process_event(struct perf_script *script __maybe_unused, union perf_event *event,
+ struct perf_sample *sample, struct perf_evsel *evsel,
+ struct addr_location *al)
{
struct thread *thread = al->thread;
struct perf_event_attr *attr = &evsel->attr;
@@ -663,12 +672,13 @@ static int cleanup_scripting(void)
return scripting_ops ? scripting_ops->stop_script() : 0;
}
-static int process_sample_event(struct perf_tool *tool __maybe_unused,
+static int process_sample_event(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
struct perf_evsel *evsel,
struct machine *machine)
{
+ struct perf_script *scr = container_of(tool, struct perf_script, tool);
struct addr_location al;
if (debug_mode) {
@@ -697,21 +707,13 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
if (scripting_ops)
scripting_ops->process_event(event, sample, evsel, &al);
else
- process_event(event, sample, evsel, &al);
+ process_event(scr, event, sample, evsel, &al);
out_put:
addr_location__put(&al);
return 0;
}
-struct perf_script {
- struct perf_tool tool;
- struct perf_session *session;
- bool show_task_events;
- bool show_mmap_events;
- bool show_switch_events;
-};
-
static int process_attr(struct perf_tool *tool, union perf_event *event,
struct perf_evlist **pevlist)
{
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] perf script: Align event name properly
2015-11-26 14:25 ` David Ahern
2015-11-26 14:30 ` Jiri Olsa
@ 2015-12-27 11:59 ` Jiri Olsa
1 sibling, 0 replies; 12+ messages in thread
From: Jiri Olsa @ 2015-12-27 11:59 UTC (permalink / raw)
To: David Ahern
Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, Ingo Molnar,
Namhyung Kim, Peter Zijlstra
On Thu, Nov 26, 2015 at 07:25:17AM -0700, David Ahern wrote:
> On 11/26/15 6:55 AM, Jiri Olsa wrote:
> >Adding code to align event names, so we get aligned output
> >in case of multiple events with different names.
> >
> >Before:
> > $ perf script
> > :13757 13757 163918.230829: cpu/mem-snp-none/P: ffff88085f20d010
> > :13757 13757 163918.230832: cpu/mem-loads,ldlat=30/P: 7f5a5f719f00
> > :13757 13757 163918.230835: cpu/mem-loads,ldlat=30/P: 7f5a5f719f00
> > :13758 13758 163918.230838: cpu/mem-snp-none/P: ffff88085f4ad810
> > :13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28
> > :13757 13757 163918.155264: cpu/mem-snp-hitm/P: 601080
> > ...
> >
>
> What's up with the ":13757" for the process name?
>
> Patches LGTM
>
> Acked-by: David Ahern <dsahern@gmail.com>
this one was missed, I pushed it on the top of my perf/fixes
branch with David's ack
thanks,
jirka
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-12-27 11:59 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-26 13:55 [PATCH 1/3] perf script: Remove default_scripting_ops Jiri Olsa
2015-11-26 13:55 ` [PATCH 2/3] perf script: Pass perf_script into process_event Jiri Olsa
2015-11-26 16:22 ` Arnaldo Carvalho de Melo
2015-11-26 17:55 ` [PATCHv2 " Jiri Olsa
2015-11-27 7:45 ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-11-26 13:55 ` [PATCH 3/3] perf script: Align event name properly Jiri Olsa
2015-11-26 14:25 ` David Ahern
2015-11-26 14:30 ` Jiri Olsa
2015-11-26 14:34 ` David Ahern
2015-12-27 11:59 ` Jiri Olsa
2015-11-26 16:33 ` [PATCH 1/3] perf script: Remove default_scripting_ops Arnaldo Carvalho de Melo
2015-11-27 7:43 ` [tip:perf/core] " tip-bot for Jiri Olsa
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.