Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp297376ybk; Sat, 9 May 2020 03:12:46 -0700 (PDT) X-Google-Smtp-Source: APiQypK2FYjNq8Aiw9X3F4Q608NWUMURbheBVl14pGLU7I/qhv/2TtrjYnJixeEwhyCU30F8xVb0 X-Received: by 2002:a05:6402:1b08:: with SMTP id by8mr5553637edb.286.1589019166626; Sat, 09 May 2020 03:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589019166; cv=none; d=google.com; s=arc-20160816; b=abPM3AIQmyCAtb3ykVZ9HsvcA8otoCNEFQr8w9dzLGXvkrwnoL+FPSAP8cOdn4wZfM MEA5qzemdFC6ir2pw2ucj5Zg0VwZQRKcCxY40YkZpb7EdeaGWC6gPHz7u+xxTF7v2mdR H+/9tqWALih8sLFEIo/F6Gb1m6CP9G8VBqKmmtu6/H1HnX4dRyW2jlmLOYXza5pX5yFQ mDElZMdU7gqNBRmd8tfooQh4xSoXrTMMOrONCUwuyQ86Z6i02PhAl4O+bU3sa1xQr+oL Tz1w+WocaQMqCTKk6YSd/hslPccbIdze2iVvRwnkx3CFU9Y/zkQ9fBPR62njH8kHhF8U +iYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=PHGW4eyjv0x2rHIqX0rbtBWx7gfGUtWgfa1XTAlqvX0=; b=NZyAyH51pueK2rwWhPZrKMwY2sTPueC3VbQeV1+F02IR5obI49FdgaCEGapnL8EoFD fsezlKMpGpmEfJhc2MEn7n/z/PdNtE9VJ3cyKvMUUJvXVQe78/pBcjQ8XDrwqkorrIZd zwKczlrygGBvCbNqNeMkyNNx3KComVTmtf+ajKfnThQ4dPFMLzsb6ZhV9F/ut42DDlfY KyccibPiB7h3ijkuoSlUBJbLFLL0iqd8mDgddX6BFdaIEBwdHsQiboN3nXEGct4KDpIU vOjDzVBLDSVnAODa/dnAXQF1Bs4T8NlWFCK6lxVcwTtTntE9UlQ5WufeuWsg3dbzPHX4 0+fQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x21si2468742ejw.432.2020.05.09.03.12.22; Sat, 09 May 2020 03:12:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727838AbgEIKIj (ORCPT + 99 others); Sat, 9 May 2020 06:08:39 -0400 Received: from foss.arm.com ([217.140.110.172]:58258 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726017AbgEIKIj (ORCPT ); Sat, 9 May 2020 06:08:39 -0400 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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