* [PATCH 1/4] zswap bugfix: memory leaks when re-swapon
@ 2013-08-23 11:03 Weijie Yang
2013-08-23 15:28 ` Seth Jennings
0 siblings, 1 reply; 3+ messages in thread
From: Weijie Yang @ 2013-08-23 11:03 UTC (permalink / raw)
To: Minchan Kim, Bob Liu, sjenning; +Cc: linux-mm, linux-kernel, weijie.yang
zswap_tree is not freed when swapoff, and it got re-kzalloc in swapon,
memory leak occurs.
Add check statement in zswap_frontswap_init so that zswap_tree is
inited only once.
---
mm/zswap.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/mm/zswap.c b/mm/zswap.c
index deda2b6..1cf1c07 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -826,6 +826,11 @@ static void zswap_frontswap_init(unsigned type)
{
struct zswap_tree *tree;
+ if (zswap_trees[type]) {
+ BUG_ON(zswap_trees[type]->rbroot != RB_ROOT); /* invalidate_area set it */
+ return;
+ }
+
tree = kzalloc(sizeof(struct zswap_tree), GFP_KERNEL);
if (!tree)
goto err;
--
1.7.0.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] 3+ messages in thread
* Re: [PATCH 1/4] zswap bugfix: memory leaks when re-swapon
2013-08-23 11:03 [PATCH 1/4] zswap bugfix: memory leaks when re-swapon Weijie Yang
@ 2013-08-23 15:28 ` Seth Jennings
2013-08-25 12:00 ` Weijie Yang
0 siblings, 1 reply; 3+ messages in thread
From: Seth Jennings @ 2013-08-23 15:28 UTC (permalink / raw)
To: Weijie Yang; +Cc: Minchan Kim, Bob Liu, linux-mm, linux-kernel, weijie.yang
On Fri, Aug 23, 2013 at 07:03:37PM +0800, Weijie Yang wrote:
> zswap_tree is not freed when swapoff, and it got re-kzalloc in swapon,
> memory leak occurs.
> Add check statement in zswap_frontswap_init so that zswap_tree is
> inited only once.
>
> ---
> mm/zswap.c | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/mm/zswap.c b/mm/zswap.c
> index deda2b6..1cf1c07 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -826,6 +826,11 @@ static void zswap_frontswap_init(unsigned type)
> {
> struct zswap_tree *tree;
>
> + if (zswap_trees[type]) {
> + BUG_ON(zswap_trees[type]->rbroot != RB_ROOT); /* invalidate_area set it */
Lets leave this BUG_ON() out. If we want to make sure that the rbtree has
been properly emptied out, we should do it in
zswap_frontswap_invalidate_area() after the while loop and make it a
WARN_ON() since the problem is not fatal.
Seth
> + return;
> + }
> +
> tree = kzalloc(sizeof(struct zswap_tree), GFP_KERNEL);
> if (!tree)
> goto err;
> --
> 1.7.0.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 [flat|nested] 3+ messages in thread
* Re: [PATCH 1/4] zswap bugfix: memory leaks when re-swapon
2013-08-23 15:28 ` Seth Jennings
@ 2013-08-25 12:00 ` Weijie Yang
0 siblings, 0 replies; 3+ messages in thread
From: Weijie Yang @ 2013-08-25 12:00 UTC (permalink / raw)
To: Seth Jennings; +Cc: Minchan Kim, Bob Liu, linux-mm, linux-kernel, weijie.yang
2013/8/23 Seth Jennings <sjenning@linux.vnet.ibm.com>:
> On Fri, Aug 23, 2013 at 07:03:37PM +0800, Weijie Yang wrote:
>> zswap_tree is not freed when swapoff, and it got re-kzalloc in swapon,
>> memory leak occurs.
>> Add check statement in zswap_frontswap_init so that zswap_tree is
>> inited only once.
>>
>> ---
>> mm/zswap.c | 5 +++++
>> 1 files changed, 5 insertions(+), 0 deletions(-)
>>
>> diff --git a/mm/zswap.c b/mm/zswap.c
>> index deda2b6..1cf1c07 100644
>> --- a/mm/zswap.c
>> +++ b/mm/zswap.c
>> @@ -826,6 +826,11 @@ static void zswap_frontswap_init(unsigned type)
>> {
>> struct zswap_tree *tree;
>>
>> + if (zswap_trees[type]) {
>> + BUG_ON(zswap_trees[type]->rbroot != RB_ROOT); /* invalidate_area set it */
>
> Lets leave this BUG_ON() out. If we want to make sure that the rbtree has
> been properly emptied out, we should do it in
> zswap_frontswap_invalidate_area() after the while loop and make it a
> WARN_ON() since the problem is not fatal.
>
> Seth
>
ok.
>> + return;
>> + }
>> +
>> tree = kzalloc(sizeof(struct zswap_tree), GFP_KERNEL);
>> if (!tree)
>> goto err;
>> --
>> 1.7.0.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 [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-25 12:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-23 11:03 [PATCH 1/4] zswap bugfix: memory leaks when re-swapon Weijie Yang
2013-08-23 15:28 ` Seth Jennings
2013-08-25 12:00 ` Weijie Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).