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: 44930 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2098715wrn; Tue, 17 Jan 2023 18:22:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXuReGv8W56FpRD1FZgSLR6bTAN/fGBlczSns7SC8UnQqh+2XMb2OtNu1vm9Jc5ClyX5S/bh X-Received: by 2002:a17:907:94ce:b0:870:ab89:3dd3 with SMTP id dn14-20020a17090794ce00b00870ab893dd3mr1555574ejc.70.1674008574435; Tue, 17 Jan 2023 18:22:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674008574; cv=none; d=google.com; s=arc-20160816; b=qTvEfg1VivH5sWjJKSgyQ+iBMNw48v3Uada8ylRU03qE7MKPrQeMU5KMbu2ts6zA2A ShAJ57fwnMHt6d5Jo/bCVlB5f/mcCM6R8vS7gbSXbXaEFF/SQdMxN933//szJ11zc82H qSvygt2pNXWzUk0XrkvqwmgMb8Z7GlNYqLvJUpvvwnhPHP3FP/o9fzkSevvEogaA6Xzz yQfmTA1J0T2iSR7oXairPoTkWvjgW/RpXNpzR12935Z7hm9WmjC3tpDX/OkbgXxbY4Cu LSfAPfw5jk3JQVXEs0WCkDTY0IkP9bau+V8Ih91diPMmoSP7yvcEuhPnTT8zhkotmGC5 IDPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:to:from; bh=GSwX5JeEc09oW4yCuP33XIvxdtMqZRNTD0qPlYBVpOs=; b=CwYR/VWI8qvImQtBtPFvyYMFz0ZGU0zuAvrr4vzjFcn2jew0z8B1fSQFqJw/ng5qTg E6AsUNDtzXEP/NfxjDo+LegcwQcjVUq1muP0DN6TsqRVEeqMb04bW1/yDE4vdnhL00av +rqDdMoSND24TkxfXPvxKVZnprUOjSoutFKocFdbt48fP5uvPLdgbzX6J5a6Y7JEI5Nr vMPbetST4f0IKFYvQ7YlEu/7bvijY64k799JMqsuy0IbmpWJGMtTipMWofMujI4RuWRa bqBRbIzwER6mSOBG+paixCfPBfqvgShLNAYSqLx2ptniYHOq/15k5d8+uIPKdzH1acU0 su3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wv4-20020a170907080400b007d11af995b2si10766435ejb.680.2023.01.17.18.22.30; Tue, 17 Jan 2023 18:22:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229834AbjARCJH (ORCPT + 99 others); Tue, 17 Jan 2023 21:09:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjARCIf (ORCPT ); Tue, 17 Jan 2023 21:08:35 -0500 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73C3A42DDD for ; Tue, 17 Jan 2023 18:08:07 -0800 (PST) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755325214683123228?= X-GMAIL-MSGID: =?utf-8?q?1755325214683123228?= 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;