Skip to contentSkip to conversation

Patch "percpu: fix a memory leak in pcpu_extend_area_map()" has been added to the 2.6.35-stable tree

DISCUSSION Stefan Lippers-Hollmann 3 participants 5 messages Sep 16, 2010 – Sep 17, 2010 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 12845915543097@site

#1 lore raw

Hi

Quoted 4 lines · On Thursday 16 September 2010, [email protected] wrote:

This is a note to let you know that I've just added the patch titled
percpu: fix a memory leak in pcpu_extend_area_map()
to the 2.6.35-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

[...]

Quoted 5 lines

From a002d148426f40bc2b7dc066982eb177cdebeaaa Mon Sep 17 00:00:00 2001
From: Huang Shijie <[email protected]>
Date: Sun, 8 Aug 2010 14:39:07 +0200
Subject: percpu: fix a memory leak in pcpu_extend_area_map()

Quoted 8 lines

From: Huang Shijie <[email protected]>

commit a002d148426f40bc2b7dc066982eb177cdebeaaa upstream.

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

This patch, as part of the current -stable queue-2.6.35, breaks booting for me on nforce4/ AMD64 X2. Unfortunately it fails even before the serial console is initialized and the only messages shown on screen are:

Decompressing Linux... Parsing ELF... done.
Booting kernel.

[...]

mm/percpu.c static int pcpu_extend_area_map(struct p · line 398

Quoted 13 lines
mm/percpu.c +3 -1
@@ -390,7 +390,9 @@ static int pcpu_extend_area_map(struct p
 		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);
 
 	/*
 	 * map_alloc < PCPU_DFL_MAP_ALLOC indicates that the chunk is

Reverting just this patch from the current queue-2.6.35 fixes the issue for me; gzipped kernel config (amd64) attached.

Regards
Stefan Lippers-Hollmann

#2 lore raw
Quoted 41 lines · Stefan Lippers-Hollmann

Hi

Quoted 4 lines · On Thursday 16 September 2010, [email protected] wrote:

This is a note to let you know that I've just added the patch titled
percpu: fix a memory leak in pcpu_extend_area_map()
to the 2.6.35-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

[...]

Quoted 5 lines

From a002d148426f40bc2b7dc066982eb177cdebeaaa Mon Sep 17 00:00:00 2001
From: Huang Shijie <[email protected]>
Date: Sun, 8 Aug 2010 14:39:07 +0200
Subject: percpu: fix a memory leak in pcpu_extend_area_map()

Quoted 8 lines

From: Huang Shijie <[email protected]>

commit a002d148426f40bc2b7dc066982eb177cdebeaaa upstream.

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

This patch, as part of the current -stable queue-2.6.35, breaks booting for me on nforce4/ AMD64 X2. Unfortunately it fails even before the serial console is initialized and the only messages shown on screen are:

Decompressing Linux... Parsing ELF... done.
Booting kernel.

[...]

Quoted 11 lines
mm/percpu.c +3 -1
@@ -390,7 +390,9 @@ static int pcpu_extend_area_map(struct p
 		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 5 lines

mm/percpu.c static int pcpu_extend_area_map(struct p · line 398

Quoted 2 lines
mm/percpu.c +0 -0
 	/*
 	 * map_alloc < PCPU_DFL_MAP_ALLOC indicates that the chunk is

Reverting just this patch from the current queue-2.6.35 fixes the issue for me; gzipped kernel config (amd64) attached.

Does Linus's tree also cause the same problems for you?

thanks,

greg k-h

#3 lore raw

Hi

Quoted 1 line · Greg KH

On Thu, Sep 16, 2010 at 11:39:02PM +0200, Stefan Lippers-Hollmann wrote:

[...]

Quoted 26 lines
Quoted 26 lines · On Thursday 16 September 2010, [email protected] wrote:
Quoted 4 lines

This is a note to let you know that I've just added the patch titled
percpu: fix a memory leak in pcpu_extend_area_map()
to the 2.6.35-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

[...]

Quoted 5 lines

From a002d148426f40bc2b7dc066982eb177cdebeaaa Mon Sep 17 00:00:00 2001
From: Huang Shijie <[email protected]>
Date: Sun, 8 Aug 2010 14:39:07 +0200
Subject: percpu: fix a memory leak in pcpu_extend_area_map()

Quoted 8 lines

From: Huang Shijie <[email protected]>

commit a002d148426f40bc2b7dc066982eb177cdebeaaa upstream.

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

This patch, as part of the current -stable queue-2.6.35, breaks booting for me on nforce4/ AMD64 X2. Unfortunately it fails even before the serial console is initialized and the only messages shown on screen are:

Decompressing Linux... Parsing ELF... done.
Booting kernel.

[...]

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
mm/percpu.c +3 -1
@@ -390,7 +390,9 @@ static int pcpu_extend_area_map(struct p
 		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 7 lines
Quoted 5 lines

mm/percpu.c static int pcpu_extend_area_map(struct p · line 398

Quoted 2 lines
mm/percpu.c +0 -0
 	/*
 	 * map_alloc < PCPU_DFL_MAP_ALLOC indicates that the chunk is

Reverting just this patch from the current queue-2.6.35 fixes the issue for me; gzipped kernel config (amd64) attached.

Does Linus's tree also cause the same problems for you?

Current linux-2.6 HEAD (v2.6.36-rc4-134-g03a7ab0) boots and works fine with a config very closely derived from the previous one.

Regards
Stefan Lippers-Hollmann

#4 lore raw
In reply to Stefan Lippers-Hollmann

hi :

I think this maybe caused by the kfree/vfree.
I do not have any AMD machine. Could you add some log to debug it
? such as in pcpu_extend_area_map():

        ================================
        printk(KERN_INFO "[ %s ] line : %d\n", __func__, __LINE__);
	pcpu_mem_free(old, old_size);
        printk(KERN_INFO "[ %s ] line : %d\n", __func__, __LINE__);
        pcpu_mem_free(new, new_size);
        printk(KERN_INFO "[ %s ] line : %d\n", __func__, __LINE__);

        ================================

The system will print the log before it hung.

Best Regards.
Huang Shijie

2010/9/17 Stefan Lippers-Hollmann <[email protected]>:

Quoted 50 lines

Hi

Quoted 4 lines · On Thursday 16 September 2010, [email protected] wrote:

This is a note to let you know that I've just added the patch titled
    percpu: fix a memory leak in pcpu_extend_area_map() to the 2.6.35-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

[...]

Quoted 5 lines

From a002d148426f40bc2b7dc066982eb177cdebeaaa Mon Sep 17 00:00:00 2001
From: Huang Shijie <[email protected]>
Date: Sun, 8 Aug 2010 14:39:07 +0200
Subject: percpu: fix a memory leak in pcpu_extend_area_map()

Quoted 8 lines

From: Huang Shijie <[email protected]>

commit a002d148426f40bc2b7dc066982eb177cdebeaaa upstream.

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

This patch, as part of the current -stable queue-2.6.35, breaks booting for me on nforce4/ AMD64 X2. Unfortunately it fails even before the serial console is initialized and the only messages shown on screen are:

Decompressing Linux... Parsing ELF... done.
Booting kernel.

[...]

mm/percpu.c static int pcpu_extend_area_map(struct p · line 398

Quoted 13 lines
mm/percpu.c +3 -1
@@ -390,7 +390,9 @@ static int pcpu_extend_area_map(struct p
               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);
 
       /*
        * map_alloc < PCPU_DFL_MAP_ALLOC indicates that the chunk is

Reverting just this patch from the current queue-2.6.35 fixes the issue for me; gzipped kernel config (amd64) attached.

Regards
       Stefan Lippers-Hollmann

#5 lore raw

Hi

Quoted 7 lines · Huang Shijie

hi :

I think this maybe caused by the kfree/vfree.
I do not have any AMD machine. Could you add some log to debug it
? such as in pcpu_extend_area_map():

        ================================

[...]

mm/percpu.c +6 -1
@@ -390,7 +390,9 @@ static int pcpu_extend_area_map(struct p
 		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);
 
 	/*
 	 * map_alloc < PCPU_DFL_MAP_ALLOC indicates that the chunk is
@@ -410,8 +412,11 @@ out_unlock:
 	 * pcpu_mem_free() might end up calling vfree() which uses
 	 * IRQ-unsafe lock and thus can't be called under pcpu_lock.
 	 */
+	printk(KERN_INFO "[ %s ] line : %d\n", __func__, __LINE__);
 	pcpu_mem_free(old, old_size);
+	printk(KERN_INFO "[ %s ] line : %d\n", __func__, __LINE__);
 	pcpu_mem_free(new, new_size);
+	printk(KERN_INFO "[ %s ] line : %d\n", __func__, __LINE__);
 
 	return 0;
 }
