2022-08-08 09:42:39

by Yang Jihong

[permalink] [raw]
Subject: [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands

Yang Jihong (2):
perf kvm: Fix subcommand matching error
perf sched latency: Fix subcommand matching error

tools/perf/builtin-kvm.c | 8 ++++----
tools/perf/builtin-sched.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)

--
2.30.GIT


2022-08-08 10:07:30

by Yang Jihong

[permalink] [raw]
Subject: [PATCH 2/2] perf sched latency: Fix subcommand matching error

perf sched latency use strncmp to match subcommands which matching does not
meet expectation.

Before:

# perf sched lat1234 >/dev/null
# echo $?
0
#

Solution: Use strstarts to match subcommand.

After:

# perf sched lat1234

Usage: perf sched [<options>] {record|latency|map|replay|script|timehist}

-D, --dump-raw-trace dump raw trace in ASCII
-f, --force don't complain, do it
-i, --input <file> input file name
-v, --verbose be more verbose (show symbol address, etc)

# echo $?
129
#
# perf sched lat >/dev/null
# echo $?
0
#

Signed-off-by: Yang Jihong <[email protected]>
---
tools/perf/builtin-sched.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 646bd938927a..2f6cd1b8b662 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -3563,7 +3563,7 @@ int cmd_sched(int argc, const char **argv)

if (strlen(argv[0]) > 2 && strstarts("record", argv[0])) {
return __cmd_record(argc, argv);
- } else if (!strncmp(argv[0], "lat", 3)) {
+ } else if (strlen(argv[0]) > 2 && strstarts("latency", argv[0])) {
sched.tp_handler = &lat_ops;
if (argc > 1) {
argc = parse_options(argc, argv, latency_options, latency_usage, 0);
--
2.30.GIT

2022-08-08 21:24:31

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands

Hello,

On Mon, Aug 8, 2022 at 2:27 AM Yang Jihong <[email protected]> wrote:
>
> Yang Jihong (2):
> perf kvm: Fix subcommand matching error
> perf sched latency: Fix subcommand matching error

Acked-by: Namhyung Kim <[email protected]>

Thanks,
Namhyung


>
> tools/perf/builtin-kvm.c | 8 ++++----
> tools/perf/builtin-sched.c | 2 +-
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> --
> 2.30.GIT
>

2022-08-10 13:42:45

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands

Em Mon, Aug 08, 2022 at 02:22:22PM -0700, Namhyung Kim escreveu:
> Hello,
>
> On Mon, Aug 8, 2022 at 2:27 AM Yang Jihong <[email protected]> wrote:
> >
> > Yang Jihong (2):
> > perf kvm: Fix subcommand matching error
> > perf sched latency: Fix subcommand matching error
>
> Acked-by: Namhyung Kim <[email protected]>

Thanks, applied.

- Arnaldo