Skip to contentSkip to conversation

perf kvm: fix sample_type manipulation

PATCH In review Adrian Hunter 4 participants 8 messages Sep 6, 2013 – Sep 12, 2013 perf events

lore
Share & tools
lore

Adrian Hunter

author reviewer
#0 lore raw

v2 cover perf kvm: fix sample_type manipulation

Hi

Here is the sample identifier fix (version 2).

Changes in V2:
perf tools: fix id pos in perf_evlist__open()
New patch
perf kvm: fix sample_type manipulation
Remove setting of id_pos

Adrian Hunter (2):
perf tools: fix id pos in perf_evlist__open() perf kvm: fix sample_type manipulation

 tools/perf/builtin-kvm.c | 18 +++++++++---------
 tools/perf/util/evlist.c | 12 ++++++++++++
 2 files changed, 21 insertions(+), 9 deletions(-)

Regards
Adrian

author reviewer
#1 lore raw

PATCH v2 1/2 perf tools: fix id pos in perf_evlist__open()

Ensure the id_pos is correct when perf_evlist__open() is used.

---
 tools/perf/util/evlist.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tools/perf/util/evlist.c +12 -0
index b8727ae..005c0eb 100644
@@ -64,6 +64,16 @@ void perf_evlist__set_id_pos(struct perf_evlist *evlist)
 	evlist->is_pos = first->is_pos;
 }
 
+static void perf_evlist__update_id_pos(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel;
+
+	list_for_each_entry(evsel, &evlist->entries, node)
+		perf_evsel__calc_id_pos(evsel);
+
+	perf_evlist__set_id_pos(evlist);
+}
+
 static void perf_evlist__purge(struct perf_evlist *evlist)
 {
 	struct perf_evsel *pos, *n;
@@ -915,6 +925,8 @@ int perf_evlist__open(struct perf_evlist *evlist)
 	struct perf_evsel *evsel;
 	int err;
 
+	perf_evlist__update_id_pos(evlist);
+
 	list_for_each_entry(evsel, &evlist->entries, node) {
 		err = perf_evsel__open(evsel, evlist->cpus, evlist->threads);
 		if (err < 0)
Signature · 1 line
1.7.11.7
#2 lore raw

Re: [PATCH V2 1/2] perf tools: fix id pos in perf_evlist__open()

Quoted 2 lines · Adrian Hunter

Ensure the id_pos is correct when perf_evlist__open() is used.

The commit log should reference 7556257 and breakage of 'kvm stat live'; helps identify patches when backporting.

Other than that this patch fixes the problem.

Tested-by and Acked-by David Ahern <[email protected]>

Quoted 37 lines
---
  tools/perf/util/evlist.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)
tools/perf/util/evlist.c +12 -0
index b8727ae..005c0eb 100644
@@ -64,6 +64,16 @@ void perf_evlist__set_id_pos(struct perf_evlist *evlist)
  	evlist->is_pos = first->is_pos;
  }
 
