From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E92BD37A494 for ; Tue, 24 Mar 2026 13:07:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774357668; cv=none; b=KFD47cyE5apvTU5xZk2TYozRhz0nSDnoHVdm5hWrfvA/3tH3ZtDNkvOLle5sp+uc406hl9XVvp/OD3ezPP8Mr1+w3+9ve9JOzloDTb0QucKZ59uEO/8eqBHsbFlG9sKBlzN4IXSUQQiZmj1iEVjqK0xYJskQwD44IN259+ktU/c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774357668; c=relaxed/simple; bh=B/Us/uOYeoEX4+nVZGmaQnHlVPKI4SH/p55yVCY/ql4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hf7eXCbQlpUb8+Tns5tBS7EohvbayDuCBNEhH/s7xZYBuYw6Evzpr5wPQoVvz5PhpWpP0MYu9fmVoBsaL+uQhYj5JjYinagrG0Ni8mfsRF/vd3HBJMoQieZNUA64F4Cgplr6zo151+MacgyuOYaXCysOdbkTuH92aBruD3Df6Ck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CQ7BZOZ9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CQ7BZOZ9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A60BAC19424; Tue, 24 Mar 2026 13:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774357667; bh=B/Us/uOYeoEX4+nVZGmaQnHlVPKI4SH/p55yVCY/ql4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CQ7BZOZ9qGuCpvkMvx/CkKv/Bpd/0yNDNmoy38tW59w0wZqYaxcfMGgEsvApFS3TZ GvkLV29oJxWB1g6zZS8Q99SV/2waKTl9Au4EqDa5YV7i8RXe5BDvad/yXgE8jgBgRJ 9Q+O7hxyjoNTaBsZQlnIVYxJZAPPfzP80rz1SK8vpSp5I0NU6lQCt4/Gozb76KLqHr OwgUblG2jzYkxHr0CdvGvZUWY/kmFif8Aqa9rGggHTtAt6nQHzbrZIfdNgEiZl/HEF CRrSVpDAj4KooWbqQ55j/OW/TTjeyKvaZl85v13gKJKjFnnKkaVnTAAqODr4blKYlg 3mgk+oGiYqxDw== Date: Tue, 24 Mar 2026 13:07:42 +0000 From: "Lorenzo Stoakes (Oracle)" To: Breno Leitao Cc: Andrew Morton , Catalin Marinas , David Hildenbrand , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH] mm: kmemleak: add CONFIG_DEBUG_KMEMLEAK_VERBOSE build option Message-ID: <0dfd659a-f4c8-4356-9b14-960ca70c0d68@lucifer.local> References: <20260323-kmemleak_report-v1-1-ba2cdd9c11b9@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260323-kmemleak_report-v1-1-ba2cdd9c11b9@debian.org> On Mon, Mar 23, 2026 at 04:12:13AM -0700, Breno Leitao wrote: > Add a Kconfig option to default kmemleak verbose mode on at build time. > This option depends on DEBUG_KMEMLEAK_AUTO_SCAN since verbose reporting > is only meaningful when the automatic scanning thread is running. > > When enabled, kmemleak prints full details (backtrace, hex dump, address) > of unreferenced objects to dmesg as they are detected during scanning, > removing the need to manually read /sys/kernel/debug/kmemleak. > > Making this a compile-time option rather than a boot parameter allows > debug kernel flavors to enable verbose kmemleak reporting by default > without requiring changes to boot arguments. A machine can simply swap > to a debug kernel and benefit from kmemleak reporting automatically. > > By surfacing leak reports directly in dmesg, they are automatically > forwarded through any kernel logging infrastructure and can be easily > captured by log aggregation tooling, making it practical to monitor > memory leaks across large fleets. > > The verbose setting can still be toggled at runtime via > /sys/module/kmemleak/parameters/verbose. > > Signed-off-by: Breno Leitao This seems reasonable, so: Reviewed-by: Lorenzo Stoakes (Oracle) Cheers, Lorenzo > --- > mm/Kconfig.debug | 11 +++++++++++ > mm/kmemleak.c | 2 +- > 2 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug > index 7638d75b27db8..91b3e027b7535 100644 > --- a/mm/Kconfig.debug > +++ b/mm/Kconfig.debug > @@ -297,6 +297,17 @@ config DEBUG_KMEMLEAK_AUTO_SCAN > > If unsure, say Y. > > +config DEBUG_KMEMLEAK_VERBOSE > + bool "Default kmemleak to verbose mode" > + depends on DEBUG_KMEMLEAK_AUTO_SCAN > + help > + Say Y here to have kmemleak print unreferenced object details > + (backtrace, hex dump, address) to dmesg when new memory leaks are > + detected during automatic scanning. This can also be toggled at > + runtime via /sys/module/kmemleak/parameters/verbose. > + > + If unsure, say N. > + > config PER_VMA_LOCK_STATS > bool "Statistics for per-vma locks" > depends on PER_VMA_LOCK > diff --git a/mm/kmemleak.c b/mm/kmemleak.c > index fa8201e232221..2eff0d6b622b6 100644 > --- a/mm/kmemleak.c > +++ b/mm/kmemleak.c > @@ -241,7 +241,7 @@ static int kmemleak_skip_disable; > /* If there are leaks that can be reported */ > static bool kmemleak_found_leaks; > > -static bool kmemleak_verbose; > +static bool kmemleak_verbose = IS_ENABLED(CONFIG_DEBUG_KMEMLEAK_VERBOSE); > module_param_named(verbose, kmemleak_verbose, bool, 0600); > > static void kmemleak_disable(void); > > --- > base-commit: 785f0eb2f85decbe7c1ef9ae922931f0194ffc2e > change-id: 20260323-kmemleak_report-a9a103ee0c8c > > Best regards, > -- > Breno Leitao >