linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Documentation/vm/page-types enhancements
@ 2009-11-05 20:21 Alex Chiang
  2009-11-05 20:21 ` [PATCH v2 1/3] page-types: learn to describe flags directly from command line Alex Chiang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Alex Chiang @ 2009-11-05 20:21 UTC (permalink / raw)
  To: akpm, fengguang.wu; +Cc: linux-mm, linux-kernel

This is v2 of teaching page-types to decode page flags directly from
the command line.

v1 -> v2:
	- Use Fengguang's implementation
	- Exit early when using new -d|--describe option

---

Alex Chiang (2):
      page-types: whitespace alignment
      page-types: exit early when invoked with -d|--describe

Wu Fengguang (1):
      page-types: learn to describe flags directly from command line


 Documentation/vm/page-types.c |   60 +++++++++++++++++++++++++++--------------
 1 files changed, 39 insertions(+), 21 deletions(-)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH v2 1/3] page-types: learn to describe flags directly from command line
  2009-11-05 20:21 [PATCH v2 0/3] Documentation/vm/page-types enhancements Alex Chiang
@ 2009-11-05 20:21 ` Alex Chiang
  2009-11-06  2:13   ` Wu Fengguang
  2009-11-05 20:21 ` [PATCH v2 2/3] page-types: whitespace alignment Alex Chiang
  2009-11-05 20:21 ` [PATCH v2 3/3] page-types: exit early when invoked with -d|--describe Alex Chiang
  2 siblings, 1 reply; 7+ messages in thread
From: Alex Chiang @ 2009-11-05 20:21 UTC (permalink / raw)
  To: akpm, fengguang.wu; +Cc: Haicheng Li, linux-mm, Andi Kleen, linux-kernel

From: Wu Fengguang <fengguang.wu@intel.com>

Teach page-types to describe page flags directly from the command
line.

Why is this useful? For instance, if you're using memory hotplug
and see this in /var/log/messages:

	kernel: removing from LRU failed 3836dd0/1/1e00000000000010

It would be nice to decode those page flags without staring at
the source.

Example usage and output:

# Documentation/vm/page-types -d 0x10
0x0000000000000010	____D_____________________________	dirty

# Documentation/vm/page-types -d anon
0x0000000000001000	____________a_____________________	anonymous

# Documentation/vm/page-types -d anon,0x10
0x0000000000001010	____D_______a_____________________	dirty,anonymous

[achiang@hp.com: documentation]
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Haicheng Li <haicheng.li@intel.com>
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 Documentation/vm/page-types.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/Documentation/vm/page-types.c b/Documentation/vm/page-types.c
index 3ec4f2a..a93c28e 100644
--- a/Documentation/vm/page-types.c
+++ b/Documentation/vm/page-types.c
@@ -674,6 +674,7 @@ static void usage(void)
 	printf(
 "page-types [options]\n"
 "            -r|--raw                  Raw mode, for kernel developers\n"
+"            -d|--describe flags        Describe flags\n"
 "            -a|--addr    addr-spec    Walk a range of pages\n"
 "            -b|--bits    bits-spec    Walk pages with specified bits\n"
 "            -p|--pid     pid          Walk process address space\n"
@@ -686,6 +687,10 @@ static void usage(void)
 "            -X|--hwpoison             hwpoison pages\n"
 "            -x|--unpoison             unpoison pages\n"
 "            -h|--help                 Show this usage message\n"
+"flags:\n"
+"            0x10                      bitfield format, e.g.\n"
+"            anon                      bit-name, e.g.\n"
+"            0x10,anon                 comma-separated list, e.g.\n"
 "addr-spec:\n"
 "            N                         one page at offset N (unit: pages)\n"
 "            N+M                       pages range from N to N+M-1\n"
@@ -884,12 +889,22 @@ static void parse_bits_mask(const char *optarg)
 	add_bits_filter(mask, bits);
 }
 
+static void describe_flags(const char *optarg)
+{
+	uint64_t flags = parse_flag_names(optarg, 0);
+
+	printf("0x%016llx\t%s\t%s\n",
+		(unsigned long long)flags,
+		page_flag_name(flags),
+		page_flag_longname(flags));
+}
 
 static struct option opts[] = {
 	{ "raw"       , 0, NULL, 'r' },
 	{ "pid"       , 1, NULL, 'p' },
 	{ "file"      , 1, NULL, 'f' },
 	{ "addr"      , 1, NULL, 'a' },
+	{ "describe"  , 1, NULL, 'd' },
 	{ "bits"      , 1, NULL, 'b' },
 	{ "list"      , 0, NULL, 'l' },
 	{ "list-each" , 0, NULL, 'L' },
@@ -907,7 +922,7 @@ int main(int argc, char *argv[])
 	page_size = getpagesize();
 
 	while ((c = getopt_long(argc, argv,
-				"rp:f:a:b:lLNXxh", opts, NULL)) != -1) {
+				"rp:f:a:b:d:lLNXxh", opts, NULL)) != -1) {
 		switch (c) {
 		case 'r':
 			opt_raw = 1;
@@ -924,6 +939,10 @@ int main(int argc, char *argv[])
 		case 'b':
 			parse_bits_mask(optarg);
 			break;
+		case 'd':
+			opt_no_summary = 1;
+			describe_flags(optarg);
+			break;
 		case 'l':
 			opt_list = 1;
 			break;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH v2 2/3] page-types: whitespace alignment
  2009-11-05 20:21 [PATCH v2 0/3] Documentation/vm/page-types enhancements Alex Chiang
  2009-11-05 20:21 ` [PATCH v2 1/3] page-types: learn to describe flags directly from command line Alex Chiang
@ 2009-11-05 20:21 ` Alex Chiang
  2009-11-06  2:14   ` Wu Fengguang
  2009-11-05 20:21 ` [PATCH v2 3/3] page-types: exit early when invoked with -d|--describe Alex Chiang
  2 siblings, 1 reply; 7+ messages in thread
From: Alex Chiang @ 2009-11-05 20:21 UTC (permalink / raw)
  To: akpm, fengguang.wu; +Cc: linux-mm, linux-kernel

Align the output when page-type -h is invoked.

Signed-off-by: Alex Chiang <achiang@hp.com>
---

 Documentation/vm/page-types.c |   46 +++++++++++++++++++++--------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/Documentation/vm/page-types.c b/Documentation/vm/page-types.c
index a93c28e..9c09eb5 100644
--- a/Documentation/vm/page-types.c
+++ b/Documentation/vm/page-types.c
@@ -673,35 +673,35 @@ static void usage(void)
 
 	printf(
 "page-types [options]\n"
-"            -r|--raw                  Raw mode, for kernel developers\n"
+"            -r|--raw                   Raw mode, for kernel developers\n"
 "            -d|--describe flags        Describe flags\n"
-"            -a|--addr    addr-spec    Walk a range of pages\n"
-"            -b|--bits    bits-spec    Walk pages with specified bits\n"
-"            -p|--pid     pid          Walk process address space\n"
+"            -a|--addr     addr-spec    Walk a range of pages\n"
+"            -b|--bits     bits-spec    Walk pages with specified bits\n"
+"            -p|--pid      pid          Walk process address space\n"
 #if 0 /* planned features */
-"            -f|--file    filename     Walk file address space\n"
+"            -f|--file     filename     Walk file address space\n"
 #endif
-"            -l|--list                 Show page details in ranges\n"
-"            -L|--list-each            Show page details one by one\n"
-"            -N|--no-summary           Don't show summay info\n"
-"            -X|--hwpoison             hwpoison pages\n"
-"            -x|--unpoison             unpoison pages\n"
-"            -h|--help                 Show this usage message\n"
+"            -l|--list                  Show page details in ranges\n"
+"            -L|--list-each             Show page details one by one\n"
+"            -N|--no-summary            Don't show summary info\n"
+"            -X|--hwpoison              hwpoison pages\n"
+"            -x|--unpoison              unpoison pages\n"
+"            -h|--help                  Show this usage message\n"
 "flags:\n"
-"            0x10                      bitfield format, e.g.\n"
-"            anon                      bit-name, e.g.\n"
-"            0x10,anon                 comma-separated list, e.g.\n"
+"            0x10                       bitfield format, e.g.\n"
+"            anon                       bit-name, e.g.\n"
+"            0x10,anon                  comma-separated list, e.g.\n"
 "addr-spec:\n"
-"            N                         one page at offset N (unit: pages)\n"
-"            N+M                       pages range from N to N+M-1\n"
-"            N,M                       pages range from N to M-1\n"
-"            N,                        pages range from N to end\n"
-"            ,M                        pages range from 0 to M-1\n"
+"            N                          one page at offset N (unit: pages)\n"
+"            N+M                        pages range from N to N+M-1\n"
+"            N,M                        pages range from N to M-1\n"
+"            N,                         pages range from N to end\n"
+"            ,M                         pages range from 0 to M-1\n"
 "bits-spec:\n"
-"            bit1,bit2                 (flags & (bit1|bit2)) != 0\n"
-"            bit1,bit2=bit1            (flags & (bit1|bit2)) == bit1\n"
-"            bit1,~bit2                (flags & (bit1|bit2)) == bit1\n"
-"            =bit1,bit2                flags == (bit1|bit2)\n"
+"            bit1,bit2                  (flags & (bit1|bit2)) != 0\n"
+"            bit1,bit2=bit1             (flags & (bit1|bit2)) == bit1\n"
+"            bit1,~bit2                 (flags & (bit1|bit2)) == bit1\n"
+"            =bit1,bit2                 flags == (bit1|bit2)\n"
 "bit-names:\n"
 	);
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH v2 3/3] page-types: exit early when invoked with -d|--describe
  2009-11-05 20:21 [PATCH v2 0/3] Documentation/vm/page-types enhancements Alex Chiang
  2009-11-05 20:21 ` [PATCH v2 1/3] page-types: learn to describe flags directly from command line Alex Chiang
  2009-11-05 20:21 ` [PATCH v2 2/3] page-types: whitespace alignment Alex Chiang
@ 2009-11-05 20:21 ` Alex Chiang
  2009-11-06  2:15   ` Wu Fengguang
  2 siblings, 1 reply; 7+ messages in thread
From: Alex Chiang @ 2009-11-05 20:21 UTC (permalink / raw)
  To: akpm, fengguang.wu; +Cc: Haicheng Li, linux-mm, Andi Kleen, linux-kernel

On a system with large amount of memory (256GB), invoking page-types
can take quite a long time, which is unreasonable considering the user
only wants a description of the flags:

	# time ./page-types -d 0x10
	0x0000000000000010	____D_____________________________	dirty

	real	0m34.285s
	user	0m1.966s
	sys	0m32.313s

This is because we still walk the entire address range.

Exiting early seems like a reasonble solution:

# time ./page-types -d 0x10
	0x0000000000000010	____D_____________________________	dirty

	real	0m0.007s
	user	0m0.001s
	sys	0m0.005s

Cc: Andi Kleen <andi@firstfloor.org>
Cc: Haicheng Li <haicheng.li@intel.com>
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 Documentation/vm/page-types.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/Documentation/vm/page-types.c b/Documentation/vm/page-types.c
index 9c09eb5..9cf50ab 100644
--- a/Documentation/vm/page-types.c
+++ b/Documentation/vm/page-types.c
@@ -940,9 +940,8 @@ int main(int argc, char *argv[])
 			parse_bits_mask(optarg);
 			break;
 		case 'd':
-			opt_no_summary = 1;
 			describe_flags(optarg);
-			break;
+			exit(0);
 		case 'l':
 			opt_list = 1;
 			break;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH v2 1/3] page-types: learn to describe flags directly from command line
  2009-11-05 20:21 ` [PATCH v2 1/3] page-types: learn to describe flags directly from command line Alex Chiang
@ 2009-11-06  2:13   ` Wu Fengguang
  0 siblings, 0 replies; 7+ messages in thread
From: Wu Fengguang @ 2009-11-06  2:13 UTC (permalink / raw)
  To: Alex Chiang; +Cc: akpm, Li, Haicheng, linux-mm, Andi Kleen, linux-kernel

On Fri, Nov 06, 2009 at 04:21:16AM +0800, Alex Chiang wrote:
> From: Wu Fengguang <fengguang.wu@intel.com>
> 
> Teach page-types to describe page flags directly from the command
> line.
> 
> Why is this useful? For instance, if you're using memory hotplug
> and see this in /var/log/messages:
> 
> 	kernel: removing from LRU failed 3836dd0/1/1e00000000000010
> 
> It would be nice to decode those page flags without staring at
> the source.
> 
> Example usage and output:
> 
> # Documentation/vm/page-types -d 0x10
> 0x0000000000000010	____D_____________________________	dirty
> 
> # Documentation/vm/page-types -d anon
> 0x0000000000001000	____________a_____________________	anonymous
> 
> # Documentation/vm/page-types -d anon,0x10
> 0x0000000000001010	____D_______a_____________________	dirty,anonymous

Good examples, thanks!

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>

> [achiang@hp.com: documentation]
> Cc: Andi Kleen <andi@firstfloor.org>
> Cc: Haicheng Li <haicheng.li@intel.com>
> Signed-off-by: Alex Chiang <achiang@hp.com>
> ---
> 
>  Documentation/vm/page-types.c |   21 ++++++++++++++++++++-
>  1 files changed, 20 insertions(+), 1 deletions(-)
> 
> diff --git a/Documentation/vm/page-types.c b/Documentation/vm/page-types.c
> index 3ec4f2a..a93c28e 100644
> --- a/Documentation/vm/page-types.c
> +++ b/Documentation/vm/page-types.c
> @@ -674,6 +674,7 @@ static void usage(void)
>  	printf(
>  "page-types [options]\n"
>  "            -r|--raw                  Raw mode, for kernel developers\n"
> +"            -d|--describe flags        Describe flags\n"

"Decode flags number; Encode flags name"?

Thanks,
Fengguang

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH v2 2/3] page-types: whitespace alignment
  2009-11-05 20:21 ` [PATCH v2 2/3] page-types: whitespace alignment Alex Chiang
@ 2009-11-06  2:14   ` Wu Fengguang
  0 siblings, 0 replies; 7+ messages in thread
From: Wu Fengguang @ 2009-11-06  2:14 UTC (permalink / raw)
  To: Alex Chiang; +Cc: akpm, linux-mm, linux-kernel

Acked-by: Wu Fengguang <fengguang.wu@intel.com>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH v2 3/3] page-types: exit early when invoked with -d|--describe
  2009-11-05 20:21 ` [PATCH v2 3/3] page-types: exit early when invoked with -d|--describe Alex Chiang
@ 2009-11-06  2:15   ` Wu Fengguang
  0 siblings, 0 replies; 7+ messages in thread
From: Wu Fengguang @ 2009-11-06  2:15 UTC (permalink / raw)
  To: Alex Chiang; +Cc: akpm, Li, Haicheng, linux-mm, Andi Kleen, linux-kernel


>  		case 'd':
> -			opt_no_summary = 1;
>  			describe_flags(optarg);
> -			break;
> +			exit(0);
>  		case 'l':
>  			opt_list = 1;
>  			break;
 
Good catch, thanks!

Acked-by: Wu Fengguang <fengguang.wu@intel.com>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2009-11-06  2:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-05 20:21 [PATCH v2 0/3] Documentation/vm/page-types enhancements Alex Chiang
2009-11-05 20:21 ` [PATCH v2 1/3] page-types: learn to describe flags directly from command line Alex Chiang
2009-11-06  2:13   ` Wu Fengguang
2009-11-05 20:21 ` [PATCH v2 2/3] page-types: whitespace alignment Alex Chiang
2009-11-06  2:14   ` Wu Fengguang
2009-11-05 20:21 ` [PATCH v2 3/3] page-types: exit early when invoked with -d|--describe Alex Chiang
2009-11-06  2:15   ` Wu Fengguang

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