Skip to contentSkip to conversation

perf record: Put a copy of kcore into the perf.data directory

RFC PATCH In review Adrian Hunter 2 participants 8 messages Sep 16, 2019 – Sep 24, 2019 perf events

lore
Share & tools
lore

Adrian Hunter

author reviewer
#0 lore raw

cover perf record: Put a copy of kcore into the perf.data directory

Hi

Here are 2 patches to add an option to 'perf record' to put a copy of kcore into a directory with perf.data. Refer to patch 2 for an example.

Adrian Hunter (2):
perf tools: Support single perf.data file directory perf record: Put a copy of kcore into the perf.data directory

 tools/perf/Documentation/perf-record.txt |  3 ++
 tools/perf/builtin-record.c              | 54 +++++++++++++++++++++++-
 tools/perf/util/data.c                   | 70 +++++++++++++++++++++++++++-----
 tools/perf/util/data.h                   |  8 ++++
 tools/perf/util/header.h                 |  1 +
 tools/perf/util/record.h                 |  1 +
 tools/perf/util/session.c                |  6 ++-
 tools/perf/util/util.c                   | 18 ++++++++
 8 files changed, 149 insertions(+), 12 deletions(-)

Regards
Adrian

author reviewer
#1 lore raw

RFC PATCH 1/2 perf tools: Support single perf.data file directory

Support directory output that contains a regular perf.data file. This is preparation for adding support for putting a copy of /proc/kcore in that directory.

Distinguish the multiple file case from the regular (single) perf.data file case by adding data->is_multi_file.

---
 tools/perf/builtin-record.c |  2 +-
 tools/perf/util/data.c      | 37 +++++++++++++++++++++++++++----------
 tools/perf/util/data.h      |  6 ++++++
 tools/perf/util/header.h    |  1 +
 tools/perf/util/session.c   |  2 +-
 tools/perf/util/util.c      |  1 +
 6 files changed, 37 insertions(+), 12 deletions(-)
tools/perf/builtin-record.c +1 -1
index 1447004eee8a..4c356a046dd3 100644
@@ -534,7 +534,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_multi_file(data)) {
 		off_t file_offset;
 		int fd = perf_data__fd(data);
 		int err;
tools/perf/util/data.c +27 -10
index 88fba2ba549f..2fd3114d1167 100644
@@ -37,7 +37,7 @@ int perf_data__create_dir(struct perf_data *data, int nr)
 	struct perf_data_file *files = NULL;
 	int i, ret = -1;
 
-	if (WARN_ON(!data->is_dir))
+	if (WARN_ON(!data->is_multi_file))
 		return -EINVAL;
 
 	files = zalloc(nr * sizeof(*files));
@@ -76,7 +76,7 @@ int perf_data__open_dir(struct perf_data *data)
 	DIR *dir;
 	int nr = 0;
 
-	if (WARN_ON(!data->is_dir))
+	if (WARN_ON(!data->is_multi_file))
 		return -EINVAL;
 
 	/* The version is provided by DIR_FORMAT feature. */
@@ -217,6 +217,16 @@ static bool is_dir(struct perf_data *data)
 	return (st.st_mode & S_IFMT) == S_IFDIR;
 }
 
