linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] fork: allocate vmapped kernel stacks for cache when a cpu is up
@ 2017-02-03 15:33 Hoeun Ryu
  0 siblings, 0 replies; only message in thread
From: Hoeun Ryu @ 2017-02-03 15:33 UTC (permalink / raw)
  To: Andrew Morton, Michal Hocko, Ingo Molnar, Andy Lutomirski,
	Kees Cook, Eric W. Biederman, Mateusz Guzik
  Cc: linux-kernel, kernel-hardening, Hoeun Ryu

when a cpu is up, predefined number of stacks are allocated and cached
immediately.

Signed-off-by: Hoeun Ryu <hoeun.ryu@gmail.com>
---
 kernel/fork.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/kernel/fork.c b/kernel/fork.c
index 50de6cf..ee4067d 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -194,6 +194,21 @@ static int alloc_vm_stack_cache(unsigned int cpu)
 	vm_stack_cache->cur = 0;
 	vm_stack_cache->nr = 0;
 
+	for (i = 0; i < NR_CACHED_STACKS; i++) {
+		void *stack = __vmalloc_node_range(THREAD_SIZE, THREAD_SIZE,
+						VMALLOC_START, VMALLOC_END,
+						THREADINFO_GFP | __GFP_HIGHMEM,
+						PAGE_KERNEL,
+						0, cpu_to_node(cpu),
+						__builtin_return_address(0));
+		if (!stack)
+			return -ENOMEM;
+
+		vm_stacks[i] = find_vm_area(stack);
+		vm_stack_cache->cur++;
+		vm_stack_cache->nr++;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-03 15:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-03 15:33 [PATCH 3/3] fork: allocate vmapped kernel stacks for cache when a cpu is up Hoeun Ryu

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).