perf data: Support single perf.data file directory

Support directory output that contains a regular perf.data file, named
"data". By default the directory is named perf.data i.e.
	perf.data
	└── data

Most of the infrastructure to support a directory is already there. This
patch makes the changes needed to support the format above.

Presently there is no 'perf record' option to output a directory.

This is preparation for adding support for putting a copy of /proc/kcore in
the directory.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lore.kernel.org/lkml/20191004083121.12182-5-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Adrian Hunter
2019-10-04 11:31:20 +03:00
committed by Arnaldo Carvalho de Melo
parent 01e97a59ea
commit 46e201efa1
4 changed files with 43 additions and 2 deletions

View File

@@ -76,6 +76,13 @@ int perf_data__open_dir(struct perf_data *data)
DIR *dir;
int nr = 0;
/*
* Directory containing a single regular perf data file which is already
* open, means there is nothing more to do here.
*/
if (perf_data__is_single_file(data))
return 0;
if (WARN_ON(!data->is_dir))
return -EINVAL;
@@ -406,7 +413,7 @@ unsigned long perf_data__size(struct perf_data *data)
u64 size = data->file.size;
int i;
if (!data->is_dir)
if (perf_data__is_single_file(data))
return size;
for (i = 0; i < data->dir.nr; i++) {