Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6913567ybh; Thu, 8 Aug 2019 07:34:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7KSAvnO5B5wzo6AGIAy4O46NJQZzt82pkHhH256DMtzlni4RTeVI5zW8CpvxRnXg5RIc2 X-Received: by 2002:a63:b904:: with SMTP id z4mr12724332pge.388.1565274864194; Thu, 08 Aug 2019 07:34:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565274864; cv=none; d=google.com; s=arc-20160816; b=HO4Lr2HorUgkPeiCUAzS3pEyqfRZ0KbROHsKmu9zJdt9H3xpGOP90fwQZMcCrKE0My uy/ltGJ09o8nqFwWlAdM5ZVZHurFi6HOdnZ7Hw4+9v8dqhkNbY5TnB/eidS6NQvnMY70 CDIFCecAtoNRIGp4zSSbwW/fozpxCO6uwqAcmz95oSpL5RRelhotTn47G8ICj2pPQNGy hRPam6tfIQbO7qafpivjvW84GYXKxFE1Z4rqFmhhuwcx3BASyyvnG92SrWffiemvXrF6 UlFw1FTCfDGyCSYQa0rfDki2vwVOW95B5+08InGDLblf1eTqhAuUlAZWygMgPIoe1DWe YugA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=kQBL0PYTul2vp4+gsnrLKbiCJ8tcxgOTtMZDvmAvlm4=; b=TU374IgH/SsaUnWlThYgfqaegVy9HBij9UqtkFTX2wXXxVS0NQaZ8CLsNIJXrs05eE fvSErDZVt79DszKGyUJZ0R1lsjh3OMJRxijjiPcTbqc7wuJGU7IFqfTb9oCXU6LA2PSt ogJhVttVI20PamDmKElFosoHaceHK+uiJiXcMXhi9XvT3AWkbmegxoI2MKS/SA53cYBH p383T1RKGlhFGV7bfwOdHU5T1nTEnqjbiJaOevQPK7bTHJ6wbyQ19WxIMvdOOgyEVI7a DXTMUllds1EA8JBbnUT/88nXzlYXfYYeK2313/kupUdr+X0QhyDUevKYZfe1wBC1pr0/ ktGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o23si55582675pfp.131.2019.08.08.07.34.07; Thu, 08 Aug 2019 07:34:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732815AbfHHO2y (ORCPT + 99 others); Thu, 8 Aug 2019 10:28:54 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:43911 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727649AbfHHO2x (ORCPT ); Thu, 8 Aug 2019 10:28:53 -0400 X-UUID: ad55d4d908ed454083dd1205e0106285-20190808 X-UUID: ad55d4d908ed454083dd1205e0106285-20190808 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 943411608; Thu, 08 Aug 2019 22:28:42 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 8 Aug 2019 22:28:44 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 8 Aug 2019 22:28:44 +0800 From: To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton CC: , , , , Miles Chen Subject: [RFC PATCH] mm: slub: print kernel addresses when CONFIG_SLUB_DEBUG=y Date: Thu, 8 Aug 2019 22:28:43 +0800 Message-ID: <20190808142843.32151-1-miles.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miles Chen This RFC patch is sent to discuss the printing address with %p issue. Since commit ad67b74d2469d9b8 ("printk: hash addresses printed with %p"), %p gives obfuscated addresses now. When CONFIG_SLUB_DEBUG=y, it is still useful to get real virtual addresses. Possible approaches are: 1. stop printing kernel addresses 2. print kernel addresses with %pK, 3. print kernel addresses with %px. 4. do nothing This patch takes %px approach and shows the output here. (%px will causes checkpatch warnings, let us ignore the warning here to have the discussion). Also, use DUMP_PREFIX_OFFSET instead of DUMP_PREFIX_ADDRESS. Before this patch: INFO: Slab 0x(____ptrval____) objects=25 used=10 fp=0x(____ptrval____) INFO: Object 0x(____ptrval____) @offset=1408 fp=0x(____ptrval____) Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone (____ptrval____): bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object (____ptrval____): 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 Redzone (____ptrval____): bb bb bb bb bb bb bb bb Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a Padding (____ptrval____): 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a ... FIX kmalloc-128: Object at 0x(____ptrval____) not freed After this patch: INFO: Slab 0xffffffbf00f57000 objects=25 used=23 fp=0xffffffc03d5c3500 INFO: Object 0xffffffc03d5c3500 @offset=13568 fp=0xffffffc03d5c0800 Redzone 00000000: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone 00000010: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone 00000020: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone 00000030: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone 00000040: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone 00000050: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone 00000060: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Redzone 00000070: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb Object 00000000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object 00000010: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object 00000020: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object 00000030: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object 00000040: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object 00000050: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object 00000060: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Object 00000070: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 Redzone 00000000: bb bb bb bb bb bb bb bb Padding 00000000: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a Padding 00000010: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a Padding 00000020: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a Padding 00000030: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a ... FIX kmalloc-128: Object at 0xffffffc03d5c3500 not freed Signed-off-by: Miles Chen --- mm/slub.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 8834563cdb4b..bc1fb8e81557 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -528,7 +528,7 @@ static void print_section(char *level, char *text, u8 *addr, unsigned int length) { metadata_access_enable(); - print_hex_dump(level, text, DUMP_PREFIX_ADDRESS, 16, 1, addr, + print_hex_dump(level, text, DUMP_PREFIX_OFFSET, 16, 1, addr, length, 1); metadata_access_disable(); } @@ -611,7 +611,7 @@ static void print_tracking(struct kmem_cache *s, void *object) static void print_page_info(struct page *page) { - pr_err("INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=0x%04lx\n", + pr_err("INFO: Slab 0x%px objects=%u used=%u fp=0x%px flags=0x%04lx\n", page, page->objects, page->inuse, page->freelist, page->flags); } @@ -653,7 +653,7 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) print_page_info(page); - pr_err("INFO: Object 0x%p @offset=%tu fp=0x%p\n\n", + pr_err("INFO: Object 0x%px @offset=%tu fp=0x%px\n\n", p, p - addr, get_freepointer(s, p)); if (s->flags & SLAB_RED_ZONE) @@ -991,7 +991,7 @@ static void trace(struct kmem_cache *s, struct page *page, void *object, int alloc) { if (s->flags & SLAB_TRACE) { - pr_info("TRACE %s %s 0x%p inuse=%d fp=0x%p\n", + pr_info("TRACE %s %s 0x%px inuse=%d fp=0x%p\n", s->name, alloc ? "alloc" : "free", object, page->inuse, @@ -1212,7 +1212,7 @@ static noinline int free_debug_processing( slab_unlock(page); spin_unlock_irqrestore(&n->list_lock, flags); if (!ret) - slab_fix(s, "Object at 0x%p not freed", object); + slab_fix(s, "Object at 0x%px not freed", object); return ret; } @@ -3693,7 +3693,7 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page, for_each_object(p, s, addr, page->objects) { if (!test_bit(slab_index(p, s, addr), map)) { - pr_err("INFO: Object 0x%p @offset=%tu\n", p, p - addr); + pr_err("INFO: Object 0x%px @offset=%tu\n", p, p - addr); print_tracking(s, p); } } -- 2.18.0