From patchwork Wed Oct 18 10:29:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13426731 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 BB0A8CDB483 for ; Wed, 18 Oct 2023 09:30:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DC6F8D014F; Wed, 18 Oct 2023 05:30:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 841288D014A; Wed, 18 Oct 2023 05:30:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 641FF8D0150; Wed, 18 Oct 2023 05:30:28 -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 38A058D014C for ; Wed, 18 Oct 2023 05:30:28 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 146961601A5 for ; Wed, 18 Oct 2023 09:30:28 +0000 (UTC) X-FDA: 81358061736.20.3942569 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf18.hostedemail.com (Postfix) with ESMTP id 937D21C000A for ; Wed, 18 Oct 2023 09:30:25 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 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=1697621426; a=rsa-sha256; cv=none; b=rXxDnkscPA9NTmAKzCV3JkkjKlGPzWKarcoq0E2o9Sm/F6qMj6Uj0YeCmWJourljSDfUmT +B1uaD6FeZZ4wDMWH88LnsedQwtXbl5hHpN1Quw9j6EkXKUFnZsm5P2I11prgvpwrJShQl sekMSLd4ES+9DzAsWRcB16wnLA1dvjo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 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=1697621426; 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=QynFQbdBOqMAbRbqIKAb4ezQxOAxrMBgtLmqyiL8XDo=; b=YsPpdjwI8xaclhV+SGDVfkhH1px886uURHzqTSDjvjwjk85zlyROxHiQzV0zIa7ulR0ZeT /K2gSbHOPepivMqqu6kOnUkuVtRJYJO0TCPZpCc9G6WvyZu1VEwG7e7cVCSwQxxcbuLT/u YPYZ16iSvsPKQrLtZ53L5y7YQoIrRjM= Received: from dggpemm500009.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S9QT763HmzCrMt; Wed, 18 Oct 2023 17:26:19 +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; Wed, 18 Oct 2023 17:30:18 +0800 From: Liu Shixin To: Catalin Marinas , Patrick Wang , Andrew Morton , Kefeng Wang CC: , , Liu Shixin Subject: [PATCH v3 3/7] mm/kmemleak: fix print format of pointer in pr_debug() Date: Wed, 18 Oct 2023 18:29:48 +0800 Message-ID: <20231018102952.3339837-4-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231018102952.3339837-1-liushixin2@huawei.com> References: <20231018102952.3339837-1-liushixin2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 937D21C000A X-Stat-Signature: oqri5yyfiknpij6k99pnp4ucnuick9t1 X-HE-Tag: 1697621425-874401 X-HE-Meta: U2FsdGVkX19GXY8KER//ubcQMc382pSztPDN+S4YfgIoXq3APJ1yElxXcfq7do6rWs9FKRq6+g2rXnPGG0fJ/JepsCZ8eX5ES0DTHiMkzigJEOZvlosDycO5xFSsqOOqUuZAL3Fqx+JHskgAV0kHDIDO5eU6ND6OORRE7VevjlQNjZm6APV9RP6lc2zp1PCoJLAZ+BRRZ+tlDaWMvxT0wQAqibYqoGAFsIXObxqOS1ZBeL5SvTsf7/CIBx3rIwNfdH4DqBIaPV/LmM6IXZRqaDQIAOLjsCMxp69LdaEz42IKEijlwO7qje9/TcIyQdzw9i7GXKM5EbYEMlDnptjKq8u4qdLFCORtRryUoZYeC1MEUoVDTvsBrK2ATC3odnGSiHPeuH/Yt2KFOl9Efks7CHCdZ5poY9aANexw/cJtcneiyTuUgqzPvmaNcUiFmCyfZI8VBHlrQAxPMTkz3d8iDH3VykbgOhLWQwF2qnw+W1AumSR0+uxAxDYqTEFni5KqfLLknKxx5fdhMiy5Yv5mA7g3WFWdwwsBbaCgrGHUySyYj8NJRysIFQ+V27+OsXUGfHZ8tsF62gjJj7iB8+gkqAUSur2NZTg3CFxDZxj7pKRcb0sjY/8B658u6o0GBcWfTT0Rdh/RWzNM+n8il4MoBeqoZ1GEuugflEmSiCJoqGe1nVCiPOWGkretA+JdRELH2h3dJcie+OprF0YtX1+oqteXBf2swmn/EnRP+nm5FXkIG8y6W7Q40FyL+OjafHRwVrkIZLhFmofWrDvtxqIcgBoR5x2Dh8/8NindUpdMDg3iQNETBPM3dkhxImKU0OGt/M6MW1mFOMdi492JRCM72/iRBb5lUm1h5gBaUUt+uGZpuC40OqzIOCC4tJL9lopI7dbOmpfuwkLYEPGyK8NPw3fhmBjxZHxWCg9o3eZrqvcnP5SsV+kVSKf61CvbVYaWVOBxX18AutDu9Cv8iMC D3EBJE1H dy5GMw6Zevpgn03wP4bip3n2YEtkRdT00X5LY2R6Q67TjxuSRWmPq5rUWT8NbC+BWnLiMMfq81Fzh/WMqylNCj6dMZ42mJAx/efP3MKYRhuWekvZjzJ0ocMrZim1jmFVV4tCjVAMC21tSlYdDSRhewL+AuI0wwUDx4SUGBvHHdRVAwy0k8gShkwrsq25kUQq6ChiofEJNPxVKm+9RlzKM6gWGdjpUoRnPFdtTy3XtbYuy4qKn4eNTxCUPHuJlyoaoyOhZJ6/019A0kcgKb3b7U2oefi7/31gzxB/XvmaN+62Gj4xD58P+Vot33VmpIyygfdvO 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 54c2c90d3abc..289b3be5ee6e 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -975,7 +975,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); @@ -996,7 +996,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 @@ -1020,7 +1020,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 @@ -1043,7 +1043,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); @@ -1061,7 +1061,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); @@ -1079,7 +1079,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) @@ -1100,7 +1100,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; @@ -1131,7 +1131,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); @@ -1149,7 +1149,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); @@ -1169,7 +1169,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); @@ -1187,7 +1187,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); @@ -1203,7 +1203,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) /* @@ -1223,7 +1223,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); @@ -1237,7 +1237,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);