* [PATCH 1/6] mm/kmemleak.c: Use %u to print ->checksum.
2014-05-02 13:41 [PATCH 0/6] Kmemleak updates Catalin Marinas
@ 2014-05-02 13:41 ` Catalin Marinas
2014-05-02 13:41 ` [PATCH 2/6] mm: Introduce kmemleak_update_trace() Catalin Marinas
` (4 subsequent siblings)
5 siblings, 0 replies; 13+ messages in thread
From: Catalin Marinas @ 2014-05-02 13:41 UTC (permalink / raw)
To: linux-kernel, linux-mm; +Cc: Jianpeng Ma, Andrew Morton
From: Jianpeng Ma <majianpeng@gmail.com>
Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
mm/kmemleak.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 91d67eaee050..3a36e2b16cba 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -387,7 +387,7 @@ static void dump_object_info(struct kmemleak_object *object)
pr_notice(" min_count = %d\n", object->min_count);
pr_notice(" count = %d\n", object->count);
pr_notice(" flags = 0x%lx\n", object->flags);
- pr_notice(" checksum = %d\n", object->checksum);
+ pr_notice(" checksum = %u\n", object->checksum);
pr_notice(" backtrace:\n");
print_stack_trace(&trace, 4);
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/6] mm: Introduce kmemleak_update_trace()
2014-05-02 13:41 [PATCH 0/6] Kmemleak updates Catalin Marinas
2014-05-02 13:41 ` [PATCH 1/6] mm/kmemleak.c: Use %u to print ->checksum Catalin Marinas
@ 2014-05-02 13:41 ` Catalin Marinas
2014-05-02 13:41 ` [PATCH 3/6] lib: Update the kmemleak stack trace for radix tree allocations Catalin Marinas
` (3 subsequent siblings)
5 siblings, 0 replies; 13+ messages in thread
From: Catalin Marinas @ 2014-05-02 13:41 UTC (permalink / raw)
To: linux-kernel, linux-mm; +Cc: Andrew Morton, Johannes Weiner
The memory allocation stack trace is not always useful for debugging
a memory leak (e.g. radix_tree_preload). This function, when called,
updates the stack trace for an already allocated object.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
---
Documentation/kmemleak.txt | 1 +
include/linux/kmemleak.h | 4 ++++
mm/kmemleak.c | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+)
diff --git a/Documentation/kmemleak.txt b/Documentation/kmemleak.txt
index a7563ec4ea7b..b772418bf064 100644
--- a/Documentation/kmemleak.txt
+++ b/Documentation/kmemleak.txt
@@ -142,6 +142,7 @@ kmemleak_alloc_percpu - notify of a percpu memory block allocation
kmemleak_free - notify of a memory block freeing
kmemleak_free_part - notify of a partial memory block freeing
kmemleak_free_percpu - notify of a percpu memory block freeing
+kmemleak_update_trace - update object allocation stack trace
kmemleak_not_leak - mark an object as not a leak
kmemleak_ignore - do not scan or report an object as leak
kmemleak_scan_area - add scan areas inside a memory block
diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h
index 5bb424659c04..057e95971014 100644
--- a/include/linux/kmemleak.h
+++ b/include/linux/kmemleak.h
@@ -30,6 +30,7 @@ extern void kmemleak_alloc_percpu(const void __percpu *ptr, size_t size) __ref;
extern void kmemleak_free(const void *ptr) __ref;
extern void kmemleak_free_part(const void *ptr, size_t size) __ref;
extern void kmemleak_free_percpu(const void __percpu *ptr) __ref;
+extern void kmemleak_update_trace(const void *ptr) __ref;
extern void kmemleak_not_leak(const void *ptr) __ref;
extern void kmemleak_ignore(const void *ptr) __ref;
extern void kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp) __ref;
@@ -83,6 +84,9 @@ static inline void kmemleak_free_recursive(const void *ptr, unsigned long flags)
static inline void kmemleak_free_percpu(const void __percpu *ptr)
{
}
+static inline void kmemleak_update_trace(const void *ptr)
+{
+}
static inline void kmemleak_not_leak(const void *ptr)
{
}
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 3a36e2b16cba..61a64ed2fbef 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -990,6 +990,40 @@ void __ref kmemleak_free_percpu(const void __percpu *ptr)
EXPORT_SYMBOL_GPL(kmemleak_free_percpu);
/**
+ * kmemleak_update_trace - update object allocation stack trace
+ * @ptr: pointer to beginning of the object
+ *
+ * Override the object allocation stack trace for cases where the actual
+ * allocation place is not always useful.
+ */
+void __ref kmemleak_update_trace(const void *ptr)
+{
+ struct kmemleak_object *object;
+ unsigned long flags;
+
+ pr_debug("%s(0x%p)\n", __func__, ptr);
+
+ if (!kmemleak_enabled || IS_ERR_OR_NULL(ptr))
+ return;
+
+ object = find_and_get_object((unsigned long)ptr, 1);
+ if (!object) {
+#ifdef DEBUG
+ kmemleak_warn("Updating stack trace for unknown object at %p\n",
+ ptr);
+#endif
+ return;
+ }
+
+ spin_lock_irqsave(&object->lock, flags);
+ object->trace_len = __save_stack_trace(object->trace);
+ spin_unlock_irqrestore(&object->lock, flags);
+
+ put_object(object);
+}
+EXPORT_SYMBOL(kmemleak_update_trace);
+
+/**
* kmemleak_not_leak - mark an allocated object as false positive
* @ptr: pointer to beginning of the object
*
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/6] lib: Update the kmemleak stack trace for radix tree allocations
2014-05-02 13:41 [PATCH 0/6] Kmemleak updates Catalin Marinas
2014-05-02 13:41 ` [PATCH 1/6] mm/kmemleak.c: Use %u to print ->checksum Catalin Marinas
2014-05-02 13:41 ` [PATCH 2/6] mm: Introduce kmemleak_update_trace() Catalin Marinas
@ 2014-05-02 13:41 ` Catalin Marinas
2014-05-02 13:48 ` Johannes Weiner
2014-05-02 13:41 ` [PATCH 4/6] mm: Update the kmemleak stack trace for mempool allocations Catalin Marinas
` (2 subsequent siblings)
5 siblings, 1 reply; 13+ messages in thread
From: Catalin Marinas @ 2014-05-02 13:41 UTC (permalink / raw)
To: linux-kernel, linux-mm; +Cc: Andrew Morton, Johannes Weiner
Since radix_tree_preload() stack trace is not always useful for
debugging an actual radix tree memory leak, this patch updates the
kmemleak allocation stack trace in the radix_tree_node_alloc() function.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
---
lib/radix-tree.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 9599aa72d7a0..5297f8e09096 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -27,6 +27,7 @@
#include <linux/radix-tree.h>
#include <linux/percpu.h>
#include <linux/slab.h>
+#include <linux/kmemleak.h>
#include <linux/notifier.h>
#include <linux/cpu.h>
#include <linux/string.h>
@@ -200,6 +201,11 @@ radix_tree_node_alloc(struct radix_tree_root *root)
rtp->nodes[rtp->nr - 1] = NULL;
rtp->nr--;
}
+ /*
+ * Update the allocation stack trace as this is more useful
+ * for debugging.
+ */
+ kmemleak_update_trace(ret);
}
if (ret == NULL)
ret = kmem_cache_alloc(radix_tree_node_cachep, gfp_mask);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 3/6] lib: Update the kmemleak stack trace for radix tree allocations
2014-05-02 13:41 ` [PATCH 3/6] lib: Update the kmemleak stack trace for radix tree allocations Catalin Marinas
@ 2014-05-02 13:48 ` Johannes Weiner
0 siblings, 0 replies; 13+ messages in thread
From: Johannes Weiner @ 2014-05-02 13:48 UTC (permalink / raw)
To: Catalin Marinas; +Cc: linux-kernel, linux-mm, Andrew Morton
On Fri, May 02, 2014 at 02:41:07PM +0100, Catalin Marinas wrote:
> Since radix_tree_preload() stack trace is not always useful for
> debugging an actual radix tree memory leak, this patch updates the
> kmemleak allocation stack trace in the radix_tree_node_alloc() function.
>
> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Thanks Catalin!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 4/6] mm: Update the kmemleak stack trace for mempool allocations
2014-05-02 13:41 [PATCH 0/6] Kmemleak updates Catalin Marinas
` (2 preceding siblings ...)
2014-05-02 13:41 ` [PATCH 3/6] lib: Update the kmemleak stack trace for radix tree allocations Catalin Marinas
@ 2014-05-02 13:41 ` Catalin Marinas
2014-05-02 13:41 ` [PATCH 5/6] mm: Call kmemleak directly from memblock_(alloc|free) Catalin Marinas
2014-05-02 13:41 ` [PATCH 6/6] mm: Postpone the disabling of kmemleak early logging Catalin Marinas
5 siblings, 0 replies; 13+ messages in thread
From: Catalin Marinas @ 2014-05-02 13:41 UTC (permalink / raw)
To: linux-kernel, linux-mm; +Cc: Andrew Morton
When mempool_alloc() returns an existing pool object, kmemleak_alloc()
is no longer called and the stack trace corresponds to the original
object allocation. This patch updates the kmemleak allocation stack
trace for such objects to make it more useful for debugging.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
mm/mempool.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mm/mempool.c b/mm/mempool.c
index 905434f18c97..e7c4be024f1a 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -10,6 +10,7 @@
#include <linux/mm.h>
#include <linux/slab.h>
+#include <linux/kmemleak.h>
#include <linux/export.h>
#include <linux/mempool.h>
#include <linux/blkdev.h>
@@ -220,6 +221,11 @@ repeat_alloc:
spin_unlock_irqrestore(&pool->lock, flags);
/* paired with rmb in mempool_free(), read comment there */
smp_wmb();
+ /*
+ * Update the allocation stack trace as this is more useful
+ * for debugging.
+ */
+ kmemleak_update_trace(element);
return element;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/6] mm: Call kmemleak directly from memblock_(alloc|free)
2014-05-02 13:41 [PATCH 0/6] Kmemleak updates Catalin Marinas
` (3 preceding siblings ...)
2014-05-02 13:41 ` [PATCH 4/6] mm: Update the kmemleak stack trace for mempool allocations Catalin Marinas
@ 2014-05-02 13:41 ` Catalin Marinas
2014-05-02 13:41 ` [PATCH 6/6] mm: Postpone the disabling of kmemleak early logging Catalin Marinas
5 siblings, 0 replies; 13+ messages in thread
From: Catalin Marinas @ 2014-05-02 13:41 UTC (permalink / raw)
To: linux-kernel, linux-mm; +Cc: Andrew Morton
Kmemleak could ignore memory blocks allocated via memblock_alloc()
leading to false positives during scanning. This patch adds the
corresponding callbacks and removes kmemleak_free_* calls in
mm/nobootmem.c to avoid duplication. The kmemleak_alloc() in
mm/nobootmem.c is kept since __alloc_memory_core_early() does not use
memblock_alloc() directly.
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
mm/memblock.c | 9 ++++++++-
mm/nobootmem.c | 2 --
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/mm/memblock.c b/mm/memblock.c
index e9d6ca9a01a9..8813a31d7fbd 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -681,6 +681,7 @@ int __init_memblock memblock_free(phys_addr_t base, phys_addr_t size)
(unsigned long long)base + size - 1,
(void *)_RET_IP_);
+ kmemleak_free_part(__va(base), size);
return __memblock_remove(&memblock.reserved, base, size);
}
@@ -985,8 +986,14 @@ static phys_addr_t __init memblock_alloc_base_nid(phys_addr_t size,
align = SMP_CACHE_BYTES;
found = memblock_find_in_range_node(size, align, 0, max_addr, nid);
- if (found && !memblock_reserve(found, size))
+ if (found && !memblock_reserve(found, size)) {
+ /*
+ * The min_count is set to 0 so that memblock allocations are
+ * never reported as leaks.
+ */
+ kmemleak_alloc(__va(found), size, 0, 0);
return found;
+ }
return 0;
}
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 04a9d94333a5..7ed58602e71b 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -197,7 +197,6 @@ unsigned long __init free_all_bootmem(void)
void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
unsigned long size)
{
- kmemleak_free_part(__va(physaddr), size);
memblock_free(physaddr, size);
}
@@ -212,7 +211,6 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
*/
void __init free_bootmem(unsigned long addr, unsigned long size)
{
- kmemleak_free_part(__va(addr), size);
memblock_free(addr, size);
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/6] mm: Postpone the disabling of kmemleak early logging
2014-05-02 13:41 [PATCH 0/6] Kmemleak updates Catalin Marinas
` (4 preceding siblings ...)
2014-05-02 13:41 ` [PATCH 5/6] mm: Call kmemleak directly from memblock_(alloc|free) Catalin Marinas
@ 2014-05-02 13:41 ` Catalin Marinas
2014-05-06 15:20 ` Sasha Levin
5 siblings, 1 reply; 13+ messages in thread
From: Catalin Marinas @ 2014-05-02 13:41 UTC (permalink / raw)
To: linux-kernel, linux-mm; +Cc: Andrew Morton
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>
---
mm/kmemleak.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 61a64ed2fbef..0cd6aabd45a0 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1809,8 +1809,6 @@ void __init kmemleak_init(void)
int i;
unsigned long flags;
- kmemleak_early_log = 0;
-
#ifdef CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF
if (!kmemleak_skip_disable) {
kmemleak_disable();
@@ -1833,8 +1831,9 @@ void __init kmemleak_init(void)
if (kmemleak_error) {
local_irq_restore(flags);
return;
- } else
- kmemleak_enabled = 1;
+ }
+ kmemleak_early_log = 0;
+ kmemleak_enabled = 1;
local_irq_restore(flags);
/*
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 6/6] mm: Postpone the disabling of kmemleak early logging
2014-05-02 13:41 ` [PATCH 6/6] mm: Postpone the disabling of kmemleak early logging Catalin Marinas
@ 2014-05-06 15:20 ` Sasha Levin
2014-05-06 17:05 ` Catalin Marinas
0 siblings, 1 reply; 13+ messages in thread
From: Sasha Levin @ 2014-05-06 15:20 UTC (permalink / raw)
To: Catalin Marinas; +Cc: linux-kernel, linux-mm, Andrew Morton
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
[ 24.473021] PGD 10e30067 PUD 10e31063 PMD 12200062
[ 24.473544] Oops: 0010 [#1] PREEMPT SMP DEBUG_PAGEALLOC
[ 24.474129] Dumping ftrace buffer:
[ 24.474535] (ftrace buffer empty)
[ 24.474901] Modules linked in:
[ 24.475220] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 3.15.0-rc4-sasha-00193-g315d7bf #442
[ 24.476094] task: ffff88025c540000 ti: ffff880036210000 task.ti: ffff880036210000
[ 24.476807] RIP: 0010:[<ffffffff922f2b93>] [<ffffffff922f2b93>] log_early+0x0/0xcd
[ 24.477561] RSP: 0000:ffff880036211c20 EFLAGS: 00010246
[ 24.478075] RAX: 0000000000000000 RBX: ffff880034e26458 RCX: 0000000000000001
[ 24.478727] RDX: 0000000000000400 RSI: ffff880034e26458 RDI: 0000000000000000
[ 24.479400] RBP: ffff880036211c48 R08: 0000000000000000 R09: 0000000000000000
[ 24.480064] R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000400
[ 24.480171] R13: 0000000000000001 R14: 0000000000000001 R15: ffff88003680e600
[ 24.480171] FS: 0000000000000000(0000) GS:ffff880036c00000(0000) knlGS:0000000000000000
[ 24.480171] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[ 24.480171] CR2: ffffffff922f2b93 CR3: 0000000010e2d000 CR4: 00000000000006b0
[ 24.480171] Stack:
[ 24.480171] ffffffff8f4fb6ac ffff880036ddb210 ffff880034e26458 0000000000000020
[ 24.480171] ffff88003680e600 ffff880036211cc8 ffffffff8c2e0bf1 0000000000000002
[ 24.480171] 000000008c19b731 ffffffff8cb07a03 0000000000000000 0000000000000400
[ 24.480171] Call Trace:
[ 24.480171] [<ffffffff8f4fb6ac>] ? kmemleak_alloc+0xac/0xd0
[ 24.480171] [<ffffffff8c2e0bf1>] kmem_cache_alloc_node_trace+0x201/0x3d0
[ 24.480171] [<ffffffff8cb07a03>] ? alloc_cpumask_var_node+0x23/0x90
[ 24.480171] [<ffffffff8f566358>] ? preempt_count_sub+0xd8/0x130
[ 24.480171] [<ffffffff8c0c16e0>] ? alloc_pte_page+0x80/0x80
[ 24.480171] [<ffffffff8cb07a03>] alloc_cpumask_var_node+0x23/0x90
[ 24.480171] [<ffffffff8cb07a7e>] alloc_cpumask_var+0xe/0x10
[ 24.480171] [<ffffffff8c0a8a0a>] native_send_call_func_ipi+0x2a/0x130
[ 24.480171] [<ffffffff8cb07bee>] ? cpumask_next_and+0xae/0xd0
[ 24.480171] [<ffffffff8c0c16e0>] ? alloc_pte_page+0x80/0x80
[ 24.480171] [<ffffffff8c0c16e0>] ? alloc_pte_page+0x80/0x80
[ 24.480171] [<ffffffff8c20121b>] smp_call_function_many+0x29b/0x390
[ 24.480171] [<ffffffff8c0c16e0>] ? alloc_pte_page+0x80/0x80
[ 24.480171] [<ffffffff8c201726>] smp_call_function+0x46/0x80
[ 24.480171] [<ffffffff8c0c16e0>] ? alloc_pte_page+0x80/0x80
[ 24.480171] [<ffffffff8c2017ce>] on_each_cpu+0x3e/0x110
[ 24.480171] [<ffffffff8c0c3adb>] change_page_attr_set_clr+0x40b/0x4f0
[ 24.480171] [<ffffffff8c19b731>] ? get_parent_ip+0x11/0x50
[ 24.480171] [<ffffffff8c0c49ef>] set_memory_np+0x2f/0x40
[ 24.480171] [<ffffffff8c0bf32d>] free_init_pages+0x8d/0xb0
[ 24.480171] [<ffffffff8f4f7d60>] ? rest_init+0x140/0x140
[ 24.480171] [<ffffffff8c0bf373>] free_initmem+0x23/0x30
[ 24.480171] [<ffffffff8f4f7d78>] kernel_init+0x18/0x100
[ 24.480171] [<ffffffff8f56b0fc>] ret_from_fork+0x7c/0xb0
[ 24.480171] [<ffffffff8f4f7d60>] ? rest_init+0x140/0x140
[ 24.480171] Code: Bad RIP value.
[ 24.480171] RIP [<ffffffff922f2b93>] log_early+0x0/0xcd
[ 24.480171] RSP <ffff880036211c20>
[ 24.480171] CR2: ffffffff922f2b93
Thanks,
Sasha
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 6/6] mm: Postpone the disabling of kmemleak early logging
2014-05-06 15:20 ` Sasha Levin
@ 2014-05-06 17:05 ` Catalin Marinas
2014-05-06 18:15 ` Sasha Levin
0 siblings, 1 reply; 13+ messages in thread
From: Catalin Marinas @ 2014-05-06 17:05 UTC (permalink / raw)
To: Sasha Levin
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton
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?
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;
}
Thanks.
--
Catalin
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 6/6] mm: Postpone the disabling of kmemleak early logging
2014-05-06 17:05 ` Catalin Marinas
@ 2014-05-06 18:15 ` Sasha Levin
2014-05-06 21:52 ` Catalin Marinas
0 siblings, 1 reply; 13+ messages in thread
From: Sasha Levin @ 2014-05-06 18:15 UTC (permalink / raw)
To: Catalin Marinas
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton
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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 6/6] mm: Postpone the disabling of kmemleak early logging
2014-05-06 18:15 ` Sasha Levin
@ 2014-05-06 21:52 ` Catalin Marinas
2014-05-06 23:08 ` Sasha Levin
0 siblings, 1 reply; 13+ messages in thread
From: Catalin Marinas @ 2014-05-06 21:52 UTC (permalink / raw)
To: Sasha Levin
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton,
Li Zefan
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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 6/6] mm: Postpone the disabling of kmemleak early logging
2014-05-06 21:52 ` Catalin Marinas
@ 2014-05-06 23:08 ` Sasha Levin
0 siblings, 0 replies; 13+ messages in thread
From: Sasha Levin @ 2014-05-06 23:08 UTC (permalink / raw)
To: Catalin Marinas
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton,
Li Zefan
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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 13+ messages in thread