* [PATCH] btree: Fix the bug to release whole btree nodes
@ 2014-05-08 4:21 Minfei Huang
2014-05-08 22:44 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Minfei Huang @ 2014-05-08 4:21 UTC (permalink / raw)
To: akpm, gregkh, tj, davem, dborkman
Cc: linux-kernel, Minfei Huang, Joern Engel, Johannes Berg
I use the btree which pickes up the latest version of kernel source
3.14-rc2 in my own module. When the btree module is removed, a warning arised:
kmem_cache_destroy btree_node: Slab cache still has objects
CPU: 13 PID: 9150 Comm: rmmod Tainted: GF O 3.14.0-rc2 #1
Hardware name: Inspur NF5270M3/NF5270M3, BIOS CHEETAH_2.1.3 09/10/2013
ffff881ff8643b18 ffff881ffdc23ea8 ffffffff815a4ecc 0000000000000000
ffff881ff8643ac0 ffff881ffdc23ec8 ffffffff811610df 0000000000000880
ffffffffa057da60 ffff881ffdc23ed8 ffffffffa057d57c ffff881ffdc23f78
Call Trace:
[<ffffffff815a4ecc>] dump_stack+0x49/0x5d
[<ffffffff811610df>] kmem_cache_destroy+0xcf/0xe0
[<ffffffffa057d57c>] btree_module_exit+0x10/0x12 [btree]
[<ffffffff810d7948>] SyS_delete_module+0x198/0x1f0
[<ffffffff815aac89>] ? retint_swapgs+0xe/0x13
[<ffffffff810a561d>] ? trace_hardirqs_on_caller+0xfd/0x1c0
[<ffffffff812addde>] ? trace_hardirqs_on_thunk+0x3a/0x3f
[<ffffffff815b3652>] system_call_fastpath+0x16/0x1b
The cause is that it doesn't release the last btree node,
when height = 1 and fill = 1.
Signed-off-by: Minfei Huang <huangminfei@ucloud.cn>
CC: Joern Engel <joern@logfs.org>
CC: Johannes Berg <johannes@sipsolutions.net>
---
lib/btree.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib/btree.c b/lib/btree.c
index f9a4846..725bf8b 100644
--- a/lib/btree.c
+++ b/lib/btree.c
@@ -198,6 +198,8 @@ EXPORT_SYMBOL_GPL(btree_init);
void btree_destroy(struct btree_head *head)
{
+ if (head->node)
+ mempool_free(head->node, head->mempool);
mempool_destroy(head->mempool);
head->mempool = NULL;
}
--
1.7.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btree: Fix the bug to release whole btree nodes
2014-05-08 4:21 [PATCH] btree: Fix the bug to release whole btree nodes Minfei Huang
@ 2014-05-08 22:44 ` Andrew Morton
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2014-05-08 22:44 UTC (permalink / raw)
To: Minfei Huang
Cc: gregkh, tj, davem, dborkman, linux-kernel, Joern Engel, Johannes Berg
On Thu, 8 May 2014 12:21:12 +0800 Minfei Huang <huangminfei@ucloud.cn> wrote:
> I use the btree which pickes up the latest version of kernel source
> 3.14-rc2 in my own module. When the btree module is removed, a warning arised:
>
> kmem_cache_destroy btree_node: Slab cache still has objects
> CPU: 13 PID: 9150 Comm: rmmod Tainted: GF O 3.14.0-rc2 #1
> Hardware name: Inspur NF5270M3/NF5270M3, BIOS CHEETAH_2.1.3 09/10/2013
> ffff881ff8643b18 ffff881ffdc23ea8 ffffffff815a4ecc 0000000000000000
> ffff881ff8643ac0 ffff881ffdc23ec8 ffffffff811610df 0000000000000880
> ffffffffa057da60 ffff881ffdc23ed8 ffffffffa057d57c ffff881ffdc23f78
> Call Trace:
> [<ffffffff815a4ecc>] dump_stack+0x49/0x5d
> [<ffffffff811610df>] kmem_cache_destroy+0xcf/0xe0
> [<ffffffffa057d57c>] btree_module_exit+0x10/0x12 [btree]
> [<ffffffff810d7948>] SyS_delete_module+0x198/0x1f0
> [<ffffffff815aac89>] ? retint_swapgs+0xe/0x13
> [<ffffffff810a561d>] ? trace_hardirqs_on_caller+0xfd/0x1c0
> [<ffffffff812addde>] ? trace_hardirqs_on_thunk+0x3a/0x3f
> [<ffffffff815b3652>] system_call_fastpath+0x16/0x1b
>
> The cause is that it doesn't release the last btree node,
> when height = 1 and fill = 1.
Thanks.
> --- a/lib/btree.c
> +++ b/lib/btree.c
> @@ -198,6 +198,8 @@ EXPORT_SYMBOL_GPL(btree_init);
>
> void btree_destroy(struct btree_head *head)
> {
> + if (head->node)
> + mempool_free(head->node, head->mempool);
> mempool_destroy(head->mempool);
> head->mempool = NULL;
We don't really need the test - mempool_free(NULL, ...) is an OK thing
to do. We conventionally will rely upon this for optimisation reasons,
although not having the test can sometimes make the code less clear.
--- a/lib/btree.c~lib-btreec-fix-leak-of-whole-btree-nodes-fix
+++ a/lib/btree.c
@@ -198,8 +198,7 @@ EXPORT_SYMBOL_GPL(btree_init);
void btree_destroy(struct btree_head *head)
{
- if (head->node)
- mempool_free(head->node, head->mempool);
+ mempool_free(head->node, head->mempool);
mempool_destroy(head->mempool);
head->mempool = NULL;
}
_
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] btree: Fix the bug to release whole btree nodes
@ 2014-02-20 8:45 Minfei Huang
0 siblings, 0 replies; 3+ messages in thread
From: Minfei Huang @ 2014-02-20 8:45 UTC (permalink / raw)
To: linux-kernel; +Cc: Minfei Huang, Joern Engel, Johannes Berg
I use the btree which pickes up the latest version of kernel source
3.14-rc2 in my own module. When the btree module is removed, a warning arised:
kmem_cache_destroy btree_node: Slab cache still has objects
CPU: 13 PID: 9150 Comm: rmmod Tainted: GF O 3.14.0-rc2 #1
Hardware name: Inspur NF5270M3/NF5270M3, BIOS CHEETAH_2.1.3 09/10/2013
ffff881ff8643b18 ffff881ffdc23ea8 ffffffff815a4ecc 0000000000000000
ffff881ff8643ac0 ffff881ffdc23ec8 ffffffff811610df 0000000000000880
ffffffffa057da60 ffff881ffdc23ed8 ffffffffa057d57c ffff881ffdc23f78
Call Trace:
[<ffffffff815a4ecc>] dump_stack+0x49/0x5d
[<ffffffff811610df>] kmem_cache_destroy+0xcf/0xe0
[<ffffffffa057d57c>] btree_module_exit+0x10/0x12 [btree]
[<ffffffff810d7948>] SyS_delete_module+0x198/0x1f0
[<ffffffff815aac89>] ? retint_swapgs+0xe/0x13
[<ffffffff810a561d>] ? trace_hardirqs_on_caller+0xfd/0x1c0
[<ffffffff812addde>] ? trace_hardirqs_on_thunk+0x3a/0x3f
[<ffffffff815b3652>] system_call_fastpath+0x16/0x1b
The cause is that it doesn't release the last btree node,
when height = 1 and fill = 1.
Signed-off-by: Minfei Huang <huangminfei@ucloud.cn>
CC: Joern Engel <joern@logfs.org>
CC: Johannes Berg <johannes@sipsolutions.net>
---
lib/btree.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/lib/btree.c b/lib/btree.c
index f9a4846..fd17d26 100644
--- a/lib/btree.c
+++ b/lib/btree.c
@@ -444,6 +444,16 @@ static void btree_shrink(struct btree_head *head, struct btree_geo *geo)
mempool_free(node, head->mempool);
}
+static void btree_shrink_head(struct btree_head *head)
+{
+ if (head->height != 1)
+ return;
+
+ mempool_free(head->node, head->mempool);
+ head->node = NULL;
+ head->height--;
+}
+
static int btree_insert_level(struct btree_head *head, struct btree_geo *geo,
unsigned long *key, void *val, int level,
gfp_t gfp)
@@ -620,6 +630,8 @@ static void *btree_remove_level(struct btree_head *head, struct btree_geo *geo,
rebalance(head, geo, key, level, node, fill - 1);
else if (fill - 1 == 1)
btree_shrink(head, geo);
+ else if (fill - 1 == 0)
+ btree_shrink_head(head);
}
return ret;
--
1.7.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-08 22:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-08 4:21 [PATCH] btree: Fix the bug to release whole btree nodes Minfei Huang
2014-05-08 22:44 ` Andrew Morton
-- strict thread matches above, loose matches on Subject: below --
2014-02-20 8:45 Minfei Huang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®