Skip to contentSkip to conversation

percpu : fix the memory leak

PATCH New Huang Shijie 5 participants 8 messages Aug 8, 2010 – Sep 17, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 percpu : fix the memory leak

The origin code did not free the old map.
The patch fixes it.

---
 mm/percpu.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
mm/percpu.c +1 -0
index e61dc2c..d1c94e3 100644
@@ -393,6 +393,7 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)
 		goto out_unlock;
 
 	old_size = chunk->map_alloc * sizeof(chunk->map[0]);
+	old	 = chunk->map;
 	memcpy(new, chunk->map, old_size);
 
 	chunk->map_alloc = new_alloc;
Signature · 7 lines
1.6.6.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer
#1 lore raw

PATCH 1/1 percpu: fix a memory leak in pcpu_extend_area_map()

maintainer
#2 lore raw

Re: [PATCH] percpu: fix a memory leak in pcpu_extend_area_map()

Quoted 11 lines · On Sun, 08 Aug 2010 14:42:57 +0200 Tejun Heo <[email protected]> wrote:
Quoted 1 line

From 206c53730b8b1707becca7a868ea8d14ebee24d2 Mon Sep 17 00:00:00 2001

From: Huang Shijie <[email protected]>
Date: Sun, 8 Aug 2010 14:39:07 +0200

The original code did not free the old map. This patch fixes it.

tj: use @old as memcpy source instead of @chunk->map, and indentation
and description update

Should have had a cc:stable in the changelog, IMO.

Quoted 4 lines

---
Patch applied to percpu#for-linus w/ some updates. Thanks a lot for catching this.

This patch appears to have been lost?

Quoted 5 lines
mm/percpu.c +0 -0
index e61dc2c..a1830d8 100644

mm/percpu.c static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc) · line 401

Quoted 10 lines
mm/percpu.c +3 -1
@@ -393,7 +393,9 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)
 		goto out_unlock;
 
 	old_size = chunk->map_alloc * sizeof(chunk->map[0]);
-	memcpy(new, chunk->map, old_size);
+	old = chunk->map;
+
+	memcpy(new, old, old_size);
 
 	chunk->map_alloc = new_alloc;
 	chunk->map = new;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#3 lore raw

Re: [PATCH] percpu: fix a memory leak in pcpu_extend_area_map()

Hello,

Quoted 4 lines · Andrew Morton
Quoted 2 lines

Patch applied to percpu#for-linus w/ some updates. Thanks a lot for catching this.

This patch appears to have been lost?

It has been in percpu#for-linus. Given the way percpu allocator is currently used, the bug isn't likely to cause any real leakage, so I was waiting a bit before pushing it out. I'll push it today.

Thanks.

Signature · 7 lines
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#4 lore raw

breaks 2.6.32.21+ (was: [PATCH] percpu: fix a memory leak in pcpu_extend_area_map())

In reply to Tejun Heo

Hey,

The patch quoted below seems to have made it into Greg's stable-queue for 2.6.32.

I tried building a kernel based on 2.6.32.21 plus all the patches currently in that queue. The resulting kernel unfortunately didn't boot for me, neither as a 32 nor as 64 bit x86 kernel.

I have put up a screenshot of a trace at
http://asteria.noreply.org/~weasel/volatile/2010-09-16-SrLl9JHtDTg/trace-64bit.png
since the kernel fortunately also died in kvm - unfortunately only the last 60 lines are easily available. If you need more I could try to set up some serial console thing to catch more.

Bisecting led to this patch and reverting "percpu: fix a memory leak in pcpu_extend_area_map()" makes the kernel boot for me again.

Quoted 23 lines

From 206c53730b8b1707becca7a868ea8d14ebee24d2 Mon Sep 17 00:00:00 2001
From: Huang Shijie <[email protected]>
Date: Sun, 8 Aug 2010 14:39:07 +0200

The original code did not free the old map. This patch fixes it.

tj: use @old as memcpy source instead of @chunk->map, and indentation
and description update

---
Patch applied to percpu#for-linus w/ some updates. Thanks a lot for catching this.

 mm/percpu.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
