Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49800efc authored by Andreas Herrmann's avatar Andreas Herrmann Committed by Ingo Molnar
Browse files

x86: pda_init(): fix memory leak when using CPU hotplug



pda->irqstackptr is allocated whenever a CPU is set online.
But it is never freed. This results in a memory leak of 16K
for each CPU offline/online cycle.

Fix is to allocate pda->irqstackptr only once.

Signed-off-by: default avatarAndreas Herrmann <andreas.herrmann3@amd.com>
Cc: akpm@linux-foundation.org
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 2ae111cd
Loading
Loading
Loading
Loading
+9 −6
Original line number Original line Diff line number Diff line
@@ -493,17 +493,20 @@ void pda_init(int cpu)
		/* others are initialized in smpboot.c */
		/* others are initialized in smpboot.c */
		pda->pcurrent = &init_task;
		pda->pcurrent = &init_task;
		pda->irqstackptr = boot_cpu_stack;
		pda->irqstackptr = boot_cpu_stack;
		pda->irqstackptr += IRQSTACKSIZE - 64;
	} else {
	} else {
		if (!pda->irqstackptr) {
			pda->irqstackptr = (char *)
			pda->irqstackptr = (char *)
				__get_free_pages(GFP_ATOMIC, IRQSTACK_ORDER);
				__get_free_pages(GFP_ATOMIC, IRQSTACK_ORDER);
			if (!pda->irqstackptr)
			if (!pda->irqstackptr)
			panic("cannot allocate irqstack for cpu %d", cpu);
				panic("cannot allocate irqstack for cpu %d",
				      cpu);
			pda->irqstackptr += IRQSTACKSIZE - 64;
		}


		if (pda->nodenumber == 0 && cpu_to_node(cpu) != NUMA_NO_NODE)
		if (pda->nodenumber == 0 && cpu_to_node(cpu) != NUMA_NO_NODE)
			pda->nodenumber = cpu_to_node(cpu);
			pda->nodenumber = cpu_to_node(cpu);
	}
	}

	pda->irqstackptr += IRQSTACKSIZE-64;
}
}


char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ +
char boot_exception_stacks[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ +