* [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands
@ 2022-08-08 9:24 Yang Jihong
2022-08-08 9:24 ` [PATCH 1/2] perf kvm: Fix subcommand matching error Yang Jihong
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Yang Jihong @ 2022-08-08 9:24 UTC (permalink / raw)
To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung, linux-perf-users, linux-kernel
Cc: yangjihong1
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] perf kvm: Fix subcommand matching error
2022-08-08 9:24 [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands Yang Jihong
@ 2022-08-08 9:24 ` Yang Jihong
2022-08-08 9:24 ` [PATCH 2/2] perf sched latency: " Yang Jihong
2022-08-08 21:22 ` [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands Namhyung Kim
2 siblings, 0 replies; 5+ messages in thread
From: Yang Jihong @ 2022-08-08 9:24 UTC (permalink / raw)
To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung, linux-perf-users, linux-kernel
Cc: yangjihong1
Currently, diff, top, buildid-list and stat use strncmp to match subcommands.
As a result, matching does not meet expectation.
For example:
# perf kvm diff1234
# Event 'cycles'
#
# Baseline Delta Abs Shared Object Symbol
# ........ ......... ............. ......
#
# Event 'dummy:HG'
#
# Baseline Delta Abs Shared Object Symbol
# ........ ......... ............. ......
#
# echo $?
0
#
Invalid information should be returned, but success is actually returned.
Solution: Use strstarts to match subcommands.
After:
# perf kvm diff1234
Usage: perf kvm [<options>] {top|record|report|diff|buildid-list|stat}
-i, --input <file> Input file name
-o, --output <file> Output file name
-v, --verbose be more verbose (show counter open errors, etc)
--guest Collect guest os data
--guest-code Guest code can be found in hypervisor process
--guestkallsyms <file>
file saving guest os /proc/kallsyms
--guestmodules <file>
file saving guest os /proc/modules
--guestmount <directory>
guest mount directory under which every guest os instance has a subdir
--guestvmlinux <file>
file saving guest os vmlinux
--host Collect host os data
# echo $?
129
#
Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
---
tools/perf/builtin-kvm.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 3696ae97f149..7d9ec1bac1a2 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1638,14 +1638,14 @@ int cmd_kvm(int argc, const char **argv)
return __cmd_record(file_name, argc, argv);
else if (strlen(argv[0]) > 2 && strstarts("report", argv[0]))
return __cmd_report(file_name, argc, argv);
- else if (!strncmp(argv[0], "diff", 4))
+ else if (strlen(argv[0]) > 2 && strstarts("diff", argv[0]))
return cmd_diff(argc, argv);
- else if (!strncmp(argv[0], "top", 3))
+ else if (!strcmp(argv[0], "top"))
return cmd_top(argc, argv);
- else if (!strncmp(argv[0], "buildid-list", 12))
+ else if (strlen(argv[0]) > 2 && strstarts("buildid-list", argv[0]))
return __cmd_buildid_list(file_name, argc, argv);
#ifdef HAVE_KVM_STAT_SUPPORT
- else if (!strncmp(argv[0], "stat", 4))
+ else if (strlen(argv[0]) > 2 && strstarts("stat", argv[0]))
return kvm_cmd_stat(file_name, argc, argv);
#endif
else
--
2.30.GIT
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] perf sched latency: Fix subcommand matching error
2022-08-08 9:24 [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands Yang Jihong
2022-08-08 9:24 ` [PATCH 1/2] perf kvm: Fix subcommand matching error Yang Jihong
@ 2022-08-08 9:24 ` Yang Jihong
2022-08-08 21:22 ` [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands Namhyung Kim
2 siblings, 0 replies; 5+ messages in thread
From: Yang Jihong @ 2022-08-08 9:24 UTC (permalink / raw)
To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung, linux-perf-users, linux-kernel
Cc: yangjihong1
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 <yangjihong1@huawei.com>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands
2022-08-08 9:24 [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands Yang Jihong
2022-08-08 9:24 ` [PATCH 1/2] perf kvm: Fix subcommand matching error Yang Jihong
2022-08-08 9:24 ` [PATCH 2/2] perf sched latency: " Yang Jihong
@ 2022-08-08 21:22 ` Namhyung Kim
2022-08-10 13:16 ` Arnaldo Carvalho de Melo
2 siblings, 1 reply; 5+ messages in thread
From: Namhyung Kim @ 2022-08-08 21:22 UTC (permalink / raw)
To: Yang Jihong
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, linux-perf-users,
linux-kernel
Hello,
On Mon, Aug 8, 2022 at 2:27 AM Yang Jihong <yangjihong1@huawei.com> wrote:
>
> Yang Jihong (2):
> perf kvm: Fix subcommand matching error
> perf sched latency: Fix subcommand matching error
Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
>
> tools/perf/builtin-kvm.c | 8 ++++----
> tools/perf/builtin-sched.c | 2 +-
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> --
> 2.30.GIT
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands
2022-08-08 21:22 ` [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands Namhyung Kim
@ 2022-08-10 13:16 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-08-10 13:16 UTC (permalink / raw)
To: Namhyung Kim
Cc: Yang Jihong, Peter Zijlstra, Ingo Molnar, Mark Rutland,
Alexander Shishkin, Jiri Olsa, linux-perf-users, linux-kernel
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 <yangjihong1@huawei.com> wrote:
> >
> > Yang Jihong (2):
> > perf kvm: Fix subcommand matching error
> > perf sched latency: Fix subcommand matching error
>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
Thanks, applied.
- Arnaldo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-08-10 13:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-08 9:24 [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands Yang Jihong
2022-08-08 9:24 ` [PATCH 1/2] perf kvm: Fix subcommand matching error Yang Jihong
2022-08-08 9:24 ` [PATCH 2/2] perf sched latency: " Yang Jihong
2022-08-08 21:22 ` [PATCH 0/2] perf kvm/sched: Use strstarts instead of strncmp to match subcommands Namhyung Kim
2022-08-10 13:16 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).