perf record: Disallow -c and -F option at the same time
Namhyung Kim
maintainerPATCH 1/1 perf record: Disallow -c and -F option at the same time
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.
--- tools/perf/util/record.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tools/perf/util/record.c +7 -1
@@ -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;
Signature · 1 line
2.31.0.208.g409f899ff0-goog
Arnaldo Carvalho de Melo
maintainerEm Fri, Apr 02, 2021 at 06:40:20PM +0900, Namhyung Kim escreveu:
Quoted 13 lines
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
Quoted 6 lines
After:
$ perf record -c 111111 -F 99 true cannot set frequency and period at the same timeSo 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
Quoted 30 lines
Suggested-by Alexey Alexandrov <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/record.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)tools/perf/util/record.c +7
-1@@ -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;Signature · 1 line
2.31.0.208.g409f899ff0-goog
Signature · 1 line
- Arnaldo
A message that is not in the archive (sent off-list or not yet received): CANtFmmo6Wq_u=D89hkfmS8yMtKhk+6pm_4YawpO-6MvS_4noaw@mail.gmail.com
Arnaldo Carvalho de Melo
maintainerEm Fri, Apr 02, 2021 at 08:25:30PM -0700, Alexey Alexandrov escreveu:
Quoted 3 lines
A warning can be missed when the tool is run by some kind of automation. Backward compatibility aside, I think conflicting flags should result in an early exit to avoid later surprises.
Sure, I agree with you in principle, but having erred out in the past, i.e. in making this be accepted, now making this out of the blue finally be considered what it always should have been considered, an error, feels like an error.
I sent this message after merging the change, but before pushing it out publicly I felt some (more) discussion would be in order.
Are you sure that potentially breaking existing scripts is ok in this case?
Up to you, frankly.
- Arnaldo
Quoted 68 lines
Quoted 65 lines · Arnaldo Carvalho de Melo
Em Fri, Apr 02, 2021 at 06:40:20PM +0900, Namhyung Kim escreveu:
Quoted 13 lines
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=111111Quoted 6 lines
After:
$ perf record -c 111111 -F 99 true cannot set frequency and period at the same timeSo 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
Quoted 11 lines
Suggested-by Alexey Alexandrov <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/record.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)tools/perf/util/record.c +0
-0tools/perf/util/record.c static int get_max_rate(unsigned int *rate) · line 164
Quoted 9 lines
tools/perf/util/record.c +3
-1@@ -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 sametime\n");
Quoted 10 lines
tools/perf/util/record.c +4
-1+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
Signature · 1 line
- Arnaldo
A message that is not in the archive (sent off-list or not yet received): CANtFmmqeBPW7XHAvphw9YpGy74b3T-jfzg1op+9ZyU=YLDLjDg@mail.gmail.com
Namhyung Kim
maintainerHi Arnaldo,
(Adjusting thetop-post)
Quoted 15 lines · Alexey Alexandrov
Quoted 14 lines · On Sat, Apr 3, 2021, 10:13 Arnaldo Carvalho de Melo <[email protected]> wrote:
Em Fri, Apr 02, 2021 at 08:25:30PM -0700, Alexey Alexandrov escreveu:
Quoted 3 lines
A warning can be missed when the tool is run by some kind of automation. Backward compatibility aside, I think conflicting flags should result in an early exit to avoid later surprises.
Sure, I agree with you in principle, but having erred out in the past, i.e. in making this be accepted, now making this out of the blue finally be considered what it always should have been considered, an error, feels like an error.
I sent this message after merging the change, but before pushing it out publicly I felt some (more) discussion would be in order.
Quoted 8 lines
Quoted 4 lines
Are you sure that potentially breaking existing scripts is ok in this case?
Up to you, frankly.
I personally think it's ok to break the existing conflicting usages of these flags because the owners of those invocations need to review and fix them to know what they are doing.
At the same time, this can be a two-step movement: maybe first let's make it an error message that imperatively states the problem and makes it clear that the invocation needs to be fixed, then (after X months) make it an exiting error.
So what do you think? I can make some changes if you want. But as it's rare and should be fixed anyway, I think we're good now.
Thanks,
Namhyung
Quoted 72 lines
Quoted 72 lines
Quoted 64 lines
Quoted 61 lines · wrote:
Em Fri, Apr 02, 2021 at 06:40:20PM +0900, Namhyung Kim escreveu:
Quoted 13 lines
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=111111Quoted 6 lines
After:
$ perf record -c 111111 -F 99 true cannot set frequency and period at the same timeSo 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
Quoted 11 lines
Suggested-by Alexey Alexandrov <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/record.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)tools/perf/util/record.c +0
-0tools/perf/util/record.c static int get_max_rate(unsigned int *rate) · line 164
Quoted 9 lines
tools/perf/util/record.c +3
-1@@ -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 sametime\n");
Quoted 10 lines
tools/perf/util/record.c +4
-1+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
Quoted 4 lines
Quoted 4 lines
--
- Arnaldo
--
- Arnaldo
Arnaldo Carvalho de Melo
maintainerEm Mon, May 03, 2021 at 02:32:32PM -0700, Namhyung Kim escreveu:
Quoted 23 lines
Hi Arnaldo,
(Adjusting thetop-post)
Quoted 18 lines · Alexey Alexandrov
Quoted 17 lines · On Sat, Apr 3, 2021, 10:13 Arnaldo Carvalho de Melo <[email protected]> wrote:
Em Fri, Apr 02, 2021 at 08:25:30PM -0700, Alexey Alexandrov escreveu:
Quoted 3 lines
A warning can be missed when the tool is run by some kind of automation. Backward compatibility aside, I think conflicting flags should result in an early exit to avoid later surprises.
Sure, I agree with you in principle, but having erred out in the past, i.e. in making this be accepted, now making this out of the blue finally be considered what it always should have been considered, an error, feels like an error.
I sent this message after merging the change, but before pushing it out publicly I felt some (more) discussion would be in order.
Are you sure that potentially breaking existing scripts is ok in this case?
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Up to you, frankly.
I personally think it's ok to break the existing conflicting usages of these flags because the owners of those invocations need to review and fix them to know what they are doing.
At the same time, this can be a two-step movement: maybe first let's make it an error message that imperatively states the problem and makes it clear that the invocation needs to be fixed, then (after X months) make it an exiting error.
So what do you think? I can make some changes if you want. But as it's rare and should be fixed anyway, I think we're good now.
Fair enough, I'm applying it as-is,
- Arnaldo
Quoted 75 lines
Thanks,
NamhyungQuoted 72 lines
Quoted 72 lines
Quoted 64 lines
Quoted 61 lines · wrote:
Em Fri, Apr 02, 2021 at 06:40:20PM +0900, Namhyung Kim escreveu:
Quoted 13 lines
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=111111Quoted 6 lines
After:
$ perf record -c 111111 -F 99 true cannot set frequency and period at the same timeSo 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
Quoted 11 lines
Suggested-by Alexey Alexandrov <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/util/record.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)tools/perf/util/record.c +0
-0tools/perf/util/record.c static int get_max_rate(unsigned int *rate) · line 164
Quoted 9 lines
tools/perf/util/record.c +3
-1@@ -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 sametime\n");
Quoted 10 lines
tools/perf/util/record.c +4
-1+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
Quoted 4 lines
Quoted 4 lines
--
- Arnaldo
--
- Arnaldo
Signature · 1 line
- Arnaldo