All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Alexander Antonov <alexander.antonov@linux.intel.com>,
	Alexei Budankov <abudankov@huawei.com>
Subject: Re: [PATCH core v2] perf data: Adding error message if perf_data__create_dir fails
Date: Tue, 22 Feb 2022 23:06:02 +0100	[thread overview]
Message-ID: <YhVeSsxjpALcANeX@krava> (raw)
In-Reply-To: <20220222091417.11020-1-alexey.v.bayduraev@linux.intel.com>

On Tue, Feb 22, 2022 at 12:14:17PM +0300, Alexey Bayduraev wrote:
> Adding proper return codes for all cases of data directory creation
> failure and adding error message output based on these codes.
> 
> Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

> ---
>  tools/perf/builtin-record.c | 4 +++-
>  tools/perf/util/data.c      | 8 ++++++--
>  2 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 0bc6529814b2..0b4abed555d8 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -1186,8 +1186,10 @@ static int record__mmap_evlist(struct record *rec,
>  
>  	if (record__threads_enabled(rec)) {
>  		ret = perf_data__create_dir(&rec->data, evlist->core.nr_mmaps);
> -		if (ret)
> +		if (ret) {
> +			pr_err("Failed to create data directory: %s\n", strerror(-ret));
>  			return ret;
> +		}
>  		for (i = 0; i < evlist->core.nr_mmaps; i++) {
>  			if (evlist->mmap)
>  				evlist->mmap[i].file = &rec->data.dir.files[i];
> diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
> index f5d260b1df4d..dc5d82ea1c30 100644
> --- a/tools/perf/util/data.c
> +++ b/tools/perf/util/data.c
> @@ -52,12 +52,16 @@ int perf_data__create_dir(struct perf_data *data, int nr)
>  		struct perf_data_file *file = &files[i];
>  
>  		ret = asprintf(&file->path, "%s/data.%d", data->path, i);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			ret = -ENOMEM;
>  			goto out_err;
> +		}
>  
>  		ret = open(file->path, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			ret = -errno;
>  			goto out_err;
> +		}
>  
>  		file->fd = ret;
>  	}
> -- 
> 2.19.0
> 

  reply	other threads:[~2022-02-22 22:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22  9:14 [PATCH core v2] perf data: Adding error message if perf_data__create_dir fails Alexey Bayduraev
2022-02-22 22:06 ` Jiri Olsa [this message]
2022-02-23  0:16   ` Arnaldo Carvalho de Melo

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=YhVeSsxjpALcANeX@krava \
    --to=olsajiri@gmail.com \
    --cc=abudankov@huawei.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.antonov@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexey.v.bayduraev@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.