[PATCH 2/3 -mm] slub: use lib/hexdump

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Randy Dunlap <[email protected]>

Convert slub error memory dump functions to use lib/hexdump routines.
Completely eliminate slub's print_section() function.

Signed-off-by: Randy Dunlap <[email protected]>
---
 mm/slub.c |   53 ++++++++++++-----------------------------------------
 1 file changed, 12 insertions(+), 41 deletions(-)

--- linux-2622-rc2mm1-slub.orig/mm/slub.c
+++ linux-2622-rc2mm1-slub/mm/slub.c
@@ -8,6 +8,7 @@
  * (C) 2007 SGI, Christoph Lameter <[email protected]>
  */
 
+#include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/bit_spinlock.h>
@@ -334,41 +335,6 @@ static int slub_debug;
 
 static char *slub_debug_slabs;
 
-/*
- * Object debugging
- */
-static void print_section(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 "%10s 0x%p: ", text, addr + i);
-			newline = 0;
-		}
-		printk(" %02x", addr[i]);
-		offset = i % 16;
-		ascii[offset] = isgraph(addr[i]) ? addr[i] : '.';
-		if (offset == 15) {
-			printk(" %s\n",ascii);
-			newline = 1;
-		}
-	}
-	if (!newline) {
-		i %= 16;
-		while (i < 16) {
-			printk("   ");
-			ascii[i] = ' ';
-			i++;
-		}
-		printk(" %s\n", ascii);
-	}
-}
-
 static struct track *get_track(struct kmem_cache *s, void *object,
 	enum track_item alloc)
 {
@@ -425,8 +391,8 @@ static void print_trailer(struct kmem_ca
 	unsigned int off;	/* Offset of last byte */
 
 	if (s->flags & SLAB_RED_ZONE)
-		print_section("Redzone", p + s->objsize,
-			s->inuse - s->objsize);
+		print_hex_dump(KERN_ERR, "   Redzone ", DUMP_PREFIX_ADDRESS,
+			16, 1, p + s->objsize, s->inuse - s->objsize, 1);
 
 	printk(KERN_ERR "FreePointer 0x%p -> 0x%p\n",
 			p + s->offset,
@@ -445,7 +411,8 @@ static void print_trailer(struct kmem_ca
 
 	if (off != s->size)
 		/* Beginning of the filler is the free pointer */
-		print_section("Filler", p + off, s->size - off);
+		print_hex_dump(KERN_ERR, "    Filler ", DUMP_PREFIX_ADDRESS,
+			16, 1, p + off, s->size - off, 1);
 }
 
 static void object_err(struct kmem_cache *s, struct page *page,
@@ -458,8 +425,10 @@ static void object_err(struct kmem_cache
 	printk(KERN_ERR "    offset=%tu flags=0x%04lx inuse=%u freelist=0x%p\n",
 		object - addr, page->flags, page->inuse, page->freelist);
 	if (object > addr + 16)
-		print_section("Bytes b4", object - 16, 16);
-	print_section("Object", object, min(s->objsize, 128));
+		print_hex_dump(KERN_ERR, "  Bytes b4 ", DUMP_PREFIX_ADDRESS,
+			16, 1, object - 16, 16, 1);
+	print_hex_dump(KERN_ERR, "    Object ", DUMP_PREFIX_ADDRESS, 16, 1,
+		object, min(s->objsize, 128), 1);
 	print_trailer(s, object);
 	dump_stack();
 }
@@ -759,7 +728,9 @@ static void trace(struct kmem_cache *s, 
 			page->freelist);
 
 		if (!alloc)
-			print_section("Object", (void *)object, s->objsize);
+			print_hex_dump(KERN_ERR, "    Object ",
+				DUMP_PREFIX_ADDRESS, 16, 1,
+				(void *)object, s->objsize, 1);
 
 		dump_stack();
 	}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux