提交 46e201ef 编写于 作者: A Adrian Hunter 提交者: Arnaldo Carvalho de Melo

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: NAdrian Hunter <adrian.hunter@intel.com>
Reviewed-by: NJiri Olsa <jolsa@kernel.org>
Link: http://lore.kernel.org/lkml/20191004083121.12182-5-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 01e97a59
perf.data directory format
DISCLAIMER This is not ABI yet and is subject to possible change
in following versions of perf. We will remove this
disclaimer once the directory format soaks in.
This document describes the on-disk perf.data directory format.
The layout is described by HEADER_DIR_FORMAT feature.
Currently it holds only version number (0):
HEADER_DIR_FORMAT = 24
struct {
uint64_t version;
}
The current only version value 0 means that:
- there is a single perf.data file named 'data' within the directory.
e.g.
$ tree -ps perf.data
perf.data
└── [-rw------- 25912] data
Future versions are expected to describe different data files
layout according to special needs.
......@@ -537,7 +537,7 @@ static int record__process_auxtrace(struct perf_tool *tool,
size_t padding;
u8 pad[8] = {0};
if (!perf_data__is_pipe(data) && !perf_data__is_dir(data)) {
if (!perf_data__is_pipe(data) && perf_data__is_single_file(data)) {
off_t file_offset;
int fd = perf_data__fd(data);
int err;
......
......@@ -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++) {
......
......@@ -10,6 +10,7 @@ enum perf_data_mode {
};
enum perf_dir_version {
PERF_DIR_SINGLE_FILE = 0,
PERF_DIR_VERSION = 1,
};
......@@ -54,6 +55,11 @@ static inline bool perf_data__is_dir(struct perf_data *data)
return data->is_dir;
}
static inline bool perf_data__is_single_file(struct perf_data *data)
{
return data->dir.version == PERF_DIR_SINGLE_FILE;
}
static inline int perf_data__fd(struct perf_data *data)
{
return data->file.fd;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册