public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: pda_init: fix memory leak with CPU_HOTPLUG
@ 2008-08-01 14:36 Andreas Herrmann
  2008-08-14  9:14 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Herrmann @ 2008-08-01 14:36 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-kernel, Borislav Petkov

pda->irqstackptr is allocated whenever a CPU is set online.
But it is never freed (or did I miss something?).
This results in a memory leak of 16 KByte for each CPU offline/online
cycle.

Fix is to allocate pda->irqstackptr only once.

Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
---
 arch/x86/kernel/cpu/common_64.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

The leak is not a big deal for normal CPU hotplug usage.
But when doing lots of CPU offline/online-cycles during stress tests
this becomes significant.

Patch is against Linus' git-tree (v2.6.27-rc1-157-gf164ca9).


Regards,

Andreas

diff --git a/arch/x86/kernel/cpu/common_64.c b/arch/x86/kernel/cpu/common_64.c
index dd6e3f1..c941397 100644
--- a/arch/x86/kernel/cpu/common_64.c
+++ b/arch/x86/kernel/cpu/common_64.c
@@ -493,17 +493,20 @@ void pda_init(int cpu)
 		/* others are initialized in smpboot.c */
 		pda->pcurrent = &init_task;
 		pda->irqstackptr = boot_cpu_stack;
+		pda->irqstackptr += IRQSTACKSIZE - 64;
 	} else {
-		pda->irqstackptr = (char *)
-			__get_free_pages(GFP_ATOMIC, IRQSTACK_ORDER);
-		if (!pda->irqstackptr)
-			panic("cannot allocate irqstack for cpu %d", cpu);
+		if (!pda->irqstackptr) {
+			pda->irqstackptr = (char *)
+				__get_free_pages(GFP_ATOMIC, IRQSTACK_ORDER);
+			if (!pda->irqstackptr)
+				panic("cannot allocate irqstack for cpu %d",
+				      cpu);
+			pda->irqstackptr += IRQSTACKSIZE - 64;
+		}
 
 		if (pda->nodenumber == 0 && cpu_to_node(cpu) != NUMA_NO_NODE)
 			pda->nodenumber = cpu_to_node(cpu);
 	}
-
-	pda->irqstackptr += IRQSTACKSIZE-64;
 }
 
 char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ +
-- 
1.5.6.3




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-14  9:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-01 14:36 [PATCH] x86: pda_init: fix memory leak with CPU_HOTPLUG Andreas Herrmann
2008-08-14  9:14 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox