From patchwork Wed Jan 18 02:07:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13105417 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 5802CC00A5A for ; Wed, 18 Jan 2023 02:08:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D88D06B0072; Tue, 17 Jan 2023 21:08:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D39626B0074; Tue, 17 Jan 2023 21:08:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C01C06B0075; Tue, 17 Jan 2023 21:08:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B05766B0072 for ; Tue, 17 Jan 2023 21:08:46 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 812331208F4 for ; Wed, 18 Jan 2023 02:08:46 +0000 (UTC) X-FDA: 80366286252.04.A4E7C0E Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by imf20.hostedemail.com (Postfix) with ESMTP id EE53C1C000A for ; Wed, 18 Jan 2023 02:08:42 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf20.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674007724; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references; bh=GSwX5JeEc09oW4yCuP33XIvxdtMqZRNTD0qPlYBVpOs=; b=uxZxJzrLwVMHvpJQSRL5+D66dhRyDiHlOoTOowuJs3vFbsjBxtrvjmj3QC7tWOokbi800n HmzgU4vJMeLoyUPVX68tLMLcb3LIW6grQ4SUlEYSE8QEiVNZ7YsThh6YJjJtQCfG1za2Sa rJl0ByvazomnEI4TSbARBsWLwjLv/bc= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf20.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674007724; a=rsa-sha256; cv=none; b=0X60GgEWtBlKtDb+z9BYq7NNWS6//GdKwz+MLOOqlMIAitXNMG9gy4H1vT3G79pKZ9wrsP sJhWA/zP8tbhfdRjDlLA3GWi3CJsVnTXL7ebed4Tve0h/IGcEbEZ/pTArKsK61HNTl1YFc dmcY6Ol3vrQbqevDNU4QEZLEHmFY1GA= Received: from SHSend.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by SHSQR01.spreadtrum.com with ESMTP id 30I27vdA018004; Wed, 18 Jan 2023 10:07:57 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from bj03382pcu.spreadtrum.com (10.0.74.65) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 18 Jan 2023 10:07:52 +0800 From: "zhaoyang.huang" To: Andrew Morton , Catalin Marinas , Vlastimil Babka , "Nathan Chancellor" , Peter Zijlstra , Zhaoyang Huang , , , , Mirsad Todorovac Subject: [PATCHv3] mm: use stack_depot_early_init for kmemleak Date: Wed, 18 Jan 2023 10:07:35 +0800 Message-ID: <1674007655-23016-1-git-send-email-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.0.74.65] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 30I27vdA018004 X-Rspamd-Queue-Id: EE53C1C000A X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: ob7zgy3fxh978eikuagiz44tkscyje36 X-HE-Tag: 1674007722-138659 X-HE-Meta: U2FsdGVkX1/F6qBsEgZRDW++jZ8QKZaIsA3OMU7uc75HIEQk8yRa0ED/HaAOfpcdSClDAm3Qbo1bbShvkY1qbEBES9LZMz8rZEuT4wosVOvgz6bx7RZ+aglikZOaFpL2EKrOs5j2Vn8lQqIrZstfMtMnUjzYc/l48+lJT0gpDRXR2jAwvK2yBuZQHCo1PlRkj2zfHWzGo1rhWTOOmsSFIBqtpDztxmh/XWb50F8Q3XvWFjtp9uCaswlGQq8F9Ek9l6xdYuuceDPkd80JZoNXQmi8Rzd1lDVarLUGcKnjk2lOU7cdDVZiNP99DWRNHYsqG2RhYWRJBWZEXPl2yw+yt/wn1FUCdUIfTtDQ0scZ+EQhyQoAW4z8OlZvJ5ZMJA6L/WL4nGAHj/Z+BJNrEzExCmAXjZvGol4LmCnqkDwF4hSKnaYN8Vy37aiQUxxsenxBvTYP1PVd2BeZCCEzE78V47K9ZK8nj7yUPWQwrBWiuQ1rnMsk9kGZdh4GFf57pj16/a6wV75C8zjRcBuEPn1Xy0SH4hunE3t1Pi0X7HKoXIagAjEuSl/GD5dsQ4GK2hMFrd0fo2BxX6sytrwAhF/ivn6IlX6gsADB/CHDF1cMrbyBasjta8nOF+HfQMaQ73nPX21OkEU9EN965R0cfUiAZ07EofnJqXnmlsvIRvmOGCfiRcnz0BSfijRP4PpZB7tf86aV7XHjVhWf+sr4xGBpywveANlLpE78d+lV5gAIXZLjBzKBwBVsL/6PVAzRDQlstLYFsalAnirCat3Mx+XQOQAYPBSesCZ+pvURdx2AXENy4pPMN6rN12XbmDMaGYp9TJP2+aXuNX+RZnvqOh6cWlQf3it0hNf9R7njs/u/gkyHAAmrT4TP6FcKnN1CkoLs1UFIhn5bNR9fO+fSISfRwJP8pfIRPczqz61O5D34K3ufWCbn786vfog6qmsGqh41jgUkQExMBI8ZafjRbmx sxhpS7T4 ocS+UISvbBHhRHDI= 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: From: Zhaoyang Huang Mirsad report bellow error which caused by stack_depot_init failed in kvcalloc. Solve this by having stackdepot use stack_depot_early_init. On 1/4/23 17:08, Mirsad Goran Todorovac wrote: I hate to bring bad news again, but there seems to be a problem with the output of /sys/kernel/debug/kmemleak: [root@pc-mtodorov ~]# cat /sys/kernel/debug/kmemleak unreferenced object 0xffff951c118568b0 (size 16): comm "kworker/u12:2", pid 56, jiffies 4294893952 (age 4356.548s) hex dump (first 16 bytes): 6d 65 6d 73 74 69 63 6b 30 00 00 00 00 00 00 00 memstick0....... backtrace: [root@pc-mtodorov ~]# Apparently, backtrace of called functions on the stack is no longer printed with the list of memory leaks. This appeared on Lenovo desktop 10TX000VCR, with AlmaLinux 8.7 and BIOS version M22KT49A (11/10/2022) and 6.2-rc1 and 6.2-rc2 builds. This worked on 6.1 with the same CONFIG_KMEMLEAK=y and MGLRU enabled on a vanilla mainstream kernel from Mr. Torvalds' tree. I don't know if this is deliberate feature for some reason or a bug. Please find attached the config, lshw and kmemleak output. reported-by: Mirsad Todorovac suggested-by: Vlastimil Babka Signed-off-by: Zhaoyang Huang --- v2: use stack_depot_want_early_init instead of CONFIG_STACKDEPOT_ALWAYS_INIT v3: have the Kconfig changes commited in another patch --- Signed-off-by: Zhaoyang Huang --- mm/kmemleak.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 762b91f..ddc1ddf 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -2070,8 +2070,10 @@ static int __init kmemleak_boot_config(char *str) return -EINVAL; if (strcmp(str, "off") == 0) kmemleak_disable(); - else if (strcmp(str, "on") == 0) + else if (strcmp(str, "on") == 0) { kmemleak_skip_disable = 1; + stack_depot_want_early_init(); + } else return -EINVAL; return 0;