perf scripting: Add 'flush' callback to scripting API
In order to defer some output via the scripting API, there needs to be a callback after session processing but before the session is deleted. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1408129739-17368-3-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
d44bc55829
commit
d445dd2a78
|
@ -485,6 +485,11 @@ static int default_start_script(const char *script __maybe_unused,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int default_flush_script(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int default_stop_script(void)
|
static int default_stop_script(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -498,6 +503,7 @@ static int default_generate_script(struct pevent *pevent __maybe_unused,
|
||||||
|
|
||||||
static struct scripting_ops default_scripting_ops = {
|
static struct scripting_ops default_scripting_ops = {
|
||||||
.start_script = default_start_script,
|
.start_script = default_start_script,
|
||||||
|
.flush_script = default_flush_script,
|
||||||
.stop_script = default_stop_script,
|
.stop_script = default_stop_script,
|
||||||
.process_event = process_event,
|
.process_event = process_event,
|
||||||
.generate_script = default_generate_script,
|
.generate_script = default_generate_script,
|
||||||
|
@ -513,6 +519,11 @@ static void setup_scripting(void)
|
||||||
scripting_ops = &default_scripting_ops;
|
scripting_ops = &default_scripting_ops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int flush_scripting(void)
|
||||||
|
{
|
||||||
|
return scripting_ops->flush_script();
|
||||||
|
}
|
||||||
|
|
||||||
static int cleanup_scripting(void)
|
static int cleanup_scripting(void)
|
||||||
{
|
{
|
||||||
pr_debug("\nperf script stopped\n");
|
pr_debug("\nperf script stopped\n");
|
||||||
|
@ -1813,6 +1824,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
|
||||||
|
|
||||||
err = __cmd_script(&script);
|
err = __cmd_script(&script);
|
||||||
|
|
||||||
|
flush_scripting();
|
||||||
|
|
||||||
out_delete:
|
out_delete:
|
||||||
perf_session__delete(session);
|
perf_session__delete(session);
|
||||||
|
|
||||||
|
|
|
@ -432,6 +432,11 @@ error:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int perl_flush_script(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stop trace script
|
* Stop trace script
|
||||||
*/
|
*/
|
||||||
|
@ -633,6 +638,7 @@ static int perl_generate_script(struct pevent *pevent, const char *outfile)
|
||||||
struct scripting_ops perl_scripting_ops = {
|
struct scripting_ops perl_scripting_ops = {
|
||||||
.name = "Perl",
|
.name = "Perl",
|
||||||
.start_script = perl_start_script,
|
.start_script = perl_start_script,
|
||||||
|
.flush_script = perl_flush_script,
|
||||||
.stop_script = perl_stop_script,
|
.stop_script = perl_stop_script,
|
||||||
.process_event = perl_process_event,
|
.process_event = perl_process_event,
|
||||||
.generate_script = perl_generate_script,
|
.generate_script = perl_generate_script,
|
||||||
|
|
|
@ -639,6 +639,11 @@ error:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int python_flush_script(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stop trace script
|
* Stop trace script
|
||||||
*/
|
*/
|
||||||
|
@ -823,6 +828,7 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
|
||||||
struct scripting_ops python_scripting_ops = {
|
struct scripting_ops python_scripting_ops = {
|
||||||
.name = "Python",
|
.name = "Python",
|
||||||
.start_script = python_start_script,
|
.start_script = python_start_script,
|
||||||
|
.flush_script = python_flush_script,
|
||||||
.stop_script = python_stop_script,
|
.stop_script = python_stop_script,
|
||||||
.process_event = python_process_event,
|
.process_event = python_process_event,
|
||||||
.generate_script = python_generate_script,
|
.generate_script = python_generate_script,
|
||||||
|
|
|
@ -30,6 +30,11 @@
|
||||||
|
|
||||||
struct scripting_context *scripting_context;
|
struct scripting_context *scripting_context;
|
||||||
|
|
||||||
|
static int flush_script_unsupported(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int stop_script_unsupported(void)
|
static int stop_script_unsupported(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -74,6 +79,7 @@ static int python_generate_script_unsupported(struct pevent *pevent
|
||||||
struct scripting_ops python_scripting_unsupported_ops = {
|
struct scripting_ops python_scripting_unsupported_ops = {
|
||||||
.name = "Python",
|
.name = "Python",
|
||||||
.start_script = python_start_script_unsupported,
|
.start_script = python_start_script_unsupported,
|
||||||
|
.flush_script = flush_script_unsupported,
|
||||||
.stop_script = stop_script_unsupported,
|
.stop_script = stop_script_unsupported,
|
||||||
.process_event = process_event_unsupported,
|
.process_event = process_event_unsupported,
|
||||||
.generate_script = python_generate_script_unsupported,
|
.generate_script = python_generate_script_unsupported,
|
||||||
|
@ -137,6 +143,7 @@ static int perl_generate_script_unsupported(struct pevent *pevent
|
||||||
struct scripting_ops perl_scripting_unsupported_ops = {
|
struct scripting_ops perl_scripting_unsupported_ops = {
|
||||||
.name = "Perl",
|
.name = "Perl",
|
||||||
.start_script = perl_start_script_unsupported,
|
.start_script = perl_start_script_unsupported,
|
||||||
|
.flush_script = flush_script_unsupported,
|
||||||
.stop_script = stop_script_unsupported,
|
.stop_script = stop_script_unsupported,
|
||||||
.process_event = process_event_unsupported,
|
.process_event = process_event_unsupported,
|
||||||
.generate_script = perl_generate_script_unsupported,
|
.generate_script = perl_generate_script_unsupported,
|
||||||
|
|
|
@ -64,6 +64,7 @@ struct perf_session;
|
||||||
struct scripting_ops {
|
struct scripting_ops {
|
||||||
const char *name;
|
const char *name;
|
||||||
int (*start_script) (const char *script, int argc, const char **argv);
|
int (*start_script) (const char *script, int argc, const char **argv);
|
||||||
|
int (*flush_script) (void);
|
||||||
int (*stop_script) (void);
|
int (*stop_script) (void);
|
||||||
void (*process_event) (union perf_event *event,
|
void (*process_event) (union perf_event *event,
|
||||||
struct perf_sample *sample,
|
struct perf_sample *sample,
|
||||||
|
|
Loading…
Reference in New Issue