linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Clark Williams <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Song Liu <songliubraving@fb.com>
Subject: [PATCH 4/8] perf parse-events: Add parse_events_option() variant that creates evlist
Date: Wed, 29 Apr 2020 10:11:02 -0300	[thread overview]
Message-ID: <20200429131106.27974-5-acme@kernel.org> (raw)
In-Reply-To: <20200429131106.27974-1-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

For the upcoming --switch-output-event option we want to create the side
band event, populate it with the specified events and then, if it is
present multiple times, go on adding to it, then, if the BPF tracking is
required, use the first event to set its attr.bpf_event to get those
PERF_RECORD_BPF_EVENT metadata events too.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Link: http://lore.kernel.org/lkml/20200427211935.25789-6-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/parse-events.c | 23 +++++++++++++++++++++++
 tools/perf/util/parse-events.h |  1 +
 2 files changed, 24 insertions(+)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 10107747b361..5795f3a8f71c 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2190,6 +2190,29 @@ int parse_events_option(const struct option *opt, const char *str,
 	return ret;
 }
 
+int parse_events_option_new_evlist(const struct option *opt, const char *str, int unset)
+{
+	struct evlist **evlistp = opt->value;
+	int ret;
+
+	if (*evlistp == NULL) {
+		*evlistp = evlist__new();
+
+		if (*evlistp == NULL) {
+			fprintf(stderr, "Not enough memory to create evlist\n");
+			return -1;
+		}
+	}
+
+	ret = parse_events_option(opt, str, unset);
+	if (ret) {
+		evlist__delete(*evlistp);
+		*evlistp = NULL;
+	}
+
+	return ret;
+}
+
 static int
 foreach_evsel_in_last_glob(struct evlist *evlist,
 			   int (*func)(struct evsel *evsel,
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 27596cbd0ba0..6ead9661238c 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -31,6 +31,7 @@ bool have_tracepoints(struct list_head *evlist);
 const char *event_type(int type);
 
 int parse_events_option(const struct option *opt, const char *str, int unset);
+int parse_events_option_new_evlist(const struct option *opt, const char *str, int unset);
 int parse_events(struct evlist *evlist, const char *str,
 		 struct parse_events_error *error);
 int parse_events_terms(struct list_head *terms, const char *str);
-- 
2.21.1


  parent reply	other threads:[~2020-04-29 13:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29 13:10 [RFC PATCHSET v2] Implement --switch-output-event Arnaldo Carvalho de Melo
2020-04-29 13:10 ` [PATCH 1/8] perf record: Move sb_evlist to 'struct record' Arnaldo Carvalho de Melo
2020-05-08 13:05   ` [tip: perf/core] " tip-bot2 for Arnaldo Carvalho de Melo
2020-04-29 13:11 ` [PATCH 2/8] perf top: Move sb_evlist to 'struct perf_top' Arnaldo Carvalho de Melo
2020-05-08 13:05   ` [tip: perf/core] " tip-bot2 for Arnaldo Carvalho de Melo
2020-04-29 13:11 ` [PATCH 3/8] perf bpf: Decouple creating the evlist from adding the SB event Arnaldo Carvalho de Melo
2020-04-30  9:04   ` Jiri Olsa
2020-04-30 13:39     ` Arnaldo Carvalho de Melo
2020-05-08 13:05   ` [tip: perf/core] " tip-bot2 for Arnaldo Carvalho de Melo
2020-04-29 13:11 ` Arnaldo Carvalho de Melo [this message]
2020-05-08 13:05   ` [tip: perf/core] perf parse-events: Add parse_events_option() variant that creates evlist tip-bot2 for Arnaldo Carvalho de Melo
2020-04-29 13:11 ` [PATCH 5/8] perf evlist: Allow reusing the side band thread for more purposes Arnaldo Carvalho de Melo
2020-05-01 11:25   ` Jiri Olsa
2020-05-01 11:31     ` Arnaldo Melo
2020-05-08 13:05   ` [tip: perf/core] " tip-bot2 for Arnaldo Carvalho de Melo
2020-04-29 13:11 ` [PATCH 6/8] libsubcmd: Introduce OPT_CALLBACK_SET() Arnaldo Carvalho de Melo
2020-05-08 13:05   ` [tip: perf/core] " tip-bot2 for Arnaldo Carvalho de Melo
2020-04-29 13:11 ` [PATCH 7/8] perf record: Introduce --switch-output-event Arnaldo Carvalho de Melo
2020-04-29 17:25   ` Ian Rogers
2020-05-11 15:04     ` Arnaldo Carvalho de Melo
2020-05-08 13:05   ` [tip: perf/core] " tip-bot2 for Arnaldo Carvalho de Melo
2020-04-29 13:11 ` [PATCH 8/8] perf record: Move side band evlist setup to separate routine Arnaldo Carvalho de Melo
2020-05-08 13:05   ` [tip: perf/core] " tip-bot2 for Arnaldo Carvalho de Melo
2020-04-30  9:05 ` [RFC PATCHSET v2] Implement --switch-output-event Jiri Olsa

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=20200429131106.27974-5-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=songliubraving@fb.com \
    --cc=tglx@linutronix.de \
    --cc=williams@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).