Re: [PATCH v2 2/4] perf record: implement -z=<level> and --mmap-flush=<thres> options
From: Jiri Olsa
Date: Tue Feb 12 2019 - 08:08:42 EST
On Mon, Feb 11, 2019 at 11:22:38PM +0300, Alexey Budankov wrote:
SNIP
> static void record__init_features(struct record *rec)
> @@ -838,6 +881,9 @@ static void record__init_features(struct record *rec)
> if (!(rec->opts.use_clockid && rec->opts.clockid_res_ns))
> perf_header__clear_feat(&session->header, HEADER_CLOCKID);
>
> + if (!record__comp_enabled(rec))
> + perf_header__clear_feat(&session->header, HEADER_COMPRESSED);
> +
> perf_header__clear_feat(&session->header, HEADER_STAT);
> }
>
> @@ -1147,6 +1193,10 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
> fd = perf_data__fd(data);
> rec->session = session;
>
> + rec->opts.comp_level = 0;
> + session->header.env.comp_level = rec->opts.comp_level;
> + session->header.env.comp_type = PERF_COMP_NONE;
hum I think both record and session are zerod from start,
so this seems superfluous
SNIP
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index dec6d218c31c..5ad3a27a042f 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -1463,6 +1463,21 @@ static int write_mem_topology(struct feat_fd *ff __maybe_unused,
> return ret;
> }
>
> +static int write_compressed(struct feat_fd *ff __maybe_unused,
> + struct perf_evlist *evlist __maybe_unused)
> +{
> + int ret;
> + u64 compression_info = ((u64)ff->ph->env.comp_type << 32) | ff->ph->env.comp_level;
> +
> + ret = do_write(ff, &compression_info, sizeof(compression_info));
> + if (ret)
> + return ret;
> +
> + compression_info = ((u64)ff->ph->env.comp_ratio << 32) | ff->ph->env.comp_mmap_len;
let's not complicate this, if you have two u32 values
to store, store two u32 values ;-)
also please add version in case we will add new fields in the future,
so we can stay backward compatible
jirka