linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chen Jun <chenjun102@huawei.com>
To: <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>
Cc: <catalin.marinas@arm.com>, <akpm@linux-foundation.org>,
	<rui.xiang@huawei.com>, <weiyongjun1@huawei.com>
Subject: [PATCH -next 5/5] mm/kmemleak-test: Add a test case for alloc_percpu
Date: Mon, 21 Sep 2020 02:00:07 +0000	[thread overview]
Message-ID: <20200921020007.35803-6-chenjun102@huawei.com> (raw)
In-Reply-To: <20200921020007.35803-1-chenjun102@huawei.com>

After insmod kmemleak-test.ko, a leaking for alloc_percpu will be
reported as below:

kmemleak: alloc_percpu(sizeof(*elem)) = 00007dfdd26a2c40
			:
			:
unreferenced object 0x7dfdd26a2c40 (size 8):
  comm "insmod", pid 183, jiffies 4294905864 (age 40.520s)
  hex dump (first 8 bytes):
    00 00 00 00 00 00 00 00                          ........
  backtrace:
    [<(____ptrval____)>] pcpu_alloc+0x3ec/0x8c8
    [<(____ptrval____)>] __alloc_percpu+0x18/0x28
    [<(____ptrval____)>] 0xffff800008df525c
    [<(____ptrval____)>] do_one_initcall+0x60/0x1d8
    [<(____ptrval____)>] do_init_module+0x58/0x1d0
    [<(____ptrval____)>] load_module+0x1d8c/0x23d0
    [<(____ptrval____)>] __do_sys_finit_module+0xdc/0xf8
    [<(____ptrval____)>] __arm64_sys_finit_module+0x20/0x30
    [<(____ptrval____)>] el0_svc_common.constprop.3+0x68/0x170
    [<(____ptrval____)>] do_el0_svc+0x24/0x90
    [<(____ptrval____)>] el0_sync_handler+0x13c/0x1a8
    [<(____ptrval____)>] el0_sync+0x158/0x180

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Chen Jun <chenjun102@huawei.com>
---
 mm/kmemleak-test.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/kmemleak-test.c b/mm/kmemleak-test.c
index 75fe1b8c3226..8f3e4a60166b 100644
--- a/mm/kmemleak-test.c
+++ b/mm/kmemleak-test.c
@@ -79,6 +79,9 @@ static int __init kmemleak_test_init(void)
 			per_cpu(kmemleak_test_pointer, i));
 	}
 
+	pr_info("alloc_percpu(sizeof(*elem)) = %px\n",
+		alloc_percpu(sizeof(*elem)));
+
 	return 0;
 }
 module_init(kmemleak_test_init);
-- 
2.25.0


      parent reply	other threads:[~2020-09-21  2:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-21  2:00 [PATCH -next 0/5] mm/kmemleak:support for percpu memory leak detect Chen Jun
2020-09-21  2:00 ` [PATCH -next 1/5] mm/kmemleak: make create_object return void Chen Jun
2020-09-22  9:57   ` Catalin Marinas
2020-09-21  2:00 ` [PATCH -next 2/5] mm/kmemleak: skip update_checksum for OBJECT_NO_SCAN objects Chen Jun
2020-09-22  9:03   ` Catalin Marinas
2020-09-21  2:00 ` [PATCH -next 3/5] mm/kmemleak: Add support for percpu memory leak detect Chen Jun
2020-09-22  9:57   ` Catalin Marinas
2020-09-28 14:08     ` chenjun (AM)
2020-09-28 14:16       ` Catalin Marinas
2020-09-21  2:00 ` [PATCH -next 4/5] mm/kmemleak-test: use %px instead of %p in print Chen Jun
2020-09-22  9:58   ` Catalin Marinas
2020-09-21  2:00 ` Chen Jun [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200921020007.35803-6-chenjun102@huawei.com \
    --to=chenjun102@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rui.xiang@huawei.com \
    --cc=weiyongjun1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).