All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 22/43] perf tools: Add event_update event cpus type
Date: Thu, 17 Dec 2015 16:47:03 -0300	[thread overview]
Message-ID: <1450381644-25674-23-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1450381644-25674-1-git-send-email-acme@kernel.org>

From: Jiri Olsa <jolsa@kernel.org>

Adding the cpumask 'event update' event, that stores/transfer the
cpumask for a event.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Kan Liang <kan.liang@intel.com>
Cc: 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/1445784728-21732-25-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/event_update.c | 29 ++++++++++++++++++++++++++++
 tools/perf/util/event.h         |  5 +++++
 tools/perf/util/header.c        | 42 +++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/header.h        |  3 +++
 4 files changed, 79 insertions(+)

diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.c
index 482b89650bbe..012eab5d1df1 100644
--- a/tools/perf/tests/event_update.c
+++ b/tools/perf/tests/event_update.c
@@ -53,6 +53,29 @@ static int process_event_name(struct perf_tool *tool,
 	return 0;
 }
 
+static int process_event_cpus(struct perf_tool *tool __maybe_unused,
+			      union perf_event *event,
+			      struct perf_sample *sample __maybe_unused,
+			      struct machine *machine __maybe_unused)
+{
+	struct event_update_event *ev = (struct event_update_event*) event;
+	struct event_update_event_cpus *ev_data;
+	struct cpu_map *map;
+
+	ev_data = (struct event_update_event_cpus*) ev->data;
+
+	map = cpu_map__new_data(&ev_data->cpus);
+
+	TEST_ASSERT_VAL("wrong id", ev->id == 123);
+	TEST_ASSERT_VAL("wrong type", ev->type == PERF_EVENT_UPDATE__CPUS);
+	TEST_ASSERT_VAL("wrong cpus", map->nr == 3);
+	TEST_ASSERT_VAL("wrong cpus", map->map[0] == 1);
+	TEST_ASSERT_VAL("wrong cpus", map->map[1] == 2);
+	TEST_ASSERT_VAL("wrong cpus", map->map[2] == 3);
+	cpu_map__put(map);
+	return 0;
+}
+
 int test__event_update(int subtest __maybe_unused)
 {
 	struct perf_evlist *evlist;
@@ -84,5 +107,11 @@ int test__event_update(int subtest __maybe_unused)
 	TEST_ASSERT_VAL("failed to synthesize attr update name",
 			!perf_event__synthesize_event_update_name(&tmp.tool, evsel, process_event_name));
 
+	evsel->own_cpus = cpu_map__new("1,2,3");
+
+	TEST_ASSERT_VAL("failed to synthesize attr update cpus",
+			!perf_event__synthesize_event_update_cpus(&tmp.tool, evsel, process_event_cpus));
+
+	cpu_map__put(evsel->own_cpus);
 	return 0;
 }
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 235196b575d6..b7ffb7ee9971 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -312,6 +312,11 @@ enum {
 	PERF_EVENT_UPDATE__UNIT  = 0,
 	PERF_EVENT_UPDATE__SCALE = 1,
 	PERF_EVENT_UPDATE__NAME  = 2,
+	PERF_EVENT_UPDATE__CPUS  = 3,
+};
+
+struct event_update_event_cpus {
+	struct cpu_map_data cpus;
 };
 
 struct event_update_event_scale {
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index cd3d005a34af..79d3eb984db7 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2762,6 +2762,38 @@ perf_event__synthesize_event_update_name(struct perf_tool *tool,
 	return err;
 }
 
+int
+perf_event__synthesize_event_update_cpus(struct perf_tool *tool,
+					struct perf_evsel *evsel,
+					perf_event__handler_t process)
+{
+	size_t size = sizeof(struct event_update_event);
+	struct event_update_event *ev;
+	int max, err;
+	u16 type;
+
+	if (!evsel->own_cpus)
+		return 0;
+
+	ev = cpu_map_data__alloc(evsel->own_cpus, &size, &type, &max);
+	if (!ev)
+		return -ENOMEM;
+
+	ev->header.type = PERF_RECORD_EVENT_UPDATE;
+	ev->header.size = (u16)size;
+	ev->type = PERF_EVENT_UPDATE__CPUS;
+	ev->id   = evsel->id[0];
+
+	cpu_map_data__synthesize((struct cpu_map_data *) ev->data,
+				 evsel->own_cpus,
+				 type, max);
+
+	err = process(tool, (union perf_event*) ev, NULL, NULL);
+	free(ev);
+	return err;
+}
+
+
 int perf_event__synthesize_attrs(struct perf_tool *tool,
 				   struct perf_session *session,
 				   perf_event__handler_t process)
@@ -2827,8 +2859,10 @@ int perf_event__process_event_update(struct perf_tool *tool __maybe_unused,
 {
 	struct event_update_event *ev = &event->event_update;
 	struct event_update_event_scale *ev_scale;
+	struct event_update_event_cpus *ev_cpus;
 	struct perf_evlist *evlist;
 	struct perf_evsel *evsel;
+	struct cpu_map *map;
 
 	if (!pevlist || *pevlist == NULL)
 		return -EINVAL;
@@ -2849,6 +2883,14 @@ int perf_event__process_event_update(struct perf_tool *tool __maybe_unused,
 	case PERF_EVENT_UPDATE__SCALE:
 		ev_scale = (struct event_update_event_scale *) ev->data;
 		evsel->scale = ev_scale->scale;
+	case PERF_EVENT_UPDATE__CPUS:
+		ev_cpus = (struct event_update_event_cpus *) ev->data;
+
+		map = cpu_map__new_data(&ev_cpus->cpus);
+		if (map)
+			evsel->own_cpus = map;
+		else
+			pr_err("failed to get event_update cpus\n");
 	default:
 		break;
 	}
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 51cf566a0835..a1bc0c5706a3 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -114,6 +114,9 @@ int perf_event__synthesize_event_update_scale(struct perf_tool *tool,
 int perf_event__synthesize_event_update_name(struct perf_tool *tool,
 					     struct perf_evsel *evsel,
 					     perf_event__handler_t process);
+int perf_event__synthesize_event_update_cpus(struct perf_tool *tool,
+					     struct perf_evsel *evsel,
+					     perf_event__handler_t process);
 int perf_event__process_attr(struct perf_tool *tool, union perf_event *event,
 			     struct perf_evlist **pevlist);
 int perf_event__process_event_update(struct perf_tool *tool __maybe_unused,
-- 
2.1.0


  parent reply	other threads:[~2015-12-17 19:52 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-17 19:46 [GIT PULL 00/43] perf/core new feature: 'perf stat record/report' Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 01/43] perf thread_map: Add thread_map user level event Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 02/43] perf thread_map: Add thread_map event sythesize function Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 03/43] perf thread_map: Add thread_map__new_event function Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 04/43] perf thread_map: Add perf_event__fprintf_thread_map function Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 05/43] perf cpu_map: Add cpu_map user level event Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 06/43] perf cpu_map: Add cpu_map event synthesize function Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 07/43] perf cpu_map: Add cpu_map__new_event function Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 08/43] perf cpu_map: Add perf_event__fprintf_cpu_map function Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 09/43] perf tools: Add stat config user level event Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 10/43] perf tools: Add stat config event synthesize function Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 11/43] perf tools: Add stat config event read function Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 12/43] perf tools: Add stat user level event Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 13/43] perf tools: Add stat event synthesize function Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 14/43] perf tools: Add stat event read function Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 15/43] perf tools: Add stat round user level event Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 16/43] perf tools: Add stat round event synthesize function Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 17/43] perf tools: Add stat events fprintf functions Arnaldo Carvalho de Melo
