Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp442228ybk; Wed, 13 May 2020 04:19:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVfweQDKHn9SIW3vBQ1Y8LR6MILEeuNHXRQ5JGY6INiIiC1GUMhtP/fNpMLo4R8IY4+3lu X-Received: by 2002:a17:906:7e15:: with SMTP id e21mr2342916ejr.106.1589368757066; Wed, 13 May 2020 04:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589368757; cv=none; d=google.com; s=arc-20160816; b=iWAxrAnnJloAN7lq3nRT6UghRRo14k18FpKPkoXPFBXHgabozEo4WxHhwfnvR8J57J RW3ygCjnMnqEbNnmWYnAy5XSAi7imMHTUOAPyrVvEvlKVIq2OQmUi5O7umHaG/WfG/ZJ rj9EKQfT7YmN4cdOVK5kuDZ9no6ZKapH9RAXGxN3QaHDfxXNlt/VRJkx96VatiubZiZS QoEpypYiF6t+vn7knqltoShn+zk5QkGwOdbJjRbAqmsmnaUgB9gaCuZqDPu8TxF4DYIx AFzkRCe8Ea76x/y8K4rIJ8T0eB80xM442WiShaYpPqwIVvPN27STDeWLQHOYha1ayZXa XQzQ== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=9YC0MfEoDz7DvdxS19fOSoCaEtNB4LIS+oDQKpA+4is=; b=WfU7l5Bm4OIRJSrl1m/58qhohFx8WM4nSaqH8H0ccJ+HoZDT6DWBztXwAuWvzRx9mE 3w//nVe7XsKLv3SDxeR7yCSsbqRrHcWAVlODFoKiT1QzZjFBrDYyd8ReuqGkRVWcxCEm AyNgFyO/t5GDCuTF2e8AMCoP82NQc/88O6w61vrtW/Wra+4WigAqu/FyYfZZjnFCSH+H UtFc/+Rq7hdQ/W2Ki6vMLWHj9enJCe6JcQAq7sKNuZq7j3jurM5fWCO3ZUs5pff8Xg8l BgsFokkc/H6I5uvT8duhOJoAr3cXXObuxtiLYbMYzXzEi/uIX8aChD5719VVODTyY2ew y9ew== 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 j3si10179258edr.148.2020.05.13.04.18.54; Wed, 13 May 2020 04:19:17 -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 S2388325AbgEMJ7w (ORCPT + 99 others); Wed, 13 May 2020 05:59:52 -0400 Received: from foss.arm.com ([217.140.110.172]:41918 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388392AbgEMJ7t (ORCPT ); Wed, 13 May 2020 05:59:49 -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 83E941FB; Wed, 13 May 2020 02:59:48 -0700 (PDT) Received: from gaia (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7C2F03F305; Wed, 13 May 2020 02:59:46 -0700 (PDT) Date: Wed, 13 May 2020 10:59:40 +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: <20200513095939.GA2719@gaia> References: <20200512141535.GA14943@gaia> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 Tue, May 12, 2020 at 02:09:30PM -0400, Qian Cai wrote: > > > > On May 12, 2020, at 10:15 AM, Catalin Marinas wrote: > > > > In this case it uses kref_get() to increment the refcount. We could add > > a kmemleak_add_trace() which allocates a new array and stores the stack > > trace, linked to the original object. Similarly for kref_put(). > > > > If we do this for each inc/dec call, I'd leave it off as default and > > only enable it explicitly by cmdline argument or > > /sys/kerne/debug/kmemleak when needed. In most cases you'd hope there is > > no leak, so no point in tracking additional metadata. But if you do hit > > a problem, just enable the additional tracking to help with the > > debugging. > > Well, we would like those testing bots to report kmemleak (I knew > there would be many false positives) with those additional information > of refcount leaks in case they found ones, albeit never saw one from > those bots at all yet. I know the syzkaller guys tried to run the fuzzer with kmemleak enabled and there were false positives that required human intervention. IIRC they disabled it eventually. The proposal was for a new feature to kmemleak to run the scanning under stop_machine() so that no other CPU messes with linked lists etc. That would make kmemleak more reliable under heavy load. Another option was to let the system cool down before running the scanning. > Since some of those bots will run fuzzers, so it would be difficult to > reproduce. Thus, the option has to be enabled by default somehow. > Otherwise, they could easily miss it in the first place. I’ll look > into the see if we could make it fairly low overhead. I guess we don't need the full stack trace. About 4 function calls to the refcount modification should be sufficient to get an idea. -- Catalin