Re: [PATCH v14 3/3]: perf record: extend trace writing to multi AIO

From: Alexey Budankov
Date: Fri Nov 02 2018 - 12:13:04 EST


Hi,

On 01.11.2018 21:30, Song Liu wrote:
> On Sun, Oct 14, 2018 at 11:47 PM Alexey Budankov
> <alexey.budankov@xxxxxxxxxxxxxxx> wrote:
>>
<SNIP>
>>
>>
>> static int nr_cblocks_default = 1;
>>
>> static int record__aio_parse(const struct option *opt,
>> - const char *str __maybe_unused,
>> + const char *str,
>> int unset)
>> {
>> struct record_opts *opts = (struct record_opts *)opt->value;
>>
>> - if (unset)
>> + if (unset) {
>> opts->nr_cblocks = 0;
>> - else
>> - opts->nr_cblocks = nr_cblocks_default;
>> + } else {
>> + if (str)
>> + opts->nr_cblocks = strtol(str, NULL, 0);
>> + if (!opts->nr_cblocks)
>> + opts->nr_cblocks = nr_cblocks_default;
>> + }
>>
>> return 0;
>> }
>> #else /* HAVE_AIO_SUPPORT */
<SNIP>
>> @@ -1492,6 +1517,13 @@ static int perf_record_config(const char *var, const char *value, void *cb)
>> var = "call-graph.record-mode";
>> return perf_default_config(var, value, cb);
>> }
>> +#ifdef HAVE_AIO_SUPPORT
>> + if (!strcmp(var, "record.aio")) {
>> + rec->opts.nr_cblocks = strtol(value, NULL, 0);
>> + if (!rec->opts.nr_cblocks)
>> + rec->opts.nr_cblocks = nr_cblocks_default;
>> + }
>> +#endif
>>
>> return 0;
>> }
>> @@ -1884,8 +1916,8 @@ static struct option __record_options[] = {
>> OPT_BOOLEAN(0, "dry-run", &dry_run,
>> "Parse options then exit"),
>> #ifdef HAVE_AIO_SUPPORT
>> - OPT_CALLBACK_NOOPT(0, "aio", &record.opts,
>> - NULL, "Enable asynchronous trace writing mode",
>> + OPT_CALLBACK_OPTARG(0, "aio", &record.opts,
>> + &nr_cblocks_default, "n", "Use <n> control blocks in asynchronous trace writing mode (default: 1, max: 4)",
>> record__aio_parse),
>> #endif
>> OPT_END()
>> @@ -2080,6 +2112,8 @@ int cmd_record(int argc, const char **argv)
>> goto out;
>> }
>>
>> + if (rec->opts.nr_cblocks > 4)
>> + rec->opts.nr_cblocks = 4;
> nit: I feel this logic belongs to record__aio_parse(). And we should have
>
> static int nr_cblocks_max = 4;

This looks reasonable.

Thanks,
Alexey

>
> Other than this
>
> Acked-by: Song Liu <songliubraving@xxxxxx>
>