2015-12-17 19:46 ` [PATCH 18/43] perf tools: Add event_update user level event Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 19/43] perf tools: Add event_update event unit type Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 20/43] perf tools: Add event_update event scale type Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 21/43] perf tools: Add event_update event name type Arnaldo Carvalho de Melo
2015-12-17 19:47 ` Arnaldo Carvalho de Melo [this message]
2015-12-17 19:47 ` [PATCH 23/43] perf tools: Add perf_event__fprintf_event_update function Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 24/43] perf report: Display newly added events in raw dump Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 25/43] perf tools: Introduce stat perf.data header feature Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 26/43] perf stat record: Add record command Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 27/43] perf stat record: Initialize record features Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 28/43] perf stat record: Synthesize stat record data Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 29/43] perf evlist: Export id_add_fd() Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 30/43] perf stat record: Store events IDs in perf data file Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 31/43] perf stat record: Add pipe support for record command Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 32/43] perf stat record: Write stat events on record Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 33/43] perf stat record: Write stat round " Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 34/43] perf stat record: Do not allow record with multiple runs mode Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 35/43] perf stat record: Synthesize event update events Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 36/43] perf stat report: Add report command Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 37/43] perf stat report: Process cpu/threads maps Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 38/43] perf stat report: Process stat config event Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 39/43] perf stat report: Add support to initialize aggr_map from file Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 40/43] perf stat report: Move csv_sep initialization before report command Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 41/43] perf stat report: Process stat and stat round events Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 42/43] perf stat report: Process event update events Arnaldo Carvalho de Melo
2015-12-17 19:47 ` [PATCH 43/43] perf stat report: Allow to override aggr_mode Arnaldo Carvalho de Melo
2015-12-18  8:48 ` [GIT PULL 00/43] perf/core new feature: 'perf stat record/report' Ingo Molnar
2015-12-18  8:55   ` Ingo Molnar
2015-12-18 10:11     ` 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=1450381644-25674-23-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.