mm/percpu.c +0 -0
index e61dc2c..a1830d8 100644

mm/percpu.c static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc) · line 401

Quoted 10 lines
mm/percpu.c +3 -1
@@ -393,7 +393,9 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)
 		goto out_unlock;
 
 	old_size = chunk->map_alloc * sizeof(chunk->map[0]);
-	memcpy(new, chunk->map, old_size);
+	old = chunk->map;
+
+	memcpy(new, old, old_size);
 
 	chunk->map_alloc = new_alloc;
 	chunk->map = new;

Cheers,
Peter

Signature · 10 lines
                           |  .''`.  ** Debian GNU/Linux **
      Peter Palfrader      | : :' :      The  universal
 http://www.palfrader.org/ | `. `'      Operating System
                           |   `-    http://www.debian.org/

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#5 lore raw

Re: [stable] breaks 2.6.32.21+ (was: [PATCH] percpu: fix a memory leak in pcpu_extend_area_map())

Quoted 9 lines · Peter Palfrader

Hey,

The patch quoted below seems to have made it into Greg's stable-queue for 2.6.32.

I tried building a kernel based on 2.6.32.21 plus all the patches currently in that queue. The resulting kernel unfortunately didn't boot for me, neither as a 32 nor as 64 bit x86 kernel.

Quoted 8 lines

I have put up a screenshot of a trace at
http://asteria.noreply.org/~weasel/volatile/2010-09-16-SrLl9JHtDTg/trace-64bit.png
since the kernel fortunately also died in kvm - unfortunately only the last 60 lines are easily available. If you need more I could try to set up some serial console thing to catch more.

Bisecting led to this patch and reverting "percpu: fix a memory leak in pcpu_extend_area_map()" makes the kernel boot for me again.

Odd, someone just reported the same problem for .35-stable as well.

Tejun, what's going on here?

thanks,

greg k-h

Quoted 32 lines
Quoted 32 lines

From 206c53730b8b1707becca7a868ea8d14ebee24d2 Mon Sep 17 00:00:00 2001
From: Huang Shijie <[email protected]>
Date: Sun, 8 Aug 2010 14:39:07 +0200

The original code did not free the old map. This patch fixes it.

tj: use @old as memcpy source instead of @chunk->map, and indentation
and description update

---
Patch applied to percpu#for-linus w/ some updates. Thanks a lot for catching this.

 mm/percpu.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
mm/percpu.c +3 -1
index e61dc2c..a1830d8 100644
@@ -393,7 +393,9 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)
 		goto out_unlock;
 
 	old_size = chunk->map_alloc * sizeof(chunk->map[0]);
-	memcpy(new, chunk->map, old_size);
+	old = chunk->map;
+
+	memcpy(new, old, old_size);
 
Quoted 15 lines

mm/percpu.c static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc) · line 401

Quoted 2 lines
mm/percpu.c +0 -0
 	chunk->map_alloc = new_alloc;
 	chunk->map = new;

Cheers,
Peter

Signature · 9 lines
                           |  .''`.  ** Debian GNU/Linux **
      Peter Palfrader      | : :' :      The  universal
 http://www.palfrader.org/ | `. `'      Operating System
                           |   `-    http://www.debian.org/

_______________________________________________
stable mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/stable

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#6 lore raw

Re: [stable] breaks 2.6.32.21+

Quoted 3 lines · Greg KH

Odd, someone just reported the same problem for .35-stable as well.

Tejun, what's going on here?

Please drop it. The memory leak was introduced after 2.6.36-rc1. I got confused which commit was in which kernel. I'll be more careful with stable cc's. Sorry about that.

Signature · 7 lines
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#7 lore raw

Re: [stable] breaks 2.6.32.21+

Quoted 8 lines · Tejun Heo
Quoted 3 lines · Greg KH

Odd, someone just reported the same problem for .35-stable as well.

Tejun, what's going on here?

Please drop it. The memory leak was introduced after 2.6.36-rc1. I got confused which commit was in which kernel. I'll be more careful with stable cc's. Sorry about that.

No problem, now dropped.

thanks,

greg k-h