Re: [PATCH 3/5] perf record: Add --dir option to store data in directory

From: Namhyung Kim
Date: Wed Mar 13 2019 - 10:08:11 EST


Hi Jirka,

On Mon, Mar 11, 2019 at 12:30 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> Adding --dir option to store data in directory. It's next
> step for multiple threads in record. It's now possible to
> make directory data via --dir option, like:
>
> $ perf record --dir perf bench sched messaging
> $ ls -l perf.data
> total 344
> -rw-------. 1 jolsa jolsa 43864 Jan 20 22:26 data.0
> -rw-------. 1 jolsa jolsa 30464 Jan 20 22:26 data.1
> -rw-------. 1 jolsa jolsa 53816 Jan 20 22:26 data.2
> -rw-------. 1 jolsa jolsa 30368 Jan 20 22:26 data.3
> -rw-------. 1 jolsa jolsa 40088 Jan 20 22:26 data.4
> -rw-------. 1 jolsa jolsa 42592 Jan 20 22:26 data.5
> -rw-------. 1 jolsa jolsa 56136 Jan 20 22:26 data.6
> -rw-------. 1 jolsa jolsa 25992 Jan 20 22:26 data.7
> -rw-------. 1 jolsa jolsa 8832 Jan 20 22:26 header
>
> There's a data file created for every cpu and it's storing
> data for those cpu maps.
>
> It's possible to transform directory data into standard
> perf.data file via following inject command:
>
> $ perf inject -o perf.data.file -i perf.data
>
> The --dir option enabled DIR_FORMAT feature to be stored
> in header file to indicate the directory layout.
>
> Don't allow to use --dir with --aio yet. It needs
> to be investigated first.
>
> Link: http://lkml.kernel.org/n/tip-0kjm8wpglzu2tm18tpagfm4d@xxxxxxxxxxxxxx
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---

[SNIP]
> @@ -1983,6 +2040,8 @@ static struct option __record_options[] = {
> OPT_CALLBACK(0, "affinity", &record.opts, "node|cpu",
> "Set affinity mask of trace reading thread to NUMA node cpu mask or cpu of processed mmap buffer",
> record__parse_affinity),
> + OPT_BOOLEAN(0, "dir", &record.data.is_dir,
> + "Store data into directory perf.data"),
> OPT_END()
> };
>
> @@ -2134,6 +2193,17 @@ int cmd_record(int argc, const char **argv)
> goto out;
> }
>
> + if (perf_data__is_dir(&rec->data)) {
> + if (!rec->opts.sample_time) {
> + pr_err("Sample timestamp is required for indexing\n");

s/indexing/directory output/ ?

Thanks
Namhyung


> + goto out;
> + }
> + if (record__aio_enabled(rec)) {
> + pr_err("Cannot use both --dir and --aio yet.\n");
> + goto out;
> + }
> + }
> +
> if (rec->opts.target.tid && !rec->opts.no_inherit_set)
> rec->opts.no_inherit = true;