Commit 3541c034 authored by Mathieu Poirier's avatar Mathieu Poirier Committed by Arnaldo Carvalho de Melo

perf evsel: New tracepoint specific function

Making function perf_evsel__append_filter() static and introducing a new
tracepoint specific function to append filters.  That way we eliminate
redundant code and avoid formatting mistake.
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/1474037045-31730-3-git-send-email-mathieu.poirier@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b15d0a4c
...@@ -2151,11 +2151,10 @@ static int trace__set_ev_qualifier_filter(struct trace *trace) ...@@ -2151,11 +2151,10 @@ static int trace__set_ev_qualifier_filter(struct trace *trace)
if (filter == NULL) if (filter == NULL)
goto out_enomem; goto out_enomem;
if (!perf_evsel__append_filter(trace->syscalls.events.sys_enter, if (!perf_evsel__append_tp_filter(trace->syscalls.events.sys_enter,
"(%s) && (%s)", filter)) { filter)) {
sys_exit = trace->syscalls.events.sys_exit; sys_exit = trace->syscalls.events.sys_exit;
err = perf_evsel__append_filter(sys_exit, err = perf_evsel__append_tp_filter(sys_exit, filter);
"(%s) && (%s)", filter);
} }
free(filter); free(filter);
......
...@@ -1045,7 +1045,7 @@ int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter) ...@@ -1045,7 +1045,7 @@ int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter)
return -1; return -1;
} }
int perf_evsel__append_filter(struct perf_evsel *evsel, static int perf_evsel__append_filter(struct perf_evsel *evsel,
const char *fmt, const char *filter) const char *fmt, const char *filter)
{ {
char *new_filter; char *new_filter;
...@@ -1062,6 +1062,11 @@ int perf_evsel__append_filter(struct perf_evsel *evsel, ...@@ -1062,6 +1062,11 @@ int perf_evsel__append_filter(struct perf_evsel *evsel,
return -1; return -1;
} }
int perf_evsel__append_tp_filter(struct perf_evsel *evsel, const char *filter)
{
return perf_evsel__append_filter(evsel, "(%s) && (%s)", filter);
}
int perf_evsel__enable(struct perf_evsel *evsel) int perf_evsel__enable(struct perf_evsel *evsel)
{ {
int nthreads = thread_map__nr(evsel->threads); int nthreads = thread_map__nr(evsel->threads);
......
...@@ -235,8 +235,7 @@ void perf_evsel__set_sample_id(struct perf_evsel *evsel, ...@@ -235,8 +235,7 @@ void perf_evsel__set_sample_id(struct perf_evsel *evsel,
bool use_sample_identifier); bool use_sample_identifier);
int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter); int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter);
int perf_evsel__append_filter(struct perf_evsel *evsel, int perf_evsel__append_tp_filter(struct perf_evsel *evsel, const char *filter);
const char *fmt, const char *filter);
int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads, int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads,
const char *filter); const char *filter);
int perf_evsel__enable(struct perf_evsel *evsel); int perf_evsel__enable(struct perf_evsel *evsel);
......
...@@ -1767,7 +1767,7 @@ static int set_filter(struct perf_evsel *evsel, const void *arg) ...@@ -1767,7 +1767,7 @@ static int set_filter(struct perf_evsel *evsel, const void *arg)
return -1; return -1;
} }
if (perf_evsel__append_filter(evsel, "(%s) && (%s)", str) < 0) { if (perf_evsel__append_tp_filter(evsel, str) < 0) {
fprintf(stderr, fprintf(stderr,
"not enough memory to hold filter string\n"); "not enough memory to hold filter string\n");
return -1; return -1;
...@@ -1798,7 +1798,7 @@ static int add_exclude_perf_filter(struct perf_evsel *evsel, ...@@ -1798,7 +1798,7 @@ static int add_exclude_perf_filter(struct perf_evsel *evsel,
snprintf(new_filter, sizeof(new_filter), "common_pid != %d", getpid()); snprintf(new_filter, sizeof(new_filter), "common_pid != %d", getpid());
if (perf_evsel__append_filter(evsel, "(%s) && (%s)", new_filter) < 0) { if (perf_evsel__append_tp_filter(evsel, new_filter) < 0) {
fprintf(stderr, fprintf(stderr,
"not enough memory to hold filter string\n"); "not enough memory to hold filter string\n");
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment