[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YGcd/vz3KyOUReOh@kernel.org>
Date: Fri, 2 Apr 2021 10:37:02 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Jiri Olsa <jolsa@...hat.com>, Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
LKML <linux-kernel@...r.kernel.org>,
Andi Kleen <ak@...ux.intel.com>,
Ian Rogers <irogers@...gle.com>,
Alexey Alexandrov <aalexand@...gle.com>
Subject: Re: [PATCH] perf record: Disallow -c and -F option at the same time
Em Fri, Apr 02, 2021 at 06:40:20PM +0900, Namhyung Kim escreveu:
> It's confusing which one is effective when the both options are given.
> The current code happens to use -c in this case but users might not be
> aware of it. We can change it to complain about that instead of
> relying on the implicit priority.
>
> Before:
> $ perf record -c 111111 -F 99 true
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.031 MB perf.data (8 samples) ]
>
> $ perf evlist -F
> cycles: sample_period=111111
>
> After:
> $ perf record -c 111111 -F 99 true
> cannot set frequency and period at the same time
>
> So this change can break existing usages, but I think it's rare to
> have both options and it'd be better changing them.
Humm, perhaps we can just make that an warning stating that -c is used
if both are specified?
$ perf record -c 111111 -F 99 true
Frequency and period can't be used the same time, -c 11111 will be used.
- Arnaldo
> Suggested-by: Alexey Alexandrov <aalexand@...gle.com>
> Signed-off-by: Namhyung Kim <namhyung@...nel.org>
> ---
> tools/perf/util/record.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c
> index f99852d54b14..43e5b563dee8 100644
> --- a/tools/perf/util/record.c
> +++ b/tools/perf/util/record.c
> @@ -157,9 +157,15 @@ static int get_max_rate(unsigned int *rate)
> static int record_opts__config_freq(struct record_opts *opts)
> {
> bool user_freq = opts->user_freq != UINT_MAX;
> + bool user_interval = opts->user_interval != ULLONG_MAX;
> unsigned int max_rate;
>
> - if (opts->user_interval != ULLONG_MAX)
> + if (user_interval && user_freq) {
> + pr_err("cannot set frequency and period at the same time\n");
> + return -1;
> + }
> +
> + if (user_interval)
> opts->default_interval = opts->user_interval;
> if (user_freq)
> opts->freq = opts->user_freq;
> --
> 2.31.0.208.g409f899ff0-goog
>
--
- Arnaldo
Powered by blists - more mailing lists