From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Borislav Petkov <bp@suse.de>, David Ahern <dsahern@gmail.com>,
Don Zickus <dzickus@redhat.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Stephane Eranian <eranian@google.com>
Subject: [PATCH 05/11] perf evsel: Introduce set_filter method
Date: Mon, 6 Jul 2015 12:41:25 -0300 [thread overview]
Message-ID: <1436197291-21625-6-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1436197291-21625-1-git-send-email-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Replaces existing filter string with the one provided.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-jst49z83li0yx3g18o54u51a@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/evsel.c | 13 +++++++++++++
tools/perf/util/evsel.h | 1 +
tools/perf/util/parse-events.c | 3 +--
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 667677495fb0..ae925b9ce6dd 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -823,6 +823,19 @@ int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads,
(void *)filter);
}
+int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter)
+{
+ char *new_filter = strdup(filter);
+
+ if (new_filter != NULL) {
+ free(evsel->filter);
+ evsel->filter = new_filter;
+ return 0;
+ }
+
+ return -1;
+}
+
int perf_evsel__enable(struct perf_evsel *evsel, int ncpus, int nthreads)
{
return perf_evsel__run_ioctl(evsel, ncpus, nthreads,
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index a3ebb83d767e..8aea4baca080 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -182,6 +182,7 @@ void __perf_evsel__reset_sample_bit(struct perf_evsel *evsel,
void perf_evsel__set_sample_id(struct perf_evsel *evsel,
bool use_sample_identifier);
+int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter);
int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads,
const char *filter);
int perf_evsel__enable(struct perf_evsel *evsel, int ncpus, int nthreads);
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 09f8d2357108..a71eeb279ed2 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1177,8 +1177,7 @@ int parse_filter(const struct option *opt, const char *str,
return -1;
}
- last->filter = strdup(str);
- if (last->filter == NULL) {
+ if (perf_evsel__set_filter(last, str) < 0) {
fprintf(stderr, "not enough memory to hold filter string\n");
return -1;
}
--
2.1.0
next prev parent reply other threads:[~2015-07-06 15:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-06 15:41 [GIT PULL 00/11] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-07-06 15:41 ` [PATCH 01/11] perf tools: Asprintf like functions to format integer filter expression Arnaldo Carvalho de Melo
2015-07-06 15:41 ` [PATCH 02/11] perf trace: Remember what are the syscalls tracepoint evsels Arnaldo Carvalho de Melo
2015-07-06 15:41 ` [PATCH 03/11] perf trace: Store the syscall ids for the event qualifiers in a table Arnaldo Carvalho de Melo
2015-07-06 15:41 ` [PATCH 04/11] perf evsel: Rename set_filter to apply_filter Arnaldo Carvalho de Melo
2015-07-06 15:41 ` Arnaldo Carvalho de Melo [this message]
2015-07-06 15:41 ` [PATCH 06/11] perf evlist: Make perf_evlist__set_filter use perf_evsel__set_filter Arnaldo Carvalho de Melo
2015-07-06 15:41 ` [PATCH 07/11] perf evsel: Introduce append_filter() method Arnaldo Carvalho de Melo
2015-07-06 15:41 ` [PATCH 08/11] perf trace: Use event filters for the event qualifier list Arnaldo Carvalho de Melo
2015-07-06 15:41 ` [PATCH 09/11] perf probe: Delete an unnecessary check before the function call "strfilter__delete" Arnaldo Carvalho de Melo
2015-07-06 15:41 ` [PATCH 10/11] perf record: Let user have timestamps with per-thread recording Arnaldo Carvalho de Melo
2015-07-06 15:41 ` [PATCH 11/11] tools lib api debugfs: Check for tracefs when reporting errors Arnaldo Carvalho de Melo
2015-07-06 15:47 ` [GIT PULL 00/11] perf/core improvements and fixes Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436197291-21625-6-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=bp@suse.de \
--cc=dsahern@gmail.com \
--cc=dzickus@redhat.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome