linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/slub.c: Use print_hex_dump and remove unnecessary cast
@ 2009-05-20 17:25 Joe Perches
  2009-05-20 18:23 ` Christoph Lameter
  2009-05-22  8:04 ` Pekka Enberg
  0 siblings, 2 replies; 5+ messages in thread
From: Joe Perches @ 2009-05-20 17:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: H Hartley Sweeten, linux-mm, Matt Mackall, Pekka Enberg,
	Christoph Lameter, Ingo Molnar, David Rientjes,
	Eduard - Gabriel Munteanu

Signed-off-by: Joe Perches <joe@perches.com>
---
 mm/slub.c |   34 ++++------------------------------
 1 files changed, 4 insertions(+), 30 deletions(-)

diff --git a/mm/slub.c b/mm/slub.c
index 65ffda5..5b616d6 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -328,36 +328,10 @@ static char *slub_debug_slabs;
 /*
  * Object debugging
  */
-static void print_section(char *text, u8 *addr, unsigned int length)
+static void print_section(const char *text, u8 *addr, unsigned int length)
 {
-	int i, offset;
-	int newline = 1;
-	char ascii[17];
-
-	ascii[16] = 0;
-
-	for (i = 0; i < length; i++) {
-		if (newline) {
-			printk(KERN_ERR "%8s 0x%p: ", text, addr + i);
-			newline = 0;
-		}
-		printk(KERN_CONT " %02x", addr[i]);
-		offset = i % 16;
-		ascii[offset] = isgraph(addr[i]) ? addr[i] : '.';
-		if (offset == 15) {
-			printk(KERN_CONT " %s\n", ascii);
-			newline = 1;
-		}
-	}
-	if (!newline) {
-		i %= 16;
-		while (i < 16) {
-			printk(KERN_CONT "   ");
-			ascii[i] = ' ';
-			i++;
-		}
-		printk(KERN_CONT " %s\n", ascii);
-	}
+	print_hex_dump(KERN_ERR, text, DUMP_PREFIX_ADDRESS, 16, 1,
+		       addr, length, true);
 }
 
 static struct track *get_track(struct kmem_cache *s, void *object,
@@ -794,7 +768,7 @@ static void trace(struct kmem_cache *s, struct page *page, void *object,
 			page->freelist);
 
 		if (!alloc)
-			print_section("Object", (void *)object, s->objsize);
+			print_section("Object", object, s->objsize);
 
 		dump_stack();
 	}
-- 
1.6.3.1.10.g659a0.dirty

--
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] 5+ messages in thread

* Re: [PATCH] mm/slub.c: Use print_hex_dump and remove unnecessary cast
  2009-05-20 17:25 [PATCH] mm/slub.c: Use print_hex_dump and remove unnecessary cast Joe Perches
@ 2009-05-20 18:23 ` Christoph Lameter
  2009-05-20 18:42   ` Joe Perches
  2009-05-22  8:04 ` Pekka Enberg
  1 sibling, 1 reply; 5+ messages in thread
From: Christoph Lameter @ 2009-05-20 18:23 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-kernel, H Hartley Sweeten, linux-mm, Matt Mackall,
	Pekka Enberg, Ingo Molnar, David Rientjes,
	Eduard - Gabriel Munteanu

This was discussed before.

http://lkml.indiana.edu/hypermail/linux/kernel/0705.3/2671.html

Was hexdump changed? How does the output look after this change?

On Wed, 20 May 2009, Joe Perches wrote:

> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  mm/slub.c |   34 ++++------------------------------
>  1 files changed, 4 insertions(+), 30 deletions(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index 65ffda5..5b616d6 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -328,36 +328,10 @@ static char *slub_debug_slabs;
>  /*
>   * Object debugging
>   */
> -static void print_section(char *text, u8 *addr, unsigned int length)
> +static void print_section(const char *text, u8 *addr, unsigned int length)
>  {
> -	int i, offset;
> -	int newline = 1;
> -	char ascii[17];
> -
> -	ascii[16] = 0;
> -
> -	for (i = 0; i < length; i++) {
> -		if (newline) {
> -			printk(KERN_ERR "%8s 0x%p: ", text, addr + i);
> -			newline = 0;
> -		}
> -		printk(KERN_CONT " %02x", addr[i]);
> -		offset = i % 16;
> -		ascii[offset] = isgraph(addr[i]) ? addr[i] : '.';
> -		if (offset == 15) {
> -			printk(KERN_CONT " %s\n", ascii);
> -			newline = 1;
> -		}
> -	}
> -	if (!newline) {
> -		i %= 16;
> -		while (i < 16) {
> -			printk(KERN_CONT "   ");
> -			ascii[i] = ' ';
> -			i++;
> -		}
> -		printk(KERN_CONT " %s\n", ascii);
> -	}
> +	print_hex_dump(KERN_ERR, text, DUMP_PREFIX_ADDRESS, 16, 1,
> +		       addr, length, true);
>  }
>
>  static struct track *get_track(struct kmem_cache *s, void *object,
> @@ -794,7 +768,7 @@ static void trace(struct kmem_cache *s, struct page *page, void *object,
>  			page->freelist);
>
>  		if (!alloc)
> -			print_section("Object", (void *)object, s->objsize);
> +			print_section("Object", object, s->objsize);
>
>  		dump_stack();
>  	}
>

--
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] 5+ messages in thread

* Re: [PATCH] mm/slub.c: Use print_hex_dump and remove unnecessary cast
  2009-05-20 18:23 ` Christoph Lameter
