summaryrefslogtreecommitdiffstats
path: root/src/vlib/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlib/node.c')
-rw-r--r--src/vlib/node.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/vlib/node.c b/src/vlib/node.c
index 169c67b0888..00660373607 100644
--- a/src/vlib/node.c
+++ b/src/vlib/node.c
@@ -295,7 +295,6 @@ register_node (vlib_main_t * vm, vlib_node_registration_t * r)
{
vlib_node_main_t *nm = &vm->node_main;
vlib_node_t *n;
- u32 page_size = clib_mem_get_page_size ();
int i;
if (CLIB_DEBUG > 0)
@@ -409,36 +408,26 @@ register_node (vlib_main_t * vm, vlib_node_registration_t * r)
if (n->type == VLIB_NODE_TYPE_PROCESS)
{
vlib_process_t *p;
- void *map;
- uword log2_n_stack_bytes, stack_bytes;
- int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS;
+ uword log2_n_stack_bytes;
log2_n_stack_bytes = clib_max (r->process_log2_n_stack_bytes,
VLIB_PROCESS_LOG2_STACK_SIZE);
log2_n_stack_bytes = clib_max (log2_n_stack_bytes,
- min_log2 (page_size));
+ clib_mem_get_log2_page_size ());
p = clib_mem_alloc_aligned (sizeof (p[0]), CLIB_CACHE_LINE_BYTES);
clib_memset (p, 0, sizeof (p[0]));
p->log2_n_stack_bytes = log2_n_stack_bytes;
- stack_bytes = 1ULL << log2_n_stack_bytes;
- /* map stack size + 2 extra guard pages */
- map = mmap (0, stack_bytes + page_size, PROT_READ | PROT_WRITE,
- mmap_flags, -1, 0);
+ p->stack = clib_mem_vm_map_stack (1ULL << log2_n_stack_bytes,
+ CLIB_MEM_PAGE_SZ_DEFAULT,
+ "process stack: %U",
+ format_vlib_node_name, vm,
+ n->index);
- if (map == MAP_FAILED)
+ if (p->stack == CLIB_MEM_VM_MAP_FAILED)
clib_panic ("failed to allocate process stack (%d bytes)",
- stack_bytes);
-
- /* skip the guard page */
- p->stack = map + page_size;
-
- mmap_flags |= MAP_FIXED;
- map = mmap (map, page_size, PROT_NONE, mmap_flags, -1, 0);
-
- if (map == MAP_FAILED)
- clib_unix_warning ("failed to create stack guard page");
+ 1ULL << log2_n_stack_bytes);
/* Process node's runtime index is really index into process
pointer vector. */