tools/mm/slabinfo: recognize --partial/-p option
Subsystems (2)
PATCH 1/1 tools/mm/slabinfo: recognize --partial/-p option
The long option "partial" maps to 'p' but the short options string and switch handled 'P', causing -p/--partial to be rejected as invalid. Use lowercase 'p' consistently in the getopt short string and the switch to enable sorting by partial slabs.
--- tools/mm/slabinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/mm/slabinfo.c +3 -3
@@ -125,7 +125,7 @@ static void usage(void)"-n|--numa Show NUMA information\n" "-N|--lines=K Show the first K slabs\n" "-o|--ops Show kmem_cache_ops\n" -"-P|--partial Sort by number of partial slabs\n" +"-p|--partial Sort by number of partial slabs\n" "-r|--report Detailed report on single slabs\n" "-s|--shrink Shrink slabs\n" "-S|--Size Sort by size\n"
@@ -1427,7 +1427,7 @@ int main(int argc, char *argv[]) page_size =getpagesize (); -while ((c =getopt_long (argc, argv,"aABd::DefhilLnN:oPrsStTUvXz1" , +while ((c =getopt_long (argc, argv,"aABd::DefhilLnN:oprsStTUvXz1" , opts,NULL )) !=-1 )switch (c) {case 'a' :
@@ -1481,7 +1481,7 @@ int main(int argc, char *argv[])case 'r' : show_report =1 ;break ; -case 'P' : +case 'p' : sort_partial =1 ;break ;case 's' :
Signature · 1 line
2.34.1
Quoted 7 lines · Kaushlendra Kumar
The long option "partial" maps to 'p' but the short options string and switch handled 'P', causing -p/--partial to be rejected as invalid. Use lowercase 'p' consistently in the getopt short string and the switch to enable sorting by partial slabs.
Signed-off-by Kaushlendra Kumar <[email protected]>---
I think breaking an existing option -P is not a good idea. Can we make --Partial work instead of breaking -P option?
Quoted 38 lines
tools/mm/slabinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)tools/mm/slabinfo.c +3
-3@@ -125,7 +125,7 @@ static void usage(void)"-n|--numa Show NUMA information\n" "-N|--lines=K Show the first K slabs\n" "-o|--ops Show kmem_cache_ops\n" -"-P|--partial Sort by number of partial slabs\n" +"-p|--partial Sort by number of partial slabs\n" "-r|--report Detailed report on single slabs\n" "-s|--shrink Shrink slabs\n" "-S|--Size Sort by size\n" @@ -1427,7 +1427,7 @@ int main(int argc, char *argv[]) page_size =getpagesize (); -while ((c =getopt_long (argc, argv,"aABd::DefhilLnN:oPrsStTUvXz1" , +while ((c =getopt_long (argc, argv,"aABd::DefhilLnN:oprsStTUvXz1" , opts,NULL )) !=-1 )switch (c) {case 'a' :@@ -1481,7 +1481,7 @@ int main(int argc, char *argv[])case 'r' : show_report =1 ;break ; -case 'P' : +case 'p' : sort_partial =1 ;break ;case 's' :Signature · 1 line
2.34.1
Signature · 2 lines
Cheers, Harry / Hyeonggon
-----Original Message-----
From: Harry Yoo <[email protected]>
Sent: Monday, December 8, 2025 3:16 PM
To: Kumar, Kaushlendra <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] tools/mm/slabinfo: recognize --partial/-p option
Quoted 7 lines · Kaushlendra Kumar
The long option "partial" maps to 'p' but the short options string and switch handled 'P', causing -p/--partial to be rejected as invalid. Use lowercase 'p' consistently in the getopt short string and the switch to enable sorting by partial slabs.
Signed-off-by Kaushlendra Kumar <[email protected]>---
I think breaking an existing option -P is not a good idea. Can we make --Partial work instead of breaking -P option?
Quoted 37 lines
tools/mm/slabinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)tools/mm/slabinfo.c index renamed from tools/mm/slabinfo.c +0
-0
7c51d283504d..7f239da26ed2100644tools/mm/slabinfo.c +3
-3@@ -125,7 +125,7 @@ static void usage(void)"-n|--numa Show NUMA information\n" "-N|--lines=K Show the first K slabs\n" "-o|--ops Show kmem_cache_ops\n" -"-P|--partial Sort by number of partial slabs\n" +"-p|--partial Sort by number of partial slabs\n" "-r|--report Detailed report on single slabs\n" "-s|--shrink Shrink slabs\n" "-S|--Size Sort by size\n" @@ -1427,7 +1427,7 @@ int main(int argc, char *argv[]) page_size =getpagesize (); -while ((c =getopt_long (argc, argv,"aABd::DefhilLnN:oPrsStTUvXz1" , +while ((c =getopt_long (argc, argv,"aABd::DefhilLnN:oprsStTUvXz1" , opts,NULL )) !=-1 )switch (c) {case 'a' :@@ -1481,7 +1481,7 @@ int main(int argc, char *argv[])case 'r' : show_report =1 ;break ; -case 'P' : + case 'p': On Mon, Dec 08, 2025, Harry Hyeonggon Yoo wrote:Quoted 5 lines · Kaushlendra Kumar
The long option "partial" maps to 'p' but the short options string and switch handled 'P', causing -p/--partial to be rejected as invalid. Use lowercase 'p' consistently in the getopt short string and the switch to enable sorting by partial slabs.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Kaushlendra Kumar <[email protected]>---
I think breaking an existing option -P is not a good idea. Can we make --Partial work instead of breaking -P option?
Thanks for catching this. You're right-changing -P to -p would break existing scripts relying on the uppercase flag.
I'll respin the patch to keep -P working.
Will send v2 shortly.
-Kaushlendra