@ 2009-05-20 18:42   ` Joe Perches
  2009-05-20 19:18     ` H Hartley Sweeten
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2009-05-20 18:42 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: linux-kernel, H Hartley Sweeten, linux-mm, Matt Mackall,
	Pekka Enberg, Ingo Molnar, David Rientjes,
	Eduard - Gabriel Munteanu

On Wed, 2009-05-20 at 14:23 -0400, Christoph Lameter wrote:
> This was discussed before.
> http://lkml.indiana.edu/hypermail/linux/kernel/0705.3/2671.html

You've got a good memory.

> Was hexdump changed?

It seems not.

> How does the output look after this change?

>From reading the code, the last column is unaligned.

I did submit a patch to fix hexdump once.
http://lkml.org/lkml/2007/12/6/304


--
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] 5+ messages in thread

* RE: [PATCH] mm/slub.c: Use print_hex_dump and remove unnecessary cast
  2009-05-20 18:42   ` Joe Perches
@ 2009-05-20 19:18     ` H Hartley Sweeten
  0 siblings, 0 replies; 5+ messages in thread
From: H Hartley Sweeten @ 2009-05-20 19:18 UTC (permalink / raw)
  To: Joe Perches, Christoph Lameter
  Cc: linux-kernel, linux-mm, Matt Mackall, Pekka Enberg, Ingo Molnar,
	David Rientjes, Eduard - Gabriel Munteanu

On Wednesday, May 20, 2009 11:43 AM, Joe Perches wrote:
> On Wed, 2009-05-20 at 14:23 -0400, Christoph Lameter wrote:
>> This was discussed before.
>> http://lkml.indiana.edu/hypermail/linux/kernel/0705.3/2671.html
>
> You've got a good memory.
>
>> Was hexdump changed?
>
> It seems not.
>
>> How does the output look after this change?
>>
>> From reading the code, the last column is unaligned.
>
> I did submit a patch to fix hexdump once.
> http://lkml.org/lkml/2007/12/6/304

>From what I can tell the current code does properly align the
ascii output.

I just chopped the necessary functions out of the kernel and
created a test program.  If I pass the string:

"This is a sample buffer"

I get the following output:

prefix_type = DUMP_PREFIX_NONE

<7>buffer: 54 68 69 73 20 69 73 20 61 20 73 61 6d 70 6c 65  This is a sample
<7>buffer: 20 62 75 66 66 65 72                              buffer

prefix_type = DUMP_PREFIX_ADDRESS

<7>buffer: 0x804a008: 54 68 69 73 20 69 73 20 61 20 73 61 6d 70 6c 65  This is a sample
<7>buffer: 0x804a018: 20 62 75 66 66 65 72                              buffer

prefix_type = DUMP_PREFIX_OFFSET

<7>buffer: 00000000: 54 68 69 73 20 69 73 20 61 20 73 61 6d 70 6c 65  This is a sample
<7>buffer: 00000010: 20 62 75 66 66 65 72                              buffer

Regards,
Hartley

--
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] 5+ messages in thread

* Re: [PATCH] mm/slub.c: Use print_hex_dump and remove unnecessary cast
  2009-05-20 17:25 [PATCH] mm/slub.c: Use print_hex_dump and remove unnecessary cast Joe Perches
  2009-05-20 18:23 ` Christoph Lameter
@ 2009-05-22  8:04 ` Pekka Enberg
  1 sibling, 0 replies; 5+ messages in thread
From: Pekka Enberg @ 2009-05-22  8:04 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-kernel, H Hartley Sweeten, linux-mm, Matt Mackall,
	Christoph Lameter, Ingo Molnar, David Rientjes,
	Eduard - Gabriel Munteanu

On Wed, 2009-05-20 at 10:25 -0700, Joe Perches wrote:
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  mm/slub.c |   34 ++++------------------------------
>  1 files changed, 4 insertions(+), 30 deletions(-)

I am more than happy to merge this patch if the hexdump issues are
resolved.

			Pekka

--
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] 5+ messages in thread

end of thread, other threads:[~2009-05-22  8:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-20 17:25 [PATCH] mm/slub.c: Use print_hex_dump and remove unnecessary cast Joe Perches
2009-05-20 18:23 ` Christoph Lameter
2009-05-20 18:42   ` Joe Perches
2009-05-20 19:18     ` H Hartley Sweeten
2009-05-22  8:04 ` Pekka Enberg

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