Skip to contentSkip to conversation

perf record: Fix perf.data size in no-buildid mode

PATCH Applied He Kuang 3 participants 4 messages May 28, 2015 – Jun 9, 2015 perf events

lore
Share & tools
lore

He Kuang

author
#0 lore raw

PATCH 1/1 perf record: Fix perf.data size in no-buildid mode

The size of perf.data is missing update in no-buildid mode, which gives wrong output result.

Before this patch:

  $ perf.perf record -B -e syscalls:sys_enter_open uname
  Linux
  [ perf record: Woken up 1 times to  write data ]
  [ perf record: Captured and wrote 0.000 MB perf.data ]

After this patch:

  $ perf.perf record -B -e syscalls:sys_enter_open uname
  Linux
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.001 MB perf.data ]
---
 tools/perf/builtin-record.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/perf/builtin-record.c +2 -4
index 91aa2a3..d3731cc 100644
@@ -345,12 +345,9 @@ static int process_buildids(struct record *rec)
 	struct perf_data_file *file  = &rec->file;
 	struct perf_session *session = rec->session;
 
-	u64 size = lseek(perf_data_file__fd(file), 0, SEEK_CUR);
-	if (size == 0)
+	if (file->size == 0)
 		return 0;
 
-	file->size = size;
-
 	/*
 	 * During this process, it'll load kernel map and replace the
 	 * dso->long_name to a real pathname it found.  In this case
@@ -719,6 +716,7 @@ out_child:
 
 	if (!err && !file->is_pipe) {
 		rec->session->header.data_size += rec->bytes_written;
+		file->size = lseek(perf_data_file__fd(file), 0, SEEK_CUR);
 
 		if (!rec->no_buildid) {
 			process_buildids(rec);
Signature · 1 line
1.8.5.2
author
#1 lore raw

ping..

Quoted 49 lines · He Kuang

The size of perf.data is missing update in no-buildid mode, which gives wrong output result.

Before this patch:

   $ perf.perf record -B -e syscalls:sys_enter_open uname
   Linux
   [ perf record: Woken up 1 times to  write data ]
   [ perf record: Captured and wrote 0.000 MB perf.data ]

After this patch:

   $ perf.perf record -B -e syscalls:sys_enter_open uname
   Linux
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.001 MB perf.data ]
---
  tools/perf/builtin-record.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
tools/perf/builtin-record.c +2 -4
index 91aa2a3..d3731cc 100644
@@ -345,12 +345,9 @@ static int process_buildids(struct record *rec)
  	struct perf_data_file *file  = &rec->file;
  	struct perf_session *session = rec->session;
 
-	u64 size = lseek(perf_data_file__fd(file), 0, SEEK_CUR);
-	if (size == 0)
+	if (file->size == 0)
  		return 0;
 
-	file->size = size;
-
  	/*
  	 * During this process, it'll load kernel map and replace the
  	 * dso->long_name to a real pathname it found.  In this case
@@ -719,6 +716,7 @@ out_child:
 
  	if (!err && !file->is_pipe) {
  		rec->session->header.data_size += rec->bytes_written;
+		file->size = lseek(perf_data_file__fd(file), 0, SEEK_CUR);
 
  		if (!rec->no_buildid) {
  			process_buildids(rec);
maintainer Applied
#2 lore raw

Em Fri, Jun 05, 2015 at 07:40:16PM +0800, He Kuang escreveu:

Quoted 2 lines

ping..

Thanks, applied.

- Arnaldo

Quoted 50 lines · He Kuang
Quoted 49 lines

The size of perf.data is missing update in no-buildid mode, which gives wrong output result.

Before this patch:

  $ perf.perf record -B -e syscalls:sys_enter_open uname
  Linux
  [ perf record: Woken up 1 times to  write data ]
  [ perf record: Captured and wrote 0.000 MB perf.data ]

After this patch:

  $ perf.perf record -B -e syscalls:sys_enter_open uname
  Linux
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.001 MB perf.data ]
---
 tools/perf/builtin-record.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/perf/builtin-record.c +2 -4
index 91aa2a3..d3731cc 100644
@@ -345,12 +345,9 @@ static int process_buildids(struct record *rec)
 	struct perf_data_file *file  = &rec->file;
 	struct perf_session *session = rec->session;
 
-	u64 size = lseek(perf_data_file__fd(file), 0, SEEK_CUR);
-	if (size == 0)
+	if (file->size == 0)
 		return 0;
 
-	file->size = size;
-
 	/*
 	 * During this process, it'll load kernel map and replace the
 	 * dso->long_name to a real pathname it found.  In this case
@@ -719,6 +716,7 @@ out_child:
 
 	if (!err && !file->is_pipe) {
 		rec->session->header.data_size += rec->bytes_written;
+		file->size = lseek(perf_data_file__fd(file), 0, SEEK_CUR);
 
 		if (!rec->no_buildid) {
 			process_buildids(rec);
#3 lore raw
In reply to He Kuang
perf record: Fix perf.data size in no-buildid mode
Commit-ID:  457ae94ae047330e75c13f28ead6de31eab245ed
Gitweb:     http://git.kernel.org/tip/457ae94ae047330e75c13f28ead6de31eab245ed
Author:     He Kuang <[email protected]>
AuthorDate: Thu, 28 May 2015 13:17:30 +0000
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 8 Jun 2015 10:30:32 -0300

perf record: Fix perf.data size in no-buildid mode

The size of perf.data is missing update in no-buildid mode, which gives wrong output result.

Before this patch:

  $ perf.perf record -B -e syscalls:sys_enter_open uname
  Linux
  [ perf record: Woken up 1 times to  write data ]
  [ perf record: Captured and wrote 0.000 MB perf.data ]

After this patch:

  $ perf.perf record -B -e syscalls:sys_enter_open uname
  Linux
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.001 MB perf.data ]
---
 tools/perf/builtin-record.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/perf/builtin-record.c +2 -4
index 91aa2a3..d3731cc 100644
@@ -345,12 +345,9 @@ static int process_buildids(struct record *rec)
 	struct perf_data_file *file  = &rec->file;
 	struct perf_session *session = rec->session;
 
-	u64 size = lseek(perf_data_file__fd(file), 0, SEEK_CUR);
-	if (size == 0)
+	if (file->size == 0)
 		return 0;
 
-	file->size = size;
-
 	/*
 	 * During this process, it'll load kernel map and replace the
 	 * dso->long_name to a real pathname it found.  In this case
@@ -719,6 +716,7 @@ out_child:
 
 	if (!err && !file->is_pipe) {
 		rec->session->header.data_size += rec->bytes_written;
+		file->size = lseek(perf_data_file__fd(file), 0, SEEK_CUR);
 
 		if (!rec->no_buildid) {
 			process_buildids(rec);