Skip to contentSkip to conversation

perf report: delay sample_type checks in pipe mode

PATCH In review David Ahern 2 participants 5 messages Jun 11, 2012 – Jun 29, 2012 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf report: delay sample_type checks in pipe mode

The pipeline:
perf record -a -g -o - sleep 5 |perf inject -v -b | perf report -g -i -

generates the warning:
Selected -g but no callchain data. Did you call 'perf record' without -g?

The problem is that the header data is not written to the pipe, so the sample_type has not been available when perf_report__setup_sample_type is called. For pipe mode, record dumps the sample type as part of the synthesized events stream -- perf_event__synthesize_attrs(). Handle this be detecting pipe mode and not doing early sanity checks on sample_type.

---
 tools/perf/builtin-report.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/builtin-report.c +4 -2
index ebcb3e2..9b3e9e9 100644
@@ -246,11 +246,12 @@ static int process_read_event(struct perf_tool *tool,
 	return 0;
 }
 
+/* For pipe mode, sample_type is not currently set */
 static int perf_report__setup_sample_type(struct perf_report *rep)
 {
 	struct perf_session *self = rep->session;
 
-	if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
+	if (!self->fd_pipe && !(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
 		if (sort__has_parent) {
 			ui__error("Selected --sort parent, but no "
 				    "callchain data. Did you call "
@@ -273,7 +274,8 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
 	}
 
 	if (sort__branch_mode == 1) {
-		if (!(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) {
+		if (!self->fd_pipe &&
+		    !(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) {
 			ui__error("Selected -b but no branch data. "
 				  "Did you call perf record without -b?\n");
 			return -1;
Signature · 1 line
1.7.10.1
#1 lore raw
Quoted 11 lines · David Ahern

The pipeline:
perf record -a -g -o - sleep 5 |perf inject -v -b | perf report -g -i -

generates the warning:
Selected -g but no callchain data. Did you call 'perf record' without -g?

The problem is that the header data is not written to the pipe, so the sample_type has not been available when perf_report__setup_sample_type is called. For pipe mode, record dumps the sample type as part of the synthesized events stream -- perf_event__synthesize_attrs(). Handle this be detecting pipe mode and not doing early sanity checks on sample_type.

Slightly different fix. Tim: can you re-test?

David

Quoted 34 lines
---
  tools/perf/builtin-report.c |    6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/builtin-report.c +4 -2
index ebcb3e2..9b3e9e9 100644
@@ -246,11 +246,12 @@ static int process_read_event(struct perf_tool *tool,
  	return 0;
  }
 
+/* For pipe mode, sample_type is not currently set */
  static int perf_report__setup_sample_type(struct perf_report *rep)
  {
  	struct perf_session *self = rep->session;
 
-	if (!(self->sample_type&  PERF_SAMPLE_CALLCHAIN)) {
+	if (!self->fd_pipe&&  !(self->sample_type&  PERF_SAMPLE_CALLCHAIN)) {
  		if (sort__has_parent) {
  			ui__error("Selected --sort parent, but no "
  				    "callchain data. Did you call "
@@ -273,7 +274,8 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
  	}
 
  	if (sort__branch_mode == 1) {
-		if (!(self->sample_type&  PERF_SAMPLE_BRANCH_STACK)) {
+		if (!self->fd_pipe&&
+		    !(self->sample_type&  PERF_SAMPLE_BRANCH_STACK)) {
  			ui__error("Selected -b but no branch data. "
  				  "Did you call perf record without -b?\n");
  			return -1;
#2 lore raw
Quoted 13 lines · David Ahern
Quoted 11 lines · David Ahern

The pipeline:
perf record -a -g -o - sleep 5 |perf inject -v -b | perf report -g -i -

generates the warning:
Selected -g but no callchain data. Did you call 'perf record' without -g?

The problem is that the header data is not written to the pipe, so the sample_type has not been available when perf_report__setup_sample_type is called. For pipe mode, record dumps the sample type as part of the synthesized events stream -- perf_event__synthesize_attrs(). Handle this be detecting pipe mode and not doing early sanity checks on sample_type.

Quoted 4 lines

Slightly different fix. Tim: can you re-test?

David

Works for me.

Tim

#3 lore raw
In reply to David Ahern

Hi Arnaldo

Quoted 6 lines · David Ahern

The pipeline:
perf record -a -g -o - sleep 5 |perf inject -v -b | perf report -g -i -

generates the warning:
Selected -g but no callchain data. Did you call 'perf record' without -g?

Quoted 7 lines

The problem is that the header data is not written to the pipe, so the sample_type has not been available when perf_report__setup_sample_type is called. For pipe mode, record dumps the sample type as part of the synthesized events stream -- perf_event__synthesize_attrs(). Handle this be detecting pipe mode and not doing early sanity checks on sample_type.

Haven't seen this one come through your queues.

David

Quoted 33 lines
---
  tools/perf/builtin-report.c |    6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/builtin-report.c +4 -2
index ebcb3e2..9b3e9e9 100644
@@ -246,11 +246,12 @@ static int process_read_event(struct perf_tool *tool,
  	return 0;
  }
 
+/* For pipe mode, sample_type is not currently set */
  static int perf_report__setup_sample_type(struct perf_report *rep)
  {
  	struct perf_session *self = rep->session;
 
-	if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
+	if (!self->fd_pipe && !(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
  		if (sort__has_parent) {
  			ui__error("Selected --sort parent, but no "
  				    "callchain data. Did you call "
@@ -273,7 +274,8 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
  	}
 
  	if (sort__branch_mode == 1) {
-		if (!(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) {
+		if (!self->fd_pipe &&
+		    !(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) {
  			ui__error("Selected -b but no branch data. "
  				  "Did you call perf record without -b?\n");
  			return -1;
#4 lore raw

[tip:perf/core] perf report: Delay sample_type checks in pipe mode

In reply to David Ahern
Commit-ID:  300aa941650e98966ad85847527537df5b11a87e
Gitweb:     http://git.kernel.org/tip/300aa941650e98966ad85847527537df5b11a87e
Author:     David Ahern <[email protected]>
AuthorDate: Mon, 11 Jun 2012 13:48:41 -0600
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 27 Jun 2012 13:19:14 -0300

perf report: Delay sample_type checks in pipe mode

The pipeline:
perf record -a -g -o - sleep 5 |perf inject -v -b | perf report -g -i -

generates the warning:
Selected -g but no callchain data. Did you call 'perf record' without -g?

The problem is that the header data is not written to the pipe, so the sample_type has not been available when perf_report__setup_sample_type is called. For pipe mode, record dumps the sample type as part of the synthesized events stream -- perf_event__synthesize_attrs(). Handle this be detecting pipe mode and not doing early sanity checks on sample_type.

---
 tools/perf/builtin-report.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
tools/perf/builtin-report.c +4 -2
index 40b0ffc..69b1c11 100644
@@ -245,11 +245,12 @@ static int process_read_event(struct perf_tool *tool,
 	return 0;
 }
 
+/* For pipe mode, sample_type is not currently set */
 static int perf_report__setup_sample_type(struct perf_report *rep)
 {
 	struct perf_session *self = rep->session;
 
-	if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
+	if (!self->fd_pipe && !(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
 		if (sort__has_parent) {
 			ui__error("Selected --sort parent, but no "
 				    "callchain data. Did you call "
@@ -272,7 +273,8 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
 	}
 
 	if (sort__branch_mode == 1) {
-		if (!(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) {
+		if (!self->fd_pipe &&
+		    !(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) {
 			ui__error("Selected -b but no branch data. "
 				  "Did you call perf record without -b?\n");
 			return -1;