tools/mm/page_owner_sort: add help option support
PATCH 1/1 tools/mm/page_owner_sort: add help option support
From: Ye Liu <[email protected]>
Add -h/--help option to display usage information and improve code style.
--- tools/mm/page_owner_sort.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
tools/mm/page_owner_sort.c +7 -3
@@ -669,14 +669,15 @@ int main(int argc, char **argv) { "pid", required_argument, NULL, 1 }, { "tgid", required_argument, NULL, 2 }, { "name", required_argument, NULL, 3 }, - { "cull", required_argument, NULL, 4 }, - { "sort", required_argument, NULL, 5 }, + { "cull", required_argument, NULL, 4 }, + { "sort", required_argument, NULL, 5 }, + { "help", no_argument, NULL, 'h' }, { 0, 0, 0, 0}, }; compare_flag =COMP_NO_FLAG ; -while ((opt =getopt_long (argc, argv,"admnpstP" , longopts,NULL )) !=-1 ) +while ((opt =getopt_long (argc, argv,"admnpstPh" , longopts,NULL )) !=-1 )switch (opt) {case 'a' : compare_flag |=COMP_ALLOC ;
@@ -702,6 +703,9 @@ int main(int argc, char **argv)case 'n' : compare_flag |=COMP_COMM ;break ; +case 'h' : +usage (); +exit (0 );case 1 : filter = filter |FILTER_PID ; fc.pids =parse_nums_list (optarg, &fc.pids_size);
Signature · 1 line
2.43.0
Quoted 3 lines · On Thu, 16 Oct 2025 13:49:25 +0800 Ye Liu <[email protected]> wrote:
From: Ye Liu <[email protected]>
Add -h/--help option to display usage information and improve code style.
Looks good to me, though I have a trivial comment below.
Quoted 11 lines
Signed-off-by Ye Liu <[email protected]>--- tools/mm/page_owner_sort.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)tools/mm/page_owner_sort.c +0
-0
tools/mm/page_owner_sort.c int main(int argc, char **argv) · line 673
Quoted 7 lines
tools/mm/page_owner_sort.c +2
-2@@ -669,14 +669,15 @@ int main(int argc, char **argv) { "pid", required_argument, NULL, 1 }, { "tgid", required_argument, NULL, 2 }, { "name", required_argument, NULL, 3 }, - { "cull", required_argument, NULL, 4 }, - { "sort", required_argument, NULL, 5 }, + { "cull", required_argument, NULL, 4 }, + { "sort", required_argument, NULL, 5 },
Seems unnecessary changes.
Quoted 23 lines
tools/mm/page_owner_sort.c +5
-1+ { "help", no_argument, NULL, 'h' }, { 0, 0, 0, 0}, }; compare_flag =COMP_NO_FLAG ; -while ((opt =getopt_long (argc, argv,"admnpstP" , longopts,NULL )) !=-1 ) +while ((opt =getopt_long (argc, argv,"admnpstPh" , longopts,NULL )) !=-1 )switch (opt) {case 'a' : compare_flag |=COMP_ALLOC ;@@ -702,6 +703,9 @@ int main(int argc, char **argv)case 'n' : compare_flag |=COMP_COMM ;break ; +case 'h' : +usage (); +exit (0 );case 1 : filter = filter |FILTER_PID ; fc.pids =parse_nums_list (optarg, &fc.pids_size);Signature · 1 line
2.43.0
If you remove the unnecessary changes, please feel free to add below:
Thanks,
SJ
Quoted 14 lines · SeongJae Park
Quoted 3 lines · On Thu, 16 Oct 2025 13:49:25 +0800 Ye Liu <[email protected]> wrote:
From: Ye Liu <[email protected]>
Add -h/--help option to display usage information and improve code style.
Looks good to me, though I have a trivial comment below.
Quoted 6 lines
Signed-off-by Ye Liu <[email protected]>--- tools/mm/page_owner_sort.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
Quoted 14 lines
tools/mm/page_owner_sort.c int main(int argc, char **argv) · line 673
Quoted 12 lines
tools/mm/page_owner_sort.c +2
-2@@ -669,14 +669,15 @@ int main(int argc, char **argv) { "pid", required_argument, NULL, 1 }, { "tgid", required_argument, NULL, 2 }, { "name", required_argument, NULL, 3 }, - { "cull", required_argument, NULL, 4 }, - { "sort", required_argument, NULL, 5 }, + { "cull", required_argument, NULL, 4 }, + { "sort", required_argument, NULL, 5 },Seems unnecessary changes.
The spacing changes fix inconsistent formatting in longopts array. Since the format fixes are simple and in the same context, I put them together. If you insist on removing these changes, I will drop them in the next version.>
Quoted 31 lines
Quoted 23 lines
tools/mm/page_owner_sort.c +5
-1+ { "help", no_argument, NULL, 'h' }, { 0, 0, 0, 0}, }; compare_flag =COMP_NO_FLAG ; -while ((opt =getopt_long (argc, argv,"admnpstP" , longopts,NULL )) !=-1 ) +while ((opt =getopt_long (argc, argv,"admnpstPh" , longopts,NULL )) !=-1 )switch (opt) {case 'a' : compare_flag |=COMP_ALLOC ;@@ -702,6 +703,9 @@ int main(int argc, char **argv)case 'n' : compare_flag |=COMP_COMM ;break ; +case 'h' : +usage (); +exit (0 );case 1 : filter = filter |FILTER_PID ; fc.pids =parse_nums_list (optarg, &fc.pids_size);Signature · 1 line
2.43.0If you remove the unnecessary changes, please feel free to add below:
Reviewed-by SeongJae Park <[email protected]>Thanks,
SJ
Signature · 2 lines
Thanks, Ye Liu
Quoted 31 lines · On Fri, 17 Oct 2025 09:19:09 +0800 Ye Liu <[email protected]> wrote:
Quoted 14 lines · SeongJae Park
Quoted 3 lines · On Thu, 16 Oct 2025 13:49:25 +0800 Ye Liu <[email protected]> wrote:
From: Ye Liu <[email protected]>
Add -h/--help option to display usage information and improve code style.
Looks good to me, though I have a trivial comment below.
Quoted 6 lines
Signed-off-by Ye Liu <[email protected]>--- tools/mm/page_owner_sort.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)Quoted 14 lines
tools/mm/page_owner_sort.c int main(int argc, char **argv) · line 673
Quoted 12 lines
tools/mm/page_owner_sort.c +2
-2@@ -669,14 +669,15 @@ int main(int argc, char **argv) { "pid", required_argument, NULL, 1 }, { "tgid", required_argument, NULL, 2 }, { "name", required_argument, NULL, 3 }, - { "cull", required_argument, NULL, 4 }, - { "sort", required_argument, NULL, 5 }, + { "cull", required_argument, NULL, 4 }, + { "sort", required_argument, NULL, 5 },Seems unnecessary changes.
Quoted 2 lines
The spacing changes fix inconsistent formatting in longopts array. Since the format fixes are simple and in the same context, I put them together.
Thank you for clarifying.
Quoted 1 line
If you insist on removing these changes, I will drop them in the next version.
I have no strong opinion, plese do whatever you prefer :)
Thanks,
SJ
[...]