]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
perf record: Fix perf.data size in no-buildid mode
authorHe Kuang <hekuang@huawei.com>
Thu, 28 May 2015 13:17:30 +0000 (13:17 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 8 Jun 2015 13:30:32 +0000 (10:30 -0300)
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 ]

Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1432819050-30511-1-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-record.c

index 91aa2a3dcf19ebe036867dd46daeb4174d5c1784..d3731cce7c1cc5d498977f31427895487ed723b9 100644 (file)
@@ -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);