]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
tools/mm/page_owner_sort: add help option support
authorYe Liu <liuye@kylinos.cn>
Thu, 16 Oct 2025 05:49:25 +0000 (13:49 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 22 Oct 2025 01:51:40 +0000 (18:51 -0700)
Add -h/--help option to display usage information and improve code style.

Link: https://lkml.kernel.org/r/20251016054927.138510-1-ye.liu@linux.dev
Signed-off-by: Ye Liu <liuye@kylinos.cn>
Cc: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/mm/page_owner_sort.c

index 894a765652acd04e206303b9861b8a1ab46eb5d9..14c67e9e84c42bc7b3ee4ec868440f6e6bbf01f4 100644 (file)
@@ -667,14 +667,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;
@@ -700,6 +701,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);