buitin-kvm: Update cmd_kvm() to check perf_host value
PATCH 1/1 buitin-kvm: Update cmd_kvm() to check perf_host value
From: Yunseong Kim <[email protected]>
According to perf-kvm.txt, the default operation is --guest, meaning perf_host should be set to false and perf_guest to true. Currently, the incorrect usage of --no-host and --no-guest still results in the default --guest operation.
This patch updates the usage messages to include the --no-guest option for those who only want host data, as well as the --no-host and --no-guest case.
--- tools/perf/builtin-kvm.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
tools/perf/builtin-kvm.c +13 -6
@@ -2129,7 +2129,7 @@ int cmd_kvm(int argc, const char **argv)OPT_BOOLEAN (0 ,"guest" , &perf_guest,"Collect guest os data" ),OPT_BOOLEAN (0 ,"host" , &perf_host, -"Collect host os data" ), +"Collect host os data. Host only with --host --no-guest" ),OPT_STRING (0 ,"guestmount" , &symbol_conf.guestmount,"directory" ,"guest mount directory under which every guest os" " instance has a subdir"),
@@ -2150,16 +2150,23 @@ int cmd_kvm(int argc, const char **argv) "buildid-list", "stat", NULL };const char *kvm_usage[] = {NULL ,NULL }; - perf_host =0 ; - perf_guest =1 ; +/* +* tools/perf/Documentation/perf-kvm.txt +* +* Default('') -> perf.data.guest +* --host -> perf.data.kvm +* --guest -> perf.data.guest +* --host --guest -> perf.data.kvm +* --host --no-guest -> perf.data.host +*/ + perf_host = false; + perf_guest = true; argc =parse_options_subcommand (argc, argv, kvm_options, kvm_subcommands, kvm_usage,PARSE_OPT_STOP_AT_NON_OPTION ); -if (!argc) +if (!argc || (!perf_host && !perf_guest))usage_with_options (kvm_usage, kvm_options); -if (!perf_host) - perf_guest =1 ;if (!file_name) { file_name =get_filename_for_perf_kvm ();
Signature · 1 line
2.34.1
Namhyung Kim
maintainerHello,
Quoted 7 lines · On Wed, May 15, 2024 at 12:54 PM <[email protected]> wrote:
From: Yunseong Kim <[email protected]>
According to perf-kvm.txt, the default operation is --guest, meaning
perf_hostshould be set to false andperf_guestto true. Currently, the incorrect usage of --no-host and --no-guest still results in the default --guest operation.
Hmm, right.. This is not good.
Quoted 4 lines
This patch updates the usage messages to include the --no-guest option for those who only want host data, as well as the --no-host and --no-guest case.
I'm not sure if it's worth mentioning the host-only use case which is not expected for this command. I think it's enough to warn the no-host and no-guest use cases.
Quoted 26 lines
Signed-off-by Yunseong Kim <[email protected]>--- tools/perf/builtin-kvm.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)tools/perf/builtin-kvm.c +2
-3@@ -2129,7 +2129,7 @@ int cmd_kvm(int argc, const char **argv)OPT_BOOLEAN (0 ,"guest" , &perf_guest,"Collect guest os data" ),OPT_BOOLEAN (0 ,"host" , &perf_host, -"Collect host os data" ), +"Collect host os data. Host only with --host --no-guest" ),OPT_STRING (0 ,"guestmount" , &symbol_conf.guestmount,"directory" ,"guest mount directory under which every guest os" " instance has a subdir"),@@ -2150,16 +2150,23 @@ int cmd_kvm(int argc, const char **argv) "buildid-list", "stat", NULL };const char *kvm_usage[] = {NULL ,NULL }; - perf_host =0 ; - perf_guest =1 ; +/*
tools/perf/builtin-kvm.c int cmd_kvm(int argc, const char **argv) · line 2163
Quoted 10 lines
tools/perf/builtin-kvm.c +10
-0+* tools/perf/Documentation/perf-kvm.txt +* +* Default('') -> perf.data.guest +* --host -> perf.data.kvm +* --guest -> perf.data.guest +* --host --guest -> perf.data.kvm +* --host --no-guest -> perf.data.host +*/ + perf_host = false; + perf_guest = true;
Probably not needed.
tools/perf/builtin-kvm.c int cmd_kvm(int argc, const char **argv) · line 2162
Quoted 9 lines
tools/perf/builtin-kvm.c +1
-3argc =parse_options_subcommand (argc, argv, kvm_options, kvm_subcommands, kvm_usage,PARSE_OPT_STOP_AT_NON_OPTION ); -if (!argc) +if (!argc || (!perf_host && !perf_guest))usage_with_options (kvm_usage, kvm_options); -if (!perf_host) - perf_guest =1 ;
Instead of showing the whole usage, I think it's better to print a specific message for this case.
Oh, I've realized that we have 'h' modifier for hypervisors (on ARM64?) Then maybe no-host + no-guest is a valid combination. Probably we need to add --hypervisor option then.
Thanks,
Namhyung
Quoted 6 lines
tools/perf/builtin-kvm.c +0
-1if (!file_name) { file_name =get_filename_for_perf_kvm (); --2.34.1
Quoted 14 lines · Namhyung Kim
Hello,
Quoted 7 lines · On Wed, May 15, 2024 at 12:54 PM <[email protected]> wrote:
From: Yunseong Kim <[email protected]>
According to perf-kvm.txt, the default operation is --guest, meaning
perf_hostshould be set to false andperf_guestto true. Currently, the incorrect usage of --no-host and --no-guest still results in the default --guest operation.Hmm, right.. This is not good.
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
This patch updates the usage messages to include the --no-guest option for those who only want host data, as well as the --no-host and --no-guest case.
I'm not sure if it's worth mentioning the host-only use case which is not expected for this command. I think it's enough to warn the no-host and no-guest use cases.
Thank you Namhyung for the code review!
I wasn't sure if it was necessary to mention that either.
I should have asked in the patch mail first.
Quoted 22 lines
Quoted 22 lines
Signed-off-by Yunseong Kim <[email protected]>--- tools/perf/builtin-kvm.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)tools/perf/builtin-kvm.c +1
-1@@ -2129,7 +2129,7 @@ int cmd_kvm(int argc, const char **argv)OPT_BOOLEAN (0 ,"guest" , &perf_guest,"Collect guest os data" ),OPT_BOOLEAN (0 ,"host" , &perf_host, -"Collect host os data" ), +"Collect host os data. Host only with --host --no-guest" ),OPT_STRING (0 ,"guestmount" , &symbol_conf.guestmount,"directory" ,"guest mount directory under which every guest os" " instance has a subdir"),@@ -2150,16 +2150,23 @@ int cmd_kvm(int argc, const char **argv) "buildid-list", "stat", NULL };const char *kvm_usage[] = {NULL ,NULL };
Quoted 15 lines
tools/perf/builtin-kvm.c int cmd_kvm(int argc, const char **argv) · line 2163
Quoted 13 lines
tools/perf/builtin-kvm.c +11
-2- perf_host =0 ; - perf_guest =1 ; +/* +* tools/perf/Documentation/perf-kvm.txt +* +* Default('') -> perf.data.guest +* --host -> perf.data.kvm +* --guest -> perf.data.guest +* --host --guest -> perf.data.kvm +* --host --no-guest -> perf.data.host +*/ + perf_host = false; + perf_guest = true;Probably not needed.
I agree.
Quoted 13 lines
tools/perf/builtin-kvm.c int cmd_kvm(int argc, const char **argv) · line 2162
Quoted 9 lines
tools/perf/builtin-kvm.c +1
-3argc =parse_options_subcommand (argc, argv, kvm_options, kvm_subcommands, kvm_usage,PARSE_OPT_STOP_AT_NON_OPTION ); -if (!argc) +if (!argc || (!perf_host && !perf_guest))usage_with_options (kvm_usage, kvm_options); -if (!perf_host) - perf_guest =1 ;Instead of showing the whole usage, I think it's better to print a specific message for this case.
Quoted 7 lines
Oh, I've realized that we have 'h' modifier for hypervisors (on ARM64?) Then maybe no-host + no-guest is a valid combination. Probably we need to add --hypervisor option then.
Thanks,
Namhyung
Yes, I have a native Arm64 devlopment environment.
So I'll implement and test it and send the patch.
Thank you so much for the detailed review!
Warm Regards,
Yunseong Kim
Quoted 6 lines
Quoted 6 lines
tools/perf/builtin-kvm.c +0
-1if (!file_name) { file_name =get_filename_for_perf_kvm (); --2.34.1