Skip to contentSkip to conversation

fork: allocate vmapped kernel stacks for cache when a cpu is up

PATCH In review Hoeun Ryu 1 participant 1 message Feb 3, 2017

Subsystems (3)
lore
Share & tools
lore

Hoeun Ryu

author
#0 lore raw

PATCH 3/3 fork: allocate vmapped kernel stacks for cache when a cpu is up

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

---
 kernel/fork.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
kernel/fork.c +15 -0
index 50de6cf..ee4067d 100644
@@ -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;
 }
 
Signature · 1 line
2.7.4