Linux-perf-users Archive on
 help / color / Atom feed
From: Adrien BAK <>
To:, Jiri Olsa <>
Subject: [PATCH] Error reporting improvement (updated)
Date: Fri, 18 Apr 2014 11:00:43 +0900
Message-ID: <1397786443.3093.4.camel@beast> (raw)

Update : I resend this patch due to my email client behaving. I added the
reported-by line Will Deacon added in the original discussion.

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 propose to replace this error message by
"Perf session creation failed"

I believe this issue has been brought to lkml :
although this patch only tackle 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.

Signed-off-by: Adrien BAK <>
Reported-by: Will Deacon <>
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index eb524f9..8ce62ef 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -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;
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 1fbcd8b..ff2ced7 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -86,10 +86,16 @@ 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)


             reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-18  2:00 Adrien BAK [this message]
2014-04-18  8:41 ` Peter Zijlstra
2014-04-18 10:25   ` Jiri Olsa
2014-04-18  4:59 Adrien BAK

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397786443.3093.4.camel@beast \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-perf-users Archive on

Archives are clonable:
	git clone --mirror linux-perf-users/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-perf-users linux-perf-users/ \
	public-inbox-index linux-perf-users

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone