Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/mm/page_owner_sort: add help option support

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>

authored by

Ye Liu and committed by
Andrew Morton
5bf65d4a d929525c

+7 -3
+7 -3
tools/mm/page_owner_sort.c
··· 667 667 { "pid", required_argument, NULL, 1 }, 668 668 { "tgid", required_argument, NULL, 2 }, 669 669 { "name", required_argument, NULL, 3 }, 670 - { "cull", required_argument, NULL, 4 }, 671 - { "sort", required_argument, NULL, 5 }, 670 + { "cull", required_argument, NULL, 4 }, 671 + { "sort", required_argument, NULL, 5 }, 672 + { "help", no_argument, NULL, 'h' }, 672 673 { 0, 0, 0, 0}, 673 674 }; 674 675 675 676 compare_flag = COMP_NO_FLAG; 676 677 677 - while ((opt = getopt_long(argc, argv, "admnpstP", longopts, NULL)) != -1) 678 + while ((opt = getopt_long(argc, argv, "admnpstPh", longopts, NULL)) != -1) 678 679 switch (opt) { 679 680 case 'a': 680 681 compare_flag |= COMP_ALLOC; ··· 701 700 case 'n': 702 701 compare_flag |= COMP_COMM; 703 702 break; 703 + case 'h': 704 + usage(); 705 + exit(0); 704 706 case 1: 705 707 filter = filter | FILTER_PID; 706 708 fc.pids = parse_nums_list(optarg, &fc.pids_size);