* [PATCH core v2] perf data: Adding error message if perf_data__create_dir fails
@ 2022-02-22 9:14 Alexey Bayduraev
2022-02-22 22:06 ` Jiri Olsa
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Bayduraev @ 2022-02-22 9:14 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Jiri Olsa, Namhyung Kim, Alexander Shishkin, Peter Zijlstra,
Ingo Molnar, linux-kernel, Adrian Hunter, Alexander Antonov,
Alexei Budankov
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>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH core v2] perf data: Adding error message if perf_data__create_dir fails
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
2022-02-23 0:16 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Olsa @ 2022-02-22 22:06 UTC (permalink / raw)
To: Alexey Bayduraev
Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Namhyung Kim,
Alexander Shishkin, Peter Zijlstra, Ingo Molnar, linux-kernel,
Adrian Hunter, Alexander Antonov, Alexei Budankov
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH core v2] perf data: Adding error message if perf_data__create_dir fails
2022-02-22 22:06 ` Jiri Olsa
@ 2022-02-23 0:16 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-02-23 0:16 UTC (permalink / raw)
To: Jiri Olsa
Cc: Alexey Bayduraev, Jiri Olsa, Namhyung Kim, Alexander Shishkin,
Peter Zijlstra, Ingo Molnar, linux-kernel, Adrian Hunter,
Alexander Antonov, Alexei Budankov
Em Tue, Feb 22, 2022 at 11:06:02PM +0100, Jiri Olsa escreveu:
> 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, applied.
- Arnaldo
> 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
> >
--
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-23 0:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2022-02-23 0:16 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox