diff options
author | Lukas Stockner <lstockner@genesiscloud.com> | 2024-06-04 16:14:55 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@0xa5.net> | 2024-06-05 12:28:27 +0000 |
commit | 63ff7a63250c714048b8f9cf5920a8f5713c2a81 (patch) | |
tree | 8d3112a0864e833c6319f733e04b1e098cda9b43 /src | |
parent | f4972f9232b45357db6266e07993b967fc87b172 (diff) |
buffers: support per-numa-domain buffer size
Currently, buffers-per-numa is used for all NUMA domains, and there's
no way to allocate different amounts for each domain.
Therefore, this adds a per-NUMA-domain buffer config section, which
currently has a single option to set the number of buffers.
If it's not specified or set to zero, the code falls back to
buffers-per-numa as before.
Type: improvement
Change-Id: If35d7a9eff6f8d1d78063ea7873dbf50780d0ec3
Signed-off-by: Lukas Stockner <lstockner@genesiscloud.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vlib/buffer.c | 46 | ||||
-rw-r--r-- | src/vlib/buffer.h | 3 |
2 files changed, 46 insertions, 3 deletions
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c index 674f15d5dc6..5ba42270b1a 100644 --- a/src/vlib/buffer.c +++ b/src/vlib/buffer.c @@ -663,7 +663,7 @@ vlib_buffer_main_init_numa_alloc (struct vlib_main_t *vm, u32 numa_node, u8 unpriv) { vlib_buffer_main_t *bm = vm->buffer_main; - u32 buffers_per_numa = bm->buffers_per_numa; + u32 buffers_per_numa = bm->buffers_per_numa[numa_node]; clib_error_t *error; u32 buffer_size; uword n_pages, pagesize; @@ -680,6 +680,9 @@ vlib_buffer_main_init_numa_alloc (struct vlib_main_t *vm, u32 numa_node, "size (%llu)", buffer_size, pagesize); if (buffers_per_numa == 0) + buffers_per_numa = bm->default_buffers_per_numa; + + if (buffers_per_numa == 0) buffers_per_numa = unpriv ? VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA_UNPRIV : VLIB_BUFFER_DEFAULT_BUFFERS_PER_NUMA; @@ -906,18 +909,48 @@ done: } static clib_error_t * +vlib_buffers_numa_configure (vlib_buffer_main_t *bm, u32 numa_node, + unformat_input_t *input) +{ + u32 buffers = 0; + + if (numa_node >= VLIB_BUFFER_MAX_NUMA_NODES) + return clib_error_return (0, "invalid numa node"); + + if (!input) + return 0; + + unformat_skip_white_space (input); + while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + { + if (unformat (input, "buffers %u", &buffers)) + ; + else + return unformat_parse_error (input); + } + + bm->buffers_per_numa[numa_node] = buffers; + return 0; +} + +static clib_error_t * vlib_buffers_configure (vlib_main_t * vm, unformat_input_t * input) { vlib_buffer_main_t *bm; + u32 numa_node; + unformat_input_t sub_input; + clib_error_t *error = 0; vlib_buffer_main_alloc (vm); bm = vm->buffer_main; bm->log2_page_size = CLIB_MEM_PAGE_SZ_UNKNOWN; + memset (bm->buffers_per_numa, 0, sizeof (bm->buffers_per_numa)); while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { - if (unformat (input, "buffers-per-numa %u", &bm->buffers_per_numa)) + if (unformat (input, "buffers-per-numa %u", + &bm->default_buffers_per_numa)) ; else if (unformat (input, "page-size %U", unformat_log2_page_size, &bm->log2_page_size)) @@ -925,6 +958,15 @@ vlib_buffers_configure (vlib_main_t * vm, unformat_input_t * input) else if (unformat (input, "default data-size %u", &bm->default_data_size)) ; + else if (unformat (input, "numa %u %U", &numa_node, + unformat_vlib_cli_sub_input, &sub_input)) + { + error = vlib_buffers_numa_configure (bm, numa_node, &sub_input); + unformat_free (&sub_input); + + if (error) + return error; + } else return unformat_parse_error (input); } diff --git a/src/vlib/buffer.h b/src/vlib/buffer.h index 7d45689ed19..aad9701080e 100644 --- a/src/vlib/buffer.h +++ b/src/vlib/buffer.h @@ -508,7 +508,8 @@ typedef struct u8 default_buffer_pool_index_for_numa[VLIB_BUFFER_MAX_NUMA_NODES]; /* config */ - u32 buffers_per_numa; + u32 default_buffers_per_numa; + u32 buffers_per_numa[VLIB_BUFFER_MAX_NUMA_NODES]; u16 ext_hdr_size; u32 default_data_size; clib_mem_page_sz_t log2_page_size; |