diff mbox

[6/6] mm: Postpone the disabling of kmemleak early logging

Message ID 20140506170549.GM23957@arm.com
State New
Headers show

Commit Message

Catalin Marinas May 6, 2014, 5:05 p.m. UTC
On Tue, May 06, 2014 at 04:20:27PM +0100, Sasha Levin wrote:
> On 05/02/2014 09:41 AM, Catalin Marinas wrote:
> > Currently, kmemleak_early_log is disabled at the beginning of the
> > kmemleak_init() function, before the full kmemleak tracing is actually
> > enabled. In this small window, kmem_cache_create() is called by kmemleak
> > which triggers additional memory allocation that are not traced. This
> > patch moves the kmemleak_early_log disabling further down and at the
> > same time with full kmemleak enabling.
> > 
> > Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> 
> This patch makes the kernel die during the boot process:
> 
> [   24.471801] BUG: unable to handle kernel paging request at ffffffff922f2b93
> [   24.472496] IP: [<ffffffff922f2b93>] log_early+0x0/0xcd

Thanks for reporting this. I assume you run with
CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF enabled and kmemleak_early_log remains
set even though kmemleak is not in use.

Does the patch below fix it?


Thanks.

Comments

Sasha Levin May 6, 2014, 6:15 p.m. UTC | #1
On 05/06/2014 01:05 PM, Catalin Marinas wrote:
> On Tue, May 06, 2014 at 04:20:27PM +0100, Sasha Levin wrote:
>> On 05/02/2014 09:41 AM, Catalin Marinas wrote:
>>> Currently, kmemleak_early_log is disabled at the beginning of the
>>> kmemleak_init() function, before the full kmemleak tracing is actually
>>> enabled. In this small window, kmem_cache_create() is called by kmemleak
>>> which triggers additional memory allocation that are not traced. This
>>> patch moves the kmemleak_early_log disabling further down and at the
>>> same time with full kmemleak enabling.
>>>
>>> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>
>> This patch makes the kernel die during the boot process:
>>
>> [   24.471801] BUG: unable to handle kernel paging request at ffffffff922f2b93
>> [   24.472496] IP: [<ffffffff922f2b93>] log_early+0x0/0xcd
> 
> Thanks for reporting this. I assume you run with
> CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF enabled and kmemleak_early_log remains
> set even though kmemleak is not in use.
> 
> Does the patch below fix it?

Nope, that didn't help as I don't have DEBUG_KMEMLEAK_DEFAULT_OFF enabled.

For reference:

$ cat .config | grep KMEMLEAK
CONFIG_HAVE_DEBUG_KMEMLEAK=y
CONFIG_DEBUG_KMEMLEAK=y
CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE=400
# CONFIG_DEBUG_KMEMLEAK_TEST is not set
# CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF is not set


Thanks,
Sasha
--
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/
Catalin Marinas May 6, 2014, 9:52 p.m. UTC | #2
On 6 May 2014, at 19:15, Sasha Levin <sasha.levin@oracle.com> wrote:
> On 05/06/2014 01:05 PM, Catalin Marinas wrote:
>> On Tue, May 06, 2014 at 04:20:27PM +0100, Sasha Levin wrote:
>>> On 05/02/2014 09:41 AM, Catalin Marinas wrote:
>>>> Currently, kmemleak_early_log is disabled at the beginning of the
>>>> kmemleak_init() function, before the full kmemleak tracing is actually
>>>> enabled. In this small window, kmem_cache_create() is called by kmemleak
>>>> which triggers additional memory allocation that are not traced. This
>>>> patch moves the kmemleak_early_log disabling further down and at the
>>>> same time with full kmemleak enabling.
>>>> 
>>>> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
>>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>> 
>>> This patch makes the kernel die during the boot process:
>>> 
>>> [   24.471801] BUG: unable to handle kernel paging request at ffffffff922f2b93
>>> [   24.472496] IP: [<ffffffff922f2b93>] log_early+0x0/0xcd
>> 
>> Thanks for reporting this. I assume you run with
>> CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF enabled and kmemleak_early_log remains
>> set even though kmemleak is not in use.
>> 
>> Does the patch below fix it?
> 
> Nope, that didn't help as I don't have DEBUG_KMEMLEAK_DEFAULT_OFF enabled.
> 
> For reference:
> 
> $ cat .config | grep KMEMLEAK
> CONFIG_HAVE_DEBUG_KMEMLEAK=y
> CONFIG_DEBUG_KMEMLEAK=y
> CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE=400
> # CONFIG_DEBUG_KMEMLEAK_TEST is not set
> # CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF is not set

I assume your dmesg shows some kmemleak error during boot? I’ll send
another patch tomorrow.

The code around kmemleak_init was changed by commit 8910ae896c8c
(kmemleak: change some global variables to int). It looks like it
wasn’t just a simple conversion but slightly changed the
kmemleak_early_log logic which led to false positives for the kmemleak
cache objects and that’s what my patch was trying to solve.

The failure is caused by kmemleak_alloc() still calling log_early() much
later after the __init section has been freed because kmemleak_early_log
hasn’t been set to 0 (the default off is one path, another is the
kmemleak_error path).

Catalin--
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/
Sasha Levin May 6, 2014, 11:08 p.m. UTC | #3
On 05/06/2014 05:52 PM, Catalin Marinas wrote:
> On 6 May 2014, at 19:15, Sasha Levin <sasha.levin@oracle.com> wrote:
>> On 05/06/2014 01:05 PM, Catalin Marinas wrote:
>>> On Tue, May 06, 2014 at 04:20:27PM +0100, Sasha Levin wrote:
>>>> On 05/02/2014 09:41 AM, Catalin Marinas wrote:
>>>>> Currently, kmemleak_early_log is disabled at the beginning of the
>>>>> kmemleak_init() function, before the full kmemleak tracing is actually
>>>>> enabled. In this small window, kmem_cache_create() is called by kmemleak
>>>>> which triggers additional memory allocation that are not traced. This
>>>>> patch moves the kmemleak_early_log disabling further down and at the
>>>>> same time with full kmemleak enabling.
>>>>>
>>>>> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
>>>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>>>
>>>> This patch makes the kernel die during the boot process:
>>>>
>>>> [   24.471801] BUG: unable to handle kernel paging request at ffffffff922f2b93
>>>> [   24.472496] IP: [<ffffffff922f2b93>] log_early+0x0/0xcd
>>>
>>> Thanks for reporting this. I assume you run with
>>> CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF enabled and kmemleak_early_log remains
>>> set even though kmemleak is not in use.
>>>
>>> Does the patch below fix it?
>>
>> Nope, that didn't help as I don't have DEBUG_KMEMLEAK_DEFAULT_OFF enabled.
>>
>> For reference:
>>
>> $ cat .config | grep KMEMLEAK
>> CONFIG_HAVE_DEBUG_KMEMLEAK=y
>> CONFIG_DEBUG_KMEMLEAK=y
>> CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE=400
>> # CONFIG_DEBUG_KMEMLEAK_TEST is not set
>> # CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF is not set
> 
> I assume your dmesg shows some kmemleak error during boot? I’ll send
> another patch tomorrow.

Besides the BUG, I have these kmemleak messages:

$ grep kmemleak out.txt
[    0.000000] kmemleak: Kernel memory leak detector disabled
[    0.000000] kmemleak: Early log buffer exceeded (2742), please increase DEBUG_KMEMLEAK_EARLY_LOG_SIZE

Thanks,
Sasha

--
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/
diff mbox

Patch

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 0cd6aabd45a0..e7f74091c024 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1811,6 +1811,7 @@  void __init kmemleak_init(void)
 
 #ifdef CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF
 	if (!kmemleak_skip_disable) {
+		kmemleak_early_log = 0;
 		kmemleak_disable();
 		return;
 	}