Skip to content

Commit

Permalink
perf tools: Improve error reporting
Browse files Browse the repository at this point in the history
In the current version, when using perf record, if something goes
wrong in tools/perf/builtin-record.c:375
  session = perf_session__new(file, false, NULL);

The error message:
"Not enough memory for reading per file header"

is issued. This error message seems to be outdated and is not very
helpful. This patch proposes to replace this error message by
"Perf session creation failed"

I believe this issue has been brought to lkml:
https://lkml.org/lkml/2014/2/24/458
although this patch only tackles a (small) part of the issue.

Additionnaly, this patch improves error reporting in
tools/perf/util/data.c open_file_write.

Currently, if the call to open fails, the user is unaware of it.
This patch logs the error, before returning the error code to
the caller.

Reported-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Adrien BAK <adrien.bak@metascale.org>
Link: http://lkml.kernel.org/r/1397786443.3093.4.camel@beast
[ Reorganize the changelog into paragraphs ]
[ Added empty line after fd declaration in open_file_write ]
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
  • Loading branch information
Adrien BAK authored and Jiri Olsa committed Apr 19, 2014
1 parent 922d0e4 commit ffa9188
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)

session = perf_session__new(file, false, NULL);
if (session == NULL) {
pr_err("Not enough memory for reading perf file header\n");
pr_err("Perf session creation failed.\n");
return -1;
}

Expand Down
9 changes: 8 additions & 1 deletion tools/perf/util/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,17 @@ static int open_file_read(struct perf_data_file *file)

static int open_file_write(struct perf_data_file *file)
{
int fd;

if (check_backup(file))
return -1;

return open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR);
fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR);

if (fd < 0)
pr_err("failed to open %s : %s\n", file->path, strerror(errno));

return fd;
}

static int open_file(struct perf_data_file *file)
Expand Down

0 comments on commit ffa9188

Please sign in to comment.