Skip to content

Commit ffc79d2

Browse files
Sebastian Andrzej Siewiorpenberg
authored andcommitted
slub: use print_hex_dump
Less code and same functionality. The output would be: | Object c7428000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk | Object c7428010: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk | Object c7428020: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk | Object c7428030: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 kkkkkkkkkkk. | Redzone c742803c: bb bb bb bb .... | Padding c7428064: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZZZZZZZZZ | Padding c7428074: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZZZZZ Acked-by: Christoph Lameter <cl@linux.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Pekka Enberg <penberg@kernel.org>
1 parent fdde6ab commit ffc79d2

1 file changed

Lines changed: 9 additions & 35 deletions

File tree

‎mm/slub.c‎

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -467,34 +467,8 @@ static int disable_higher_order_debug;
467467
*/
468468
static void print_section(char *text, u8 *addr, unsigned int length)
469469
{
470-
int i, offset;
471-
int newline = 1;
472-
char ascii[17];
473-
474-
ascii[16] = 0;
475-
476-
for (i = 0; i < length; i++) {
477-
if (newline) {
478-
printk(KERN_ERR "%8s 0x%p: ", text, addr + i);
479-
newline = 0;
480-
}
481-
printk(KERN_CONT " %02x", addr[i]);
482-
offset = i % 16;
483-
ascii[offset] = isgraph(addr[i]) ? addr[i] : '.';
484-
if (offset == 15) {
485-
printk(KERN_CONT " %s\n", ascii);
486-
newline = 1;
487-
}
488-
}
489-
if (!newline) {
490-
i %= 16;
491-
while (i < 16) {
492-
printk(KERN_CONT " ");
493-
ascii[i] = ' ';
494-
i++;
495-
}
496-
printk(KERN_CONT " %s\n", ascii);
497-
}
470+
print_hex_dump(KERN_ERR, text, DUMP_PREFIX_ADDRESS, 16, 1, addr,
471+
length, 1);
498472
}
499473

500474
static struct track *get_track(struct kmem_cache *s, void *object,
@@ -625,12 +599,12 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p)
625599
p, p - addr, get_freepointer(s, p));
626600

627601
if (p > addr + 16)
628-
print_section("Bytes b4", p - 16, 16);
629-
630-
print_section("Object", p, min_t(unsigned long, s->objsize, PAGE_SIZE));
602+
print_section("Bytes b4 ", p - 16, 16);
631603

604+
print_section("Object ", p, min_t(unsigned long, s->objsize,
605+
PAGE_SIZE));
632606
if (s->flags & SLAB_RED_ZONE)
633-
print_section("Redzone", p + s->objsize,
607+
print_section("Redzone ", p + s->objsize,
634608
s->inuse - s->objsize);
635609

636610
if (s->offset)
@@ -643,7 +617,7 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p)
643617

644618
if (off != s->size)
645619
/* Beginning of the filler is the free pointer */
646-
print_section("Padding", p + off, s->size - off);
620+
print_section("Padding ", p + off, s->size - off);
647621

648622
dump_stack();
649623
}
@@ -838,7 +812,7 @@ static int slab_pad_check(struct kmem_cache *s, struct page *page)
838812
end--;
839813

840814
slab_err(s, page, "Padding overwritten. 0x%p-0x%p", fault, end - 1);
841-
print_section("Padding", end - remainder, remainder);
815+
print_section("Padding ", end - remainder, remainder);
842816

843817
restore_bytes(s, "slab padding", POISON_INUSE, end - remainder, end);
844818
return 0;
@@ -987,7 +961,7 @@ static void trace(struct kmem_cache *s, struct page *page, void *object,
987961
page->freelist);
988962

989963
if (!alloc)
990-
print_section("Object", (void *)object, s->objsize);
964+
print_section("Object ", (void *)object, s->objsize);
991965

992966
dump_stack();
993967
}

0 commit comments

Comments
 (0)