Re: [PATCH core] perf data: Adding error message if perf_data__create_dir fails

From: Bayduraev, Alexey V
Date: Mon Feb 21 2022 - 08:24:40 EST


On 21.02.2022 1:43, Jiri Olsa wrote:
> On Fri, Feb 18, 2022 at 06:23:40PM +0300, Alexey Bayduraev wrote:
>> There is no notification about data directory creation failure. Add it.
>>
>> Signed-off-by: Alexey Bayduraev <alexey.v.bayduraev@xxxxxxxxxxxxxxx>
>> ---
>> tools/perf/builtin-record.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
>> index 0bc6529814b2..0306d5911de2 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(errno));
>
> errno will be misleading in here, because perf_data__create_dir
> calls other syscalls on error path

Mostly I want to output something like:

Failed to create data dir: Too many open files

This will trigger the user to increase the open files limit.
Would it be better to place such message to perf_data__create_dir after
open() syscall?

Regards,
Alexey

>
> jirka
>
>> return ret;
>> + }
>> for (i = 0; i < evlist->core.nr_mmaps; i++) {
>> if (evlist->mmap)
>> evlist->mmap[i].file = &rec->data.dir.files[i];
>> --
>> 2.19.0
>>