linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/mm/page_owner_sort: add help option support
@ 2025-10-16  5:49 Ye Liu
  2025-10-16 20:10 ` SeongJae Park
  0 siblings, 1 reply; 4+ messages in thread
From: Ye Liu @ 2025-10-16  5:49 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Ye Liu, linux-mm, linux-kernel

From: Ye Liu <liuye@kylinos.cn>

Add -h/--help option to display usage information and improve code style.

Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
 tools/mm/page_owner_sort.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c
index 880e36df0c11..202eafed66a9 100644
--- a/tools/mm/page_owner_sort.c
+++ b/tools/mm/page_owner_sort.c
@@ -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);
-- 
2.43.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/mm/page_owner_sort: add help option support
  2025-10-16  5:49 [PATCH] tools/mm/page_owner_sort: add help option support Ye Liu
@ 2025-10-16 20:10 ` SeongJae Park
  2025-10-17  1:19   ` Ye Liu
  0 siblings, 1 reply; 4+ messages in thread
From: SeongJae Park @ 2025-10-16 20:10 UTC (permalink / raw)
  To: Ye Liu; +Cc: SeongJae Park, Andrew Morton, Ye Liu, linux-mm, linux-kernel

On Thu, 16 Oct 2025 13:49:25 +0800 Ye Liu <ye.liu@linux.dev> wrote:

> From: Ye Liu <liuye@kylinos.cn>
> 
> Add -h/--help option to display usage information and improve code style.

Looks good to me, though I have a trivial comment below.

> 
> Signed-off-by: Ye Liu <liuye@kylinos.cn>
> ---
>  tools/mm/page_owner_sort.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c
> index 880e36df0c11..202eafed66a9 100644
> --- a/tools/mm/page_owner_sort.c
> +++ b/tools/mm/page_owner_sort.c
> @@ -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.

> +		{ "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);
> -- 
> 2.43.0

If you remove the unnecessary changes, please feel free to add below:

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/mm/page_owner_sort: add help option support
  2025-10-16 20:10 ` SeongJae Park
@ 2025-10-17  1:19   ` Ye Liu
  2025-10-17  1:35     ` SeongJae Park
  0 siblings, 1 reply; 4+ messages in thread
From: Ye Liu @ 2025-10-17  1:19 UTC (permalink / raw)
  To: SeongJae Park; +Cc: Andrew Morton, Ye Liu, linux-mm, linux-kernel



在 2025/10/17 04:10, SeongJae Park 写道:
> On Thu, 16 Oct 2025 13:49:25 +0800 Ye Liu <ye.liu@linux.dev> wrote:
> 
>> From: Ye Liu <liuye@kylinos.cn>
>>
>> Add -h/--help option to display usage information and improve code style.
> 
> Looks good to me, though I have a trivial comment below.
> 
>>
>> Signed-off-by: Ye Liu <liuye@kylinos.cn>
>> ---
>>  tools/mm/page_owner_sort.c | 10 +++++++---
>>  1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c
>> index 880e36df0c11..202eafed66a9 100644
>> --- a/tools/mm/page_owner_sort.c
>> +++ b/tools/mm/page_owner_sort.c
>> @@ -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.> 
>> +		{ "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);
>> -- 
>> 2.43.0
> 
> If you remove the unnecessary changes, please feel free to add below:
> 
> Reviewed-by: SeongJae Park <sj@kernel.org>
> 
> 
> Thanks,
> SJ

-- 
Thanks,
Ye Liu



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/mm/page_owner_sort: add help option support
  2025-10-17  1:19   ` Ye Liu
@ 2025-10-17  1:35     ` SeongJae Park
  0 siblings, 0 replies; 4+ messages in thread
From: SeongJae Park @ 2025-10-17  1:35 UTC (permalink / raw)
  To: Ye Liu; +Cc: SeongJae Park, Andrew Morton, Ye Liu, linux-mm, linux-kernel

On Fri, 17 Oct 2025 09:19:09 +0800 Ye Liu <ye.liu@linux.dev> wrote:

> 
> 
> 在 2025/10/17 04:10, SeongJae Park 写道:
> > On Thu, 16 Oct 2025 13:49:25 +0800 Ye Liu <ye.liu@linux.dev> wrote:
> > 
> >> From: Ye Liu <liuye@kylinos.cn>
> >>
> >> Add -h/--help option to display usage information and improve code style.
> > 
> > Looks good to me, though I have a trivial comment below.
> > 
> >>
> >> Signed-off-by: Ye Liu <liuye@kylinos.cn>
> >> ---
> >>  tools/mm/page_owner_sort.c | 10 +++++++---
> >>  1 file changed, 7 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/tools/mm/page_owner_sort.c b/tools/mm/page_owner_sort.c
> >> index 880e36df0c11..202eafed66a9 100644
> >> --- a/tools/mm/page_owner_sort.c
> >> +++ b/tools/mm/page_owner_sort.c
> >> @@ -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.

Thank you for clarifying.

> 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

[...]


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-17  1:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-16  5:49 [PATCH] tools/mm/page_owner_sort: add help option support Ye Liu
2025-10-16 20:10 ` SeongJae Park
2025-10-17  1:19   ` Ye Liu
2025-10-17  1:35     ` SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox