diff options
author | Damjan Marion <damarion@cisco.com> | 2020-05-20 22:01:44 +0200 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2020-05-20 22:01:44 +0200 |
commit | ef58758286e84d227377c447c7cf8fae82bdca94 (patch) | |
tree | 2bf2dd5acd8b2c733487f5749b95faa859bb225f /src/vlib/node.h | |
parent | ca86c95a3413214110a03b001d45d018385b92dc (diff) |
vlib: mmap process stacks
Instead of allocating stack from the main heap, this patch mmaps stack
memory together with guard page.
This aproach reduces main heap usage, and stack memory is prefaulted
on demand, so bigger process stacks will have zero impact on memory
usage as long as stack memory is not needed for real.
In addition, it fixes issue with systems which have bigger default page
size (observed with 65536).
Type: improvement
Change-Id: I593365c603d4702e428967d80fd425fdee2c4a21
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/node.h')
-rw-r--r-- | src/vlib/node.h | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/src/vlib/node.h b/src/vlib/node.h index b9961f55b56..1bdb3bb7797 100644 --- a/src/vlib/node.h +++ b/src/vlib/node.h @@ -552,6 +552,7 @@ typedef struct typedef struct { + CLIB_CACHE_LINE_ALIGN_MARK (cacheline0); /* Node runtime for this process. */ vlib_node_runtime_t node_runtime; @@ -613,32 +614,10 @@ typedef struct vlib_cli_output_function_t *output_function; uword output_function_arg; -#ifdef CLIB_UNIX - /* Pad to a multiple of the page size so we can mprotect process stacks */ -#define PAGE_SIZE_MULTIPLE 0x1000 -#define ALIGN_ON_MULTIPLE_PAGE_BOUNDARY_FOR_MPROTECT __attribute__ ((aligned (PAGE_SIZE_MULTIPLE))) -#else -#define ALIGN_ON_MULTIPLE_PAGE_BOUNDARY_FOR_MPROTECT -#endif - - /* Process stack. Starts here and extends 2^log2_n_stack_bytes - bytes. */ - + /* Process stack */ #define VLIB_PROCESS_STACK_MAGIC (0xdead7ead) - u32 stack[0] ALIGN_ON_MULTIPLE_PAGE_BOUNDARY_FOR_MPROTECT; -} vlib_process_t __attribute__ ((aligned (CLIB_CACHE_LINE_BYTES))); - -#ifdef CLIB_UNIX - /* Ensure that the stack is aligned on the multiple of the page size */ -typedef char - assert_process_stack_must_be_aligned_exactly_to_page_size_multiple[(sizeof - (vlib_process_t) - - - PAGE_SIZE_MULTIPLE) - == - 0 ? 0 : - -1]; -#endif + u32 *stack; +} vlib_process_t; typedef struct { |