+static void perf_evlist__update_id_pos(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel;
+
+	list_for_each_entry(evsel, &evlist->entries, node)
+		perf_evsel__calc_id_pos(evsel);
+
+	perf_evlist__set_id_pos(evlist);
+}
+
  static void perf_evlist__purge(struct perf_evlist *evlist)
  {
  	struct perf_evsel *pos, *n;
@@ -915,6 +925,8 @@ int perf_evlist__open(struct perf_evlist *evlist)
  	struct perf_evsel *evsel;
  	int err;
 
+	perf_evlist__update_id_pos(evlist);
+
  	list_for_each_entry(evsel, &evlist->entries, node) {
  		err = perf_evsel__open(evsel, evlist->cpus, evlist->threads);
  		if (err < 0)
#3 lore raw

Re: [PATCH V2 1/2] perf tools: fix id pos in perf_evlist__open()

Em Sat, Sep 07, 2013 at 08:20:10AM -0600, David Ahern escreveu:

Quoted 8 lines · Adrian Hunter
Quoted 2 lines

Ensure the id_pos is correct when perf_evlist__open() is used.

The commit log should reference 7556257 and breakage of 'kvm stat live'; helps identify patches when backporting.

Other than that this patch fixes the problem.

Thanks, I'm ammending the commit message log.

Quoted 39 lines

Tested-by and Acked-by David Ahern <[email protected]>

Quoted 37 lines
---
 tools/perf/util/evlist.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tools/perf/util/evlist.c +12 -0
index b8727ae..005c0eb 100644
@@ -64,6 +64,16 @@ void perf_evlist__set_id_pos(struct perf_evlist *evlist)
 	evlist->is_pos = first->is_pos;
 }
 
+static void perf_evlist__update_id_pos(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel;
+
+	list_for_each_entry(evsel, &evlist->entries, node)
+		perf_evsel__calc_id_pos(evsel);
+
+	perf_evlist__set_id_pos(evlist);
+}
+
 static void perf_evlist__purge(struct perf_evlist *evlist)
 {
 	struct perf_evsel *pos, *n;
@@ -915,6 +925,8 @@ int perf_evlist__open(struct perf_evlist *evlist)
 	struct perf_evsel *evsel;
 	int err;
 
+	perf_evlist__update_id_pos(evlist);
+
 	list_for_each_entry(evsel, &evlist->entries, node) {
 		err = perf_evsel__open(evsel, evlist->cpus, evlist->threads);
 		if (err < 0)
#4 lore raw

[tip:perf/urgent] perf evlist: Fix id pos in perf_evlist__open()

In reply to Adrian Hunter
perf evlist: Fix id pos in perf_evlist__open()
Commit-ID:  733cd2fe197a0c696c54916f7395451c0da9b867
Gitweb:     http://git.kernel.org/tip/733cd2fe197a0c696c54916f7395451c0da9b867
Author:     Adrian Hunter <[email protected]>
AuthorDate: Fri, 6 Sep 2013 22:40:11 +0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 9 Sep 2013 15:51:44 -0300

perf evlist: Fix id pos in perf_evlist__open()

Ensure the id_pos is correct when perf_evlist__open() is used.

This fixes a problem introduced in 7556257 that broke 'perf kvm stat live' in that this tool wasn't updated to use the sample_type bits setting helpers.

---
 tools/perf/util/evlist.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tools/perf/util/evlist.c +12 -0
index 7101283..f9f77be 100644
@@ -64,6 +64,16 @@ void perf_evlist__set_id_pos(struct perf_evlist *evlist)
 	evlist->is_pos = first->is_pos;
 }
 
+static void perf_evlist__update_id_pos(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel;
+
+	list_for_each_entry(evsel, &evlist->entries, node)
+		perf_evsel__calc_id_pos(evsel);
+
+	perf_evlist__set_id_pos(evlist);
+}
+
 static void perf_evlist__purge(struct perf_evlist *evlist)
 {
 	struct perf_evsel *pos, *n;
@@ -920,6 +930,8 @@ int perf_evlist__open(struct perf_evlist *evlist)
 	struct perf_evsel *evsel;
 	int err;
 
+	perf_evlist__update_id_pos(evlist);
+
 	list_for_each_entry(evsel, &evlist->entries, node) {
 		err = perf_evsel__open(evsel, evlist->cpus, evlist->threads);
 		if (err < 0)
author reviewer
#5 lore raw

PATCH v2 2/2 perf kvm: fix sample_type manipulation

In reply to Adrian Hunter

Manipulating the sample_type of an evsel requires
the use of:
perf_evsel__set_sample_bit()
and perf_evsel__reset_sample_bit()

---
 tools/perf/builtin-kvm.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
tools/perf/builtin-kvm.c +9 -9
index 47b3540..935d522 100644
@@ -1165,16 +1165,16 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm)
 		struct perf_event_attr *attr = &pos->attr;
 
 		/* make sure these *are* set */
-		attr->sample_type |= PERF_SAMPLE_TID;
-		attr->sample_type |= PERF_SAMPLE_TIME;
-		attr->sample_type |= PERF_SAMPLE_CPU;
-		attr->sample_type |= PERF_SAMPLE_RAW;
+		perf_evsel__set_sample_bit(pos, TID);
+		perf_evsel__set_sample_bit(pos, TIME);
+		perf_evsel__set_sample_bit(pos, CPU);
+		perf_evsel__set_sample_bit(pos, RAW);
 		/* make sure these are *not*; want as small a sample as possible */
-		attr->sample_type &= ~PERF_SAMPLE_PERIOD;
-		attr->sample_type &= ~PERF_SAMPLE_IP;
-		attr->sample_type &= ~PERF_SAMPLE_CALLCHAIN;
-		attr->sample_type &= ~PERF_SAMPLE_ADDR;
-		attr->sample_type &= ~PERF_SAMPLE_READ;
+		perf_evsel__reset_sample_bit(pos, PERIOD);
+		perf_evsel__reset_sample_bit(pos, IP);
+		perf_evsel__reset_sample_bit(pos, CALLCHAIN);
+		perf_evsel__reset_sample_bit(pos, ADDR);
+		perf_evsel__reset_sample_bit(pos, READ);
 		attr->mmap = 0;
 		attr->comm = 0;
 		attr->task = 0;
Signature · 1 line
1.7.11.7
#7 lore raw

[tip:perf/urgent] perf kvm: Fix sample_type manipulation

In reply to Adrian Hunter
perf kvm: Fix sample_type manipulation
Commit-ID:  e71aa28312b208a14cd87fa61e941ac8c85072f4
Gitweb:     http://git.kernel.org/tip/e71aa28312b208a14cd87fa61e941ac8c85072f4
Author:     Adrian Hunter <[email protected]>
AuthorDate: Fri, 6 Sep 2013 22:40:12 +0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 9 Sep 2013 16:13:11 -0300

perf kvm: Fix sample_type manipulation

Manipulating the sample_type of an evsel requires the use of:

perf_evsel__set_sample_bit()
and perf_evsel__reset_sample_bit()

---
 tools/perf/builtin-kvm.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
tools/perf/builtin-kvm.c +9 -9
index 47b3540..935d522 100644
@@ -1165,16 +1165,16 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm)
 		struct perf_event_attr *attr = &pos->attr;
 
 		/* make sure these *are* set */
-		attr->sample_type |= PERF_SAMPLE_TID;
-		attr->sample_type |= PERF_SAMPLE_TIME;
-		attr->sample_type |= PERF_SAMPLE_CPU;
-		attr->sample_type |= PERF_SAMPLE_RAW;
+		perf_evsel__set_sample_bit(pos, TID);
+		perf_evsel__set_sample_bit(pos, TIME);
+		perf_evsel__set_sample_bit(pos, CPU);
+		perf_evsel__set_sample_bit(pos, RAW);
 		/* make sure these are *not*; want as small a sample as possible */
-		attr->sample_type &= ~PERF_SAMPLE_PERIOD;
-		attr->sample_type &= ~PERF_SAMPLE_IP;
-		attr->sample_type &= ~PERF_SAMPLE_CALLCHAIN;
-		attr->sample_type &= ~PERF_SAMPLE_ADDR;
-		attr->sample_type &= ~PERF_SAMPLE_READ;
+		perf_evsel__reset_sample_bit(pos, PERIOD);
+		perf_evsel__reset_sample_bit(pos, IP);
+		perf_evsel__reset_sample_bit(pos, CALLCHAIN);
+		perf_evsel__reset_sample_bit(pos, ADDR);
+		perf_evsel__reset_sample_bit(pos, READ);
 		attr->mmap = 0;
 		attr->comm = 0;
 		attr->task = 0;