+static bool is_multi_file(struct perf_data *data)
+{
+	char path[PATH_MAX];
+	struct stat st;
+
+	snprintf(path, sizeof(path), "%s/header", data->path);
+
+	return !stat(path, &st);
+}
+
 static int open_file_read(struct perf_data *data)
 {
 	struct stat st;
@@ -302,12 +312,17 @@ static int open_dir(struct perf_data *data)
 {
 	int ret;
 
-	/*
-	 * So far we open only the header, so we can read the data version and
-	 * layout.
-	 */
-	if (asprintf(&data->file.path, "%s/header", data->path) < 0)
-		return -1;
+	if (perf_data__is_multi_file(data)) {
+		/*
+		 * So far we open only the header, so we can read the data version and
+		 * layout.
+		 */
+		if (asprintf(&data->file.path, "%s/header", data->path) < 0)
+			return -1;
+	} else {
+		if (asprintf(&data->file.path, "%s/perf.data", data->path) < 0)
+			return -1;
+	}
 
 	if (perf_data__is_write(data) &&
 	    mkdir(data->path, S_IRWXU) < 0)
@@ -333,8 +348,10 @@ int perf_data__open(struct perf_data *data)
 	if (check_backup(data))
 		return -1;
 
-	if (perf_data__is_read(data))
+	if (perf_data__is_read(data)) {
 		data->is_dir = is_dir(data);
+		data->is_multi_file = is_multi_file(data);
+	}
 
 	return perf_data__is_dir(data) ?
 	       open_dir(data) : open_file_dup(data);
@@ -406,7 +423,7 @@ unsigned long perf_data__size(struct perf_data *data)
 	u64 size = data->file.size;
 	int i;
 
-	if (!data->is_dir)
+	if (!data->is_multi_file)
 		return size;
 
 	for (i = 0; i < data->dir.nr; i++) {
tools/perf/util/data.h +6 -0
index 259868a39019..0c5994d969c7 100644
@@ -20,6 +20,7 @@ struct perf_data {
 	struct perf_data_file	 file;
 	bool			 is_pipe;
 	bool			 is_dir;
+	bool			 is_multi_file;
 	bool			 force;
 	enum perf_data_mode	 mode;
 
@@ -50,6 +51,11 @@ static inline bool perf_data__is_dir(struct perf_data *data)
 	return data->is_dir;
 }
 
+static inline bool perf_data__is_multi_file(struct perf_data *data)
+{
+	return data->is_multi_file;
+}
+
 static inline int perf_data__fd(struct perf_data *data)
 {
 	return data->file.fd;
tools/perf/util/header.h +1 -0
index 999dac41871e..73ad217958b8 100644
@@ -53,6 +53,7 @@ enum perf_header_version {
 };
 
 enum perf_dir_version {
+	PERF_DIR_SINGLE_FILE	= 0,
 	PERF_DIR_VERSION	= 1,
 };
 
tools/perf/util/session.c +1 -1
index 2b583e6adb49..6dd04bd092d1 100644
@@ -222,7 +222,7 @@ struct perf_session *perf_session__new(struct perf_data *data,
 			perf_evlist__init_trace_event_sample_raw(session->evlist);
 
 			/* Open the directory data. */
-			if (data->is_dir && perf_data__open_dir(data))
+			if (data->is_multi_file && perf_data__open_dir(data))
 				goto out_delete;
 		}
 	} else  {
tools/perf/util/util.c +1 -0
index 32322a20a68b..5ca7490afdd1 100644
@@ -189,6 +189,7 @@ int rm_rf_perf_data(const char *path)
 	const char *pat[] = {
 		"header",
 		"data.*",
+		"perf.data",
 		NULL,
 	};
 
Signature · 1 line
2.17.1
author reviewer
#7 lore raw

RFC PATCH 2/2 perf record: Put a copy of kcore into the perf.data directory

In reply to Adrian Hunter

Add a new 'perf record' option '--kcore' which will put a copy of /proc/kcore, kallsyms and modules into the perf.data directory.

Example:

$ sudo perf record --kcore uname
$ sudo tree perf.data
perf.data
├── kcore_dir
│   ├── kallsyms
│   ├── kcore
│   └── modules
└── perf.data
$ sudo perf script -v
build id event received for vmlinux: 1eaa285996affce2d74d8e66dcea09a80c9941de
build id event received for [vdso]: 8bbaf5dc62a9b644b4d4e4539737e104e4a84541
Samples for 'cycles' event do not have CPU attribute set. Skipping 'cpu' field.
Using CPUID GenuineIntel-6-8E-A
Using perf.data/kcore_dir/kcore for kernel data
Using perf.data/kcore_dir/kallsyms for symbols
            perf 19058 506778.423729:          1 cycles:  ffffffffa2caa548 native_write_msr+0x8 (vmlinux)
            perf 19058 506778.423733:          1 cycles:  ffffffffa2caa548 native_write_msr+0x8 (vmlinux)
            perf 19058 506778.423734:          7 cycles:  ffffffffa2caa548 native_write_msr+0x8 (vmlinux)
            perf 19058 506778.423736:        117 cycles:  ffffffffa2caa54a native_write_msr+0xa (vmlinux)
            perf 19058 506778.423738:       2092 cycles:  ffffffffa2c9b7b0 native_apic_msr_write+0x0 (vmlinux)
            perf 19058 506778.423740:      37380 cycles:  ffffffffa2f121d0 perf_event_addr_filters_exec+0x0 (vmlinux)
           uname 19058 506778.423751:     582673 cycles:  ffffffffa303a407 propagate_protected_usage+0x147 (vmlinux)
           uname 19058 506778.423892:    2241841 cycles:  ffffffffa2cae0c9 unwind_next_frame.part.5+0x79 (vmlinux)
           uname 19058 506778.424430:    2457397 cycles:  ffffffffa3019232 check_memory_region+0x52 (vmlinux)
---
 tools/perf/Documentation/perf-record.txt |  3 ++
 tools/perf/builtin-record.c              | 52 ++++++++++++++++++++++++
 tools/perf/util/data.c                   | 33 +++++++++++++++
 tools/perf/util/data.h                   |  2 +
 tools/perf/util/record.h                 |  1 +
 tools/perf/util/session.c                |  4 ++
 tools/perf/util/util.c                   | 17 ++++++++
 7 files changed, 112 insertions(+)
tools/perf/Documentation/perf-record.txt +3 -0
index c6f9f31b6039..1d85e24aa453 100644
@@ -571,6 +571,9 @@ config terms. For example: 'cycles/overwrite/' and 'instructions/no-overwrite/'.
 
 Implies --tail-synthesize.
 
+--kcore::
+Make a copy of /proc/kcore and place it into a directory with the perf.data file.
+
 SEE ALSO
 --------
 linkperf:perf-stat[1], linkperf:perf-list[1]
tools/perf/builtin-record.c +52 -0

88 lines not on this page · raw message

tools/perf/util/data.c +33 -0
index 2fd3114d1167..86b2d6cf5f11 100644
@@ -434,3 +434,36 @@ unsigned long perf_data__size(struct perf_data *data)
 
 	return size;
 }
+
+int perf_data__make_kcore_dir(struct perf_data *data, char *buf, size_t buf_sz)
+{
+	int ret;
+
+	if (!data->is_dir)
+		return -1;
+
+	ret = snprintf(buf, buf_sz, "%s/kcore_dir", data->path);
+	if (ret < 0 || (size_t)ret >= buf_sz)
+		return -1;
+
+	return mkdir(buf, S_IRWXU);
+}
+
+char *perf_data__kallsyms_name(struct perf_data *data)
+{
+	char *kallsyms_name;
+	struct stat st;
+
+	if (!data->is_dir)
+		return NULL;
+
+	if (asprintf(&kallsyms_name, "%s/kcore_dir/kallsyms", data->path) < 0)
+		return NULL;
+
+	if (stat(kallsyms_name, &st)) {
+		free(kallsyms_name);
+		return NULL;
+	}
+
+	return kallsyms_name;
+}
tools/perf/util/data.h +2 -0
index 0c5994d969c7..cb906b524897 100644
@@ -83,4 +83,6 @@ int perf_data__open_dir(struct perf_data *data);
 void perf_data__close_dir(struct perf_data *data);
 int perf_data__update_dir(struct perf_data *data);
 unsigned long perf_data__size(struct perf_data *data);
+int perf_data__make_kcore_dir(struct perf_data *data, char *buf, size_t buf_sz);
+char *perf_data__kallsyms_name(struct perf_data *data);
 #endif /* __PERF_DATA_H */
tools/perf/util/record.h +1 -0
index 00275afc524d..948bbcf9aef3 100644
@@ -44,6 +44,7 @@ struct record_opts {
 	bool	      strict_freq;
 	bool	      sample_id;
 	bool	      no_bpf_event;
+	bool	      kcore;
 	unsigned int  freq;
 	unsigned int  mmap_pages;
 	unsigned int  auxtrace_mmap_pages;
tools/perf/util/session.c +4 -0
index 6dd04bd092d1..00d3e75ca1f4 100644
@@ -224,6 +224,10 @@ struct perf_session *perf_session__new(struct perf_data *data,
 			/* Open the directory data. */
 			if (data->is_multi_file && perf_data__open_dir(data))
 				goto out_delete;
+
+			if (!symbol_conf.kallsyms_name &&
+			    !symbol_conf.vmlinux_name)
+				symbol_conf.kallsyms_name = perf_data__kallsyms_name(data);
 		}
 	} else  {
 		session->machines.host.env = &perf_env;
tools/perf/util/util.c +17 -0
index 5ca7490afdd1..44568ce5082f 100644
@@ -184,6 +184,21 @@ static int rm_rf_depth_pat(const char *path, int depth, const char **pat)
 	return rmdir(path);
 }
 
+static int rm_rf_kcore_dir(const char *path)
+{
+	char kcore_dir_path[PATH_MAX];
+	const char *pat[] = {
+		"kcore",
+		"kallsyms",
+		"modules",
+		NULL,
+	};
+
+	snprintf(kcore_dir_path, sizeof(kcore_dir_path), "%s/kcore_dir", path);
+
+	return rm_rf_depth_pat(kcore_dir_path, 0, pat);
+}
+
 int rm_rf_perf_data(const char *path)
 {
 	const char *pat[] = {
@@ -193,6 +208,8 @@ int rm_rf_perf_data(const char *path)
 		NULL,
 	};
 
+	rm_rf_kcore_dir(path);
+
 	return rm_rf_depth_pat(path, 0, pat);
 }
 
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH RFC 1/2] perf tools: Support single perf.data file directory

In reply to Adrian Hunter
Quoted 6 lines · Adrian Hunter

Support directory output that contains a regular perf.data file. This is preparation for adding support for putting a copy of /proc/kcore in that directory.

Distinguish the multiple file case from the regular (single) perf.data file case by adding data->is_multi_file.

SNIP

Quoted 14 lines

static int open_file_read(struct perf_data *data) {

tools/perf/util/data.c +1 -6
 	struct stat st;
@@ -302,12 +312,17 @@ static int open_dir(struct perf_data *data)
 {
 	int ret;
 
-	/*
-	 * So far we open only the header, so we can read the data version and
-	 * layout.
-	 */
-	if (asprintf(&data->file.path, "%s/header", data->path) < 0)
-		return -1;
+	if (perf_data__is_multi_file(data)) {

tools/perf/util/data.c static int open_dir(struct perf_data *data) · line 325

Quoted 10 lines
tools/perf/util/data.c +10 -0
+		/*
+		 * So far we open only the header, so we can read the data version and
+		 * layout.
+		 */
+		if (asprintf(&data->file.path, "%s/header", data->path) < 0)
+			return -1;
+	} else {
+		if (asprintf(&data->file.path, "%s/perf.data", data->path) < 0)
+			return -1;
+	}

first, please note that there's support for perf.data directory code, but it's not been enabled yet, so we can do any changes there without breaking existing users

currently the logic is prepared to have perf.data DIR_FORMAT feature to define the layout of the directory

it'd be great to have just single point where we get directory layout, not checking on files names first and checking on DIR_FORMAT later

also the kcore will be beneficial for other layouts, so would be great to make it somehow optional/switchable

one of the options could be to have DIR_FORMAT feature as the source of directory layout and it'd have bitmask of files/dirs (like kcore_dir) available in the directory

thanks,
jirka

author reviewer
#3 lore raw

Re: [PATCH RFC 1/2] perf tools: Support single perf.data file directory

Quoted 26 lines · Jiri Olsa
Quoted 6 lines · Adrian Hunter

Support directory output that contains a regular perf.data file. This is preparation for adding support for putting a copy of /proc/kcore in that directory.

Distinguish the multiple file case from the regular (single) perf.data file case by adding data->is_multi_file.

SNIP

Quoted 16 lines

static int open_file_read(struct perf_data *data) {

tools/perf/util/data.c +3 -6
 	struct stat st;
@@ -302,12 +312,17 @@ static int open_dir(struct perf_data *data)
 {
 	int ret;
 
-	/*
-	 * So far we open only the header, so we can read the data version and
-	 * layout.
-	 */
-	if (asprintf(&data->file.path, "%s/header", data->path) < 0)
-		return -1;
+	if (perf_data__is_multi_file(data)) {
+		/*
+		 * So far we open only the header, so we can read the data version and
Quoted 9 lines

tools/perf/util/data.c static int open_dir(struct perf_data *data) · line 325

Quoted 8 lines
tools/perf/util/data.c +8 -0
+		 * layout.
+		 */
+		if (asprintf(&data->file.path, "%s/header", data->path) < 0)
+			return -1;
+	} else {
+		if (asprintf(&data->file.path, "%s/perf.data", data->path) < 0)
+			return -1;
+	}

Thanks for replying :-)

Quoted 9 lines

first, please note that there's support for perf.data directory code, but it's not been enabled yet, so we can do any changes there without breaking existing users

currently the logic is prepared to have perf.data DIR_FORMAT feature to define the layout of the directory

it'd be great to have just single point where we get directory layout, not checking on files names first and checking on DIR_FORMAT later

Ok, but what are you suggesting? Naming the data file "header" seems a bit counter-intuitive in this case.

Quoted 3 lines

also the kcore will be beneficial for other layouts, so would be great to make it somehow optional/switchable

In these patches it is, because it is not related to the DIR_FORMAT.

Quoted 3 lines

one of the options could be to have DIR_FORMAT feature as the source of directory layout and it'd have bitmask of files/dirs (like kcore_dir) available in the directory

Is there an advantage to making optional files/dirs part of the format? i.e. if they are there, use them otherwise don't.

#4 lore raw

Re: [PATCH RFC 1/2] perf tools: Support single perf.data file directory

Quoted 43 lines · Adrian Hunter
Quoted 26 lines · Jiri Olsa
Quoted 6 lines · Adrian Hunter

Support directory output that contains a regular perf.data file. This is preparation for adding support for putting a copy of /proc/kcore in that directory.

Distinguish the multiple file case from the regular (single) perf.data file case by adding data->is_multi_file.

SNIP

Quoted 16 lines

static int open_file_read(struct perf_data *data) {

tools/perf/util/data.c +3 -6
 	struct stat st;
@@ -302,12 +312,17 @@ static int open_dir(struct perf_data *data)
 {
 	int ret;
 
-	/*
-	 * So far we open only the header, so we can read the data version and
-	 * layout.
-	 */
-	if (asprintf(&data->file.path, "%s/header", data->path) < 0)
-		return -1;
+	if (perf_data__is_multi_file(data)) {
+		/*
+		 * So far we open only the header, so we can read the data version and
Quoted 9 lines

tools/perf/util/data.c static int open_dir(struct perf_data *data) · line 325

Quoted 8 lines
tools/perf/util/data.c +8 -0
+		 * layout.
+		 */
+		if (asprintf(&data->file.path, "%s/header", data->path) < 0)
+			return -1;
+	} else {
+		if (asprintf(&data->file.path, "%s/perf.data", data->path) < 0)
+			return -1;
+	}

Thanks for replying :-)

Quoted 4 lines

first, please note that there's support for perf.data directory code, but it's not been enabled yet, so we can do any changes there without breaking existing users

Quoted 8 lines
Quoted 5 lines

currently the logic is prepared to have perf.data DIR_FORMAT feature to define the layout of the directory

it'd be great to have just single point where we get directory layout, not checking on files names first and checking on DIR_FORMAT later

Ok, but what are you suggesting? Naming the data file "header" seems a bit counter-intuitive in this case.

don't know ;-)

but I'd like to have one way of finding out the directory layout

the code for threaded record uses DIR_FORMAT feature value to ensure the directory contains the expected files, which is data file with 'data.<cpu>' name for every cpu

Quoted 5 lines
Quoted 4 lines

also the kcore will be beneficial for other layouts, so would be great to make it somehow optional/switchable

Quoted 8 lines

In these patches it is, because it is not related to the DIR_FORMAT.

Quoted 3 lines

one of the options could be to have DIR_FORMAT feature as the source of directory layout and it'd have bitmask of files/dirs (like kcore_dir) available in the directory

Is there an advantage to making optional files/dirs part of the format? i.e. if they are there, use them otherwise don't.

ok, that might work, but please make that somehow explicit/visible what files/directories are possible in the directory, so we could easily see them and add new ones

jirka

author reviewer
#5 lore raw

Re: [PATCH RFC 1/2] perf tools: Support single perf.data file directory

Quoted 47 lines · Jiri Olsa
Quoted 46 lines · Adrian Hunter
Quoted 26 lines · Jiri Olsa
Quoted 6 lines · Adrian Hunter

Support directory output that contains a regular perf.data file. This is preparation for adding support for putting a copy of /proc/kcore in that directory.

Distinguish the multiple file case from the regular (single) perf.data file case by adding data->is_multi_file.

SNIP

Quoted 16 lines

static int open_file_read(struct perf_data *data) {

tools/perf/util/data.c +3 -6
 	struct stat st;
@@ -302,12 +312,17 @@ static int open_dir(struct perf_data *data)
 {
 	int ret;
 
-	/*
-	 * So far we open only the header, so we can read the data version and
-	 * layout.
-	 */
-	if (asprintf(&data->file.path, "%s/header", data->path) < 0)
-		return -1;
+	if (perf_data__is_multi_file(data)) {
+		/*
+		 * So far we open only the header, so we can read the data version and
Quoted 9 lines

tools/perf/util/data.c static int open_dir(struct perf_data *data) · line 325

Quoted 8 lines
tools/perf/util/data.c +8 -0
+		 * layout.
+		 */
+		if (asprintf(&data->file.path, "%s/header", data->path) < 0)
+			return -1;
+	} else {
+		if (asprintf(&data->file.path, "%s/perf.data", data->path) < 0)
+			return -1;
+	}

Thanks for replying :-)

Quoted 7 lines

first, please note that there's support for perf.data directory code, but it's not been enabled yet, so we can do any changes there without breaking existing users

currently the logic is prepared to have perf.data DIR_FORMAT feature to define the layout of the directory

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

it'd be great to have just single point where we get directory layout, not checking on files names first and checking on DIR_FORMAT later

Ok, but what are you suggesting? Naming the data file "header" seems a bit counter-intuitive in this case.

don't know ;-)

So what about calling it "data" instead of "header"?

Quoted 18 lines

but I'd like to have one way of finding out the directory layout

the code for threaded record uses DIR_FORMAT feature value to ensure the directory contains the expected files, which is data file with 'data.<cpu>' name for every cpu

Quoted 11 lines
Quoted 4 lines

also the kcore will be beneficial for other layouts, so would be great to make it somehow optional/switchable

In these patches it is, because it is not related to the DIR_FORMAT.

Quoted 3 lines

one of the options could be to have DIR_FORMAT feature as the source of directory layout and it'd have bitmask of files/dirs (like kcore_dir) available in the directory

Quoted 6 lines
Quoted 2 lines

Is there an advantage to making optional files/dirs part of the format? i.e. if they are there, use them otherwise don't.

ok, that might work, but please make that somehow explicit/visible what files/directories are possible in the directory, so we could easily see them and add new ones

At the moment, what can exist is what can be removed i.e. see rm_rf_perf_data(). Will that do?

#6 lore raw

Re: [PATCH RFC 1/2] perf tools: Support single perf.data file directory

Quoted 51 lines · Adrian Hunter
Quoted 50 lines · Jiri Olsa
Quoted 49 lines · Adrian Hunter
Quoted 26 lines · Jiri Olsa
Quoted 6 lines · Adrian Hunter

Support directory output that contains a regular perf.data file. This is preparation for adding support for putting a copy of /proc/kcore in that directory.

Distinguish the multiple file case from the regular (single) perf.data file case by adding data->is_multi_file.

SNIP

Quoted 16 lines

static int open_file_read(struct perf_data *data) {

tools/perf/util/data.c +3 -6
 	struct stat st;
@@ -302,12 +312,17 @@ static int open_dir(struct perf_data *data)
 {
 	int ret;
 
-	/*
-	 * So far we open only the header, so we can read the data version and
-	 * layout.
-	 */
-	if (asprintf(&data->file.path, "%s/header", data->path) < 0)
-		return -1;
+	if (perf_data__is_multi_file(data)) {
+		/*
+		 * So far we open only the header, so we can read the data version and
Quoted 9 lines

tools/perf/util/data.c static int open_dir(struct perf_data *data) · line 325

Quoted 8 lines
tools/perf/util/data.c +8 -0
+		 * layout.
+		 */
+		if (asprintf(&data->file.path, "%s/header", data->path) < 0)
+			return -1;
+	} else {
+		if (asprintf(&data->file.path, "%s/perf.data", data->path) < 0)
+			return -1;
+	}

Thanks for replying :-)

Quoted 9 lines

first, please note that there's support for perf.data directory code, but it's not been enabled yet, so we can do any changes there without breaking existing users

currently the logic is prepared to have perf.data DIR_FORMAT feature to define the layout of the directory

it'd be great to have just single point where we get directory layout, not checking on files names first and checking on DIR_FORMAT later

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Ok, but what are you suggesting? Naming the data file "header" seems a bit counter-intuitive in this case.

don't know ;-)

So what about calling it "data" instead of "header"?

ok, it actualy contains data in threaded record as well, so no problem there..

Quoted 22 lines
Quoted 22 lines

but I'd like to have one way of finding out the directory layout

the code for threaded record uses DIR_FORMAT feature value to ensure the directory contains the expected files, which is data file with 'data.<cpu>' name for every cpu

Quoted 13 lines
Quoted 4 lines

also the kcore will be beneficial for other layouts, so would be great to make it somehow optional/switchable

In these patches it is, because it is not related to the DIR_FORMAT.

Quoted 3 lines

one of the options could be to have DIR_FORMAT feature as the source of directory layout and it'd have bitmask of files/dirs (like kcore_dir) available in the directory

Is there an advantage to making optional files/dirs part of the format? i.e. if they are there, use them otherwise don't.

Quoted 6 lines
Quoted 3 lines

ok, that might work, but please make that somehow explicit/visible what files/directories are possible in the directory, so we could easily see them and add new ones

At the moment, what can exist is what can be removed i.e. see rm_rf_perf_data(). Will that do?

ok, but also please some comments in data.h and perf.data doc update ;-)

jirka