Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1278242 > unrolled thread

[PATCH 1/3] perf script: Remove default_scripting_ops

Started byJiri Olsa <jolsa@kernel.org>
First post2015-11-26 15:00 +0100
Last post2015-11-27 08:50 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/3] perf script: Remove default_scripting_ops Jiri Olsa <jolsa@kernel.org> - 2015-11-26 15:00 +0100
    Re: [PATCH 1/3] perf script: Remove default_scripting_ops Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-11-26 17:40 +0100
    [tip:perf/core] perf script: Remove default_scripting_ops tip-bot for Jiri Olsa <tipbot@zytor.com> - 2015-11-27 08:50 +0100

#1278242 — [PATCH 1/3] perf script: Remove default_scripting_ops

FromJiri Olsa <jolsa@kernel.org>
Date2015-11-26 15:00 +0100
Subject[PATCH 1/3] perf script: Remove default_scripting_ops
Message-ID<qz5fB-5UD-13@gated-at.bofh.it>
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1278331

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2015-11-26 17:40 +0100
Message-ID<qz7Kq-7Fr-5@gated-at.bofh.it>
In reply to#1278242
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1278583 — [tip:perf/core] perf script: Remove default_scripting_ops

Fromtip-bot for Jiri Olsa <tipbot@zytor.com>
Date2015-11-27 08:50 +0100
Subject[tip:perf/core] perf script: Remove default_scripting_ops
Message-ID<qzlX3-8k4-9@gated-at.bofh.it>
In reply to#1278242
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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web