Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756399AbYK2Kre (ORCPT ); Sat, 29 Nov 2008 05:47:34 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756337AbYK2Ko2 (ORCPT ); Sat, 29 Nov 2008 05:44:28 -0500 Received: from cam-admin0.cambridge.arm.com ([193.131.176.58]:41421 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756309AbYK2Ko1 (ORCPT ); Sat, 29 Nov 2008 05:44:27 -0500 Subject: [PATCH 13/15] kmemleak: Keep the __init functions after initialization To: linux-kernel@vger.kernel.org From: Catalin Marinas Cc: Ingo Molnar Date: Sat, 29 Nov 2008 10:44:19 +0000 Message-ID: <20081129104419.16726.57359.stgit@pc1117.cambridge.arm.com> In-Reply-To: <20081129103908.16726.24264.stgit@pc1117.cambridge.arm.com> References: <20081129103908.16726.24264.stgit@pc1117.cambridge.arm.com> User-Agent: StGit/0.14.3.288.gdd3f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 29 Nov 2008 10:44:19.0328 (UTC) FILETIME=[6EC6D000:01C9520F] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1989 Lines: 60 This patch adds the CONFIG_DEBUG_KEEP_INIT option which preserves the .init.* sections after initialization. Memory leaks happening during this phase can be more easily tracked. Signed-off-by: Catalin Marinas Cc: Ingo Molnar --- include/linux/init.h | 6 ++++++ lib/Kconfig.debug | 12 ++++++++++++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/include/linux/init.h b/include/linux/init.h index 68cb026..41321ad 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -40,9 +40,15 @@ /* These are for everybody (although not all archs will actually discard it in modules) */ +#ifdef CONFIG_DEBUG_KEEP_INIT +#define __init +#define __initdata +#define __initconst +#else #define __init __section(.init.text) __cold notrace #define __initdata __section(.init.data) #define __initconst __section(.init.rodata) +#endif #define __exitdata __section(.exit.data) #define __exit_call __used __section(.exitcall.exit) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 1e59827..72cde77 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -313,6 +313,18 @@ config DEBUG_MEMLEAK In order to access the memleak file, debugfs needs to be mounted (usually at /sys/kernel/debug). +config DEBUG_KEEP_INIT + bool "Do not free the __init code/data" + default n + depends on DEBUG_MEMLEAK + help + This option moves the __init code/data out of the + .init.text/.init.data sections. It is useful for identifying + memory leaks happening during the kernel or modules + initialization. + + If unsure, say N. + config DEBUG_PREEMPT bool "Debug preemptible kernel" depends on DEBUG_KERNEL && PREEMPT && (TRACE_IRQFLAGS_SUPPORT || PPC64) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/