From patchwork Sun Oct 8 02:33:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13412516 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F21EE95A89 for ; Sun, 8 Oct 2023 01:33:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D4298D0018; Sat, 7 Oct 2023 21:33:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0842A8D0001; Sat, 7 Oct 2023 21:33:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E8D1C8D0018; Sat, 7 Oct 2023 21:33:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DB4CE8D0001 for ; Sat, 7 Oct 2023 21:33:27 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B6EC3402F6 for ; Sun, 8 Oct 2023 01:33:27 +0000 (UTC) X-FDA: 81320571654.19.245529F Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf23.hostedemail.com (Postfix) with ESMTP id 1062C140012 for ; Sun, 8 Oct 2023 01:33:23 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696728805; a=rsa-sha256; cv=none; b=e/rycKrOPO/rCrWjv8JB46VF2qzDp54I4r2kWpa/7L3KfZPT8EoKgx6RefzxeT5MzSPRnB UkpA1qKZmmH9ZTvs3tAihm/88iSFfOpES5wAvp7VPR+Hhyp2PO093TNvCaagkrAygZ2t9+ qZeMtPCjIsvv406vd3bWhSJz0JWSW0A= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696728805; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J2Is8BYDc9rNwSqPl1bKHd3fAAzOA0SWizeVob94fOU=; b=EyFv2Q++S079XdZrxwaH9lr53xyCvTc/EiN4e4yGFVQnc88XNwPZxaI4+8uWei2VRo1Drl 4VSygrPAg8CxF54MFy7yPJwbm8Kv/WeTkdhHPmC/utgoAjutFh3LjJ3RszyCncc6VDHKBq /SKTNmG4zP/QLuyXesRCIi4wPeQulIw= Received: from dggpemm500009.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4S34P56rbsz1P6g0; Sun, 8 Oct 2023 09:30:49 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Sun, 8 Oct 2023 09:33:18 +0800 From: Liu Shixin To: Catalin Marinas , Patrick Wang , Andrew Morton CC: , , Liu Shixin Subject: [PATCH v2 4/4] mm/kmemleak: fix print format of pointer in pr_debug() Date: Sun, 8 Oct 2023 10:33:17 +0800 Message-ID: <20231008023317.3015699-5-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231008023317.3015699-1-liushixin2@huawei.com> References: <20231008023317.3015699-1-liushixin2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1062C140012 X-Stat-Signature: 4bhqbxqcttypswbeth3hkarhuqtxqb7b X-HE-Tag: 1696728803-514170 X-HE-Meta: U2FsdGVkX19/bSe4AyWd0gjI7RiqlkNDhlBXdop6a3e0lvfQW0SAlWze6oxaab5nhzqJEWnbIUDFMhwU5eWXqUAU8aTUAj0HIbPFpDaeyxVtARy4OYjqw/IVgxaQKuFQFHAiz8LIeJt7YBoOGKB2CqmXaaWbc/o2VJIzfQeSCWQUV+mkeaO9BQTUWIk6SSUJKBUkw6oe2f2QP6Ly9gRKFI05oqDUHcrL1GKjhAHNm699vM19j1R/wrjp68DQp+m3IgmMw4+1MZoz3QgUjOhxGfr4pSrp7IjEemGQp/lXjh9qeGvDCcnEtPOINOqDxPoa+W/Elo14iDFHMSZmppTXIXXzzTyxwDTkJEaTd9vuG0VccWWbNY15GPs9sBCu9Ku2umMMdJW0bhTV+M0Xz2ahkSWubAqYIO/Vj9/WxkARSl+fSnHHvChC1m6QcAjej5qX9zy3CwRUUwxg4G/gqWzw8d1drYFDm3nwvqJViInLmzG2EUYXLOStCkAspPwmbLY/UBmI0T/n7lBUR0jBMgiTTmJcNmFQ7Bj7NhgDc7EdBL4yRMaqL+jJeiWvcS5ec3sTHDWwF+LoH2e15zpQzA60x61wvC3/F3dIjlTQ6JSYeaDnvcO9n+HgG8BintIhK9PTRZ6F77LJhMLpPSmM/EAUfvBzoieUNWIwSLEO1MxkQtyaNtEoexhjA6Y0kfRP2fYDDpjjIDxyYsrbTgGNVjDKiTyDwJeIs8VASkPkxR5ZPEd8KF1tgm3bEVXHbwClmckP/8Ht2KzPSmjqdG0SbejSmk85NgTF/IU+roJVs5wTGWTaW0+WQqYaABpmFM9VIQgeTQ7Yw+VDA2vc55zaGr8Q9hSTWNpe7kKifu1OimjVcBm5GUxVo7eRAKAjCXLZOpNvgiCTRxHU1kB7wqRFCTqS3tt/sh0G+nrXz9eFk3Kp/vF/ZdImVaz4Y43rRaWXLa71y6s1h6sLIMG01NHQ9jd n2QAWtVb v7Jttlm1icJ0at6WXlft82XVwOUlIkbIzL6P/8UW+sVRXIiRaXNsx06qyIpu6sHDnZkvdjzwh+LQDurdnBsT1Z2UJMLRBVPalMl08cv8jWnH5k7vksqDA7oXMRViR+UhUfr/p4a66ERWNea0SMJbzZGe7Aj7teYb4mTM7W4RTNdY03UAZBILS2DzeXc5e9FDLp80DfhgPAet4IitYIU3dX/wiPkllFoKmWf93VPmi3XMBd9GycRwNIDYz7E74T74z9x/w X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: With 0x%p, the pointer will be hashed and print (____ptrval____) instead. And with 0x%pa, the pointer can be successfully printed but with duplicate prefixes, which looks like: kmemleak: kmemleak_free(0x(____ptrval____)) kmemleak: kmemleak_free_percpu(0x(____ptrval____)) kmemleak: kmemleak_free_part_phys(0x0x0000000a1af86000) Use 0x%px instead of 0x%p or 0x%pa to print the pointer. Then the print will be like: kmemleak: kmemleak_free(0xffff9111c145b020) kmemleak: kmemleak_free_percpu(0x00000000000333b0) kmemleak: kmemleak_free_part_phys(0x0000000a1af80000) Signed-off-by: Liu Shixin Acked-by: Catalin Marinas --- mm/kmemleak.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index ed497866361a..042cb0d18c7a 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -982,7 +982,7 @@ static void object_no_scan(unsigned long ptr) void __ref kmemleak_alloc(const void *ptr, size_t size, int min_count, gfp_t gfp) { - pr_debug("%s(0x%p, %zu, %d)\n", __func__, ptr, size, min_count); + pr_debug("%s(0x%px, %zu, %d)\n", __func__, ptr, size, min_count); if (kmemleak_enabled && ptr && !IS_ERR(ptr)) create_object((unsigned long)ptr, size, min_count, gfp); @@ -1003,7 +1003,7 @@ void __ref kmemleak_alloc_percpu(const void __percpu *ptr, size_t size, { unsigned int cpu; - pr_debug("%s(0x%p, %zu)\n", __func__, ptr, size); + pr_debug("%s(0x%px, %zu)\n", __func__, ptr, size); /* * Percpu allocations are only scanned and not reported as leaks @@ -1027,7 +1027,7 @@ EXPORT_SYMBOL_GPL(kmemleak_alloc_percpu); */ void __ref kmemleak_vmalloc(const struct vm_struct *area, size_t size, gfp_t gfp) { - pr_debug("%s(0x%p, %zu)\n", __func__, area, size); + pr_debug("%s(0x%px, %zu)\n", __func__, area, size); /* * A min_count = 2 is needed because vm_struct contains a reference to @@ -1050,7 +1050,7 @@ EXPORT_SYMBOL_GPL(kmemleak_vmalloc); */ void __ref kmemleak_free(const void *ptr) { - pr_debug("%s(0x%p)\n", __func__, ptr); + pr_debug("%s(0x%px)\n", __func__, ptr); if (kmemleak_free_enabled && ptr && !IS_ERR(ptr)) delete_object_full((unsigned long)ptr); @@ -1068,7 +1068,7 @@ EXPORT_SYMBOL_GPL(kmemleak_free); */ void __ref kmemleak_free_part(const void *ptr, size_t size) { - pr_debug("%s(0x%p)\n", __func__, ptr); + pr_debug("%s(0x%px)\n", __func__, ptr); if (kmemleak_enabled && ptr && !IS_ERR(ptr)) delete_object_part((unsigned long)ptr, size, false); @@ -1086,7 +1086,7 @@ void __ref kmemleak_free_percpu(const void __percpu *ptr) { unsigned int cpu; - pr_debug("%s(0x%p)\n", __func__, ptr); + pr_debug("%s(0x%px)\n", __func__, ptr); if (kmemleak_free_enabled && ptr && !IS_ERR(ptr)) for_each_possible_cpu(cpu) @@ -1107,7 +1107,7 @@ void __ref kmemleak_update_trace(const void *ptr) struct kmemleak_object *object; unsigned long flags; - pr_debug("%s(0x%p)\n", __func__, ptr); + pr_debug("%s(0x%px)\n", __func__, ptr); if (!kmemleak_enabled || IS_ERR_OR_NULL(ptr)) return; @@ -1138,7 +1138,7 @@ EXPORT_SYMBOL(kmemleak_update_trace); */ void __ref kmemleak_not_leak(const void *ptr) { - pr_debug("%s(0x%p)\n", __func__, ptr); + pr_debug("%s(0x%px)\n", __func__, ptr); if (kmemleak_enabled && ptr && !IS_ERR(ptr)) make_gray_object((unsigned long)ptr); @@ -1156,7 +1156,7 @@ EXPORT_SYMBOL(kmemleak_not_leak); */ void __ref kmemleak_ignore(const void *ptr) { - pr_debug("%s(0x%p)\n", __func__, ptr); + pr_debug("%s(0x%px)\n", __func__, ptr); if (kmemleak_enabled && ptr && !IS_ERR(ptr)) make_black_object((unsigned long)ptr, false); @@ -1176,7 +1176,7 @@ EXPORT_SYMBOL(kmemleak_ignore); */ void __ref kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp) { - pr_debug("%s(0x%p)\n", __func__, ptr); + pr_debug("%s(0x%px)\n", __func__, ptr); if (kmemleak_enabled && ptr && size && !IS_ERR(ptr)) add_scan_area((unsigned long)ptr, size, gfp); @@ -1194,7 +1194,7 @@ EXPORT_SYMBOL(kmemleak_scan_area); */ void __ref kmemleak_no_scan(const void *ptr) { - pr_debug("%s(0x%p)\n", __func__, ptr); + pr_debug("%s(0x%px)\n", __func__, ptr); if (kmemleak_enabled && ptr && !IS_ERR(ptr)) object_no_scan((unsigned long)ptr); @@ -1210,7 +1210,7 @@ EXPORT_SYMBOL(kmemleak_no_scan); */ void __ref kmemleak_alloc_phys(phys_addr_t phys, size_t size, gfp_t gfp) { - pr_debug("%s(0x%pa, %zu)\n", __func__, &phys, size); + pr_debug("%s(0x%px, %zu)\n", __func__, &phys, size); if (kmemleak_enabled) /* @@ -1230,7 +1230,7 @@ EXPORT_SYMBOL(kmemleak_alloc_phys); */ void __ref kmemleak_free_part_phys(phys_addr_t phys, size_t size) { - pr_debug("%s(0x%pa)\n", __func__, &phys); + pr_debug("%s(0x%px)\n", __func__, &phys); if (kmemleak_enabled) delete_object_part((unsigned long)phys, size, true); @@ -1244,7 +1244,7 @@ EXPORT_SYMBOL(kmemleak_free_part_phys); */ void __ref kmemleak_ignore_phys(phys_addr_t phys) { - pr_debug("%s(0x%pa)\n", __func__, &phys); + pr_debug("%s(0x%px)\n", __func__, &phys); if (kmemleak_enabled) make_black_object((unsigned long)phys, true);