From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9E09C47254 for ; Sat, 9 May 2020 10:08:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9A84920746 for ; Sat, 9 May 2020 10:08:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A84920746 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 296D2900003; Sat, 9 May 2020 06:08:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 220418E0003; Sat, 9 May 2020 06:08:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10FF7900003; Sat, 9 May 2020 06:08:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id EE87B8E0003 for ; Sat, 9 May 2020 06:08:39 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B1CD1440E for ; Sat, 9 May 2020 10:08:39 +0000 (UTC) X-FDA: 76796756358.09.plate65_85c8b05b0d620 X-HE-Tag: plate65_85c8b05b0d620 X-Filterd-Recvd-Size: 2550 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Sat, 9 May 2020 10:08:39 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5C5C41FB; Sat, 9 May 2020 03:08:38 -0700 (PDT) Received: from gaia (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 85CAD3F71F; Sat, 9 May 2020 03:08:37 -0700 (PDT) Date: Sat, 9 May 2020 10:44:56 +0100 From: Catalin Marinas To: Qian Cai Cc: Linux-MM , LKML , "Paul E. McKenney" Subject: Re: Kmemleak infrastructure improvement for task_struct leaks and call_rcu() Message-ID: <20200509094455.GA4351@gaia> References: <20200507171607.GD3180@gaia> <40B2408F-05DD-4A82-BF97-372EA09FA873@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <40B2408F-05DD-4A82-BF97-372EA09FA873@lca.pw> User-Agent: Mutt/1.10.1 (2018-07-13) 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: On Thu, May 07, 2020 at 01:29:04PM -0400, Qian Cai wrote: > On May 7, 2020, at 1:16 PM, Catalin Marinas wrote: > > I don't mind adding additional tracking info if it helps with debugging. > > But if it's for improving false positives, I'd prefer to look deeper > > into figure out why the pointer reference graph tracking failed. > > No, the task struct leaks are real leaks. It is just painful to figure > out the missing or misplaced put_task_struct() from the kmemleak > reports at the moment. We could log the callers to get_task_struct() and put_task_struct(), something like __builtin_return_address(0) (how does this work if the function is inlined?). If it's not the full backtrace, it shouldn't slow down kmemleak considerably. I don't think it's worth logging only the first/last calls to get/put. You'd hope that put is called in reverse order to get. I think it may be better if this is added as a new allocation pointed to from kmemleak_object rather than increasing this structure since it will be added on a case by case basis. When dumping the leak information, it would also dump the get/put calls, in the order they were called. We could add some simple refcount tracking (++ for get, -- for put) to easily notice any imbalance. I'm pretty busy next week but happy to review if you have a patch ;). -- Catalin