Quoted 2 lines
        ================================

The system will print the log before it hung.

Unfortunately those printk lines aren't reached and the systems freezes earlier.

Quoted 5 lines

Best Regards.
Huang Shijie

2010/9/17 Stefan Lippers-Hollmann <[email protected]>:

[...]

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

to the 2.6.35-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

[...]

Quoted 4 lines

From a002d148426f40bc2b7dc066982eb177cdebeaaa Mon Sep 17 00:00:00 2001
From: Huang Shijie <[email protected]>
Date: Sun, 8 Aug 2010 14:39:07 +0200
Subject: percpu: fix a memory leak in pcpu_extend_area_map()

[...]

Quoted 6 lines
Quoted 6 lines

This patch, as part of the current -stable queue-2.6.35, breaks booting for me on nforce4/ AMD64 X2. Unfortunately it fails even before the serial console is initialized and the only messages shown on screen are:

Decompressing Linux... Parsing ELF... done.
Booting kernel.

I'm still stuck on those lines, before the system freezes, but I can reproduce the same issues in Intel Q9550/ ICH10 (x86_64) and Intel Pentium M (Banias)/ ICH4-M.

All systems use current Debian/ unstable (gcc-4.4 4.4.4-14, binutils 2.20.1-14) and are booted by grub2 (grub-pc 1.98+20100804-4). Queue-2.6.35 with this patch backed out and current linux-2.6 HEAD (v2.6.36-rc4-134-g03a7ab0) are working fine on all tested systems.

Regards
Stefan Lippers-Hollmann