add stat segment size configuration

Change-Id: I395ff9c91d670a9f9e50dc1b030e0412b7234de5
Signed-off-by: Dave Barach <dave@barachs.net>
This commit is contained in:
Dave Barach
2018-07-05 11:48:20 -04:00
parent 0fa56788f7
commit 01a771b121
2 changed files with 29 additions and 1 deletions

View File

@ -198,8 +198,13 @@ vlib_map_stat_segment_init (void)
void *oldheap;
u32 *lock;
int rv;
u64 memory_size;
ssvmp->ssvm_size = 32 << 20; /*$$$$$ CONFIG PARAM */
memory_size = sm->memory_size;
if (memory_size == 0)
memory_size = STAT_SEGMENT_DEFAULT_SIZE;
ssvmp->ssvm_size = memory_size;
ssvmp->i_am_master = 1;
ssvmp->my_pid = getpid ();
ssvmp->name = format (0, "/stats%c", 0);
@ -508,6 +513,25 @@ do_stat_segment_updates (stats_main_t * sm)
update_serialized_nodes (sm);
}
static clib_error_t *
statseg_config (vlib_main_t * vm, unformat_input_t * input)
{
stats_main_t *sm = &stats_main;
uword ms;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "size %U", unformat_memory_size, &sm->memory_size))
;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
}
return 0;
}
VLIB_EARLY_CONFIG_FUNCTION (statseg_config, "statseg");
/*
* fd.io coding-style-patch-verification: ON

View File

@ -167,6 +167,7 @@ typedef struct
clib_spinlock_t *stat_segment_lockp;
clib_socket_t *socket;
u8 *socket_name;
uword memory_size;
/* Pointers to scalar stats maintained by the stat thread */
f64 *input_rate_ptr;
@ -195,6 +196,9 @@ typedef struct
extern stats_main_t stats_main;
/* Default stat segment 32m */
#define STAT_SEGMENT_DEFAULT_SIZE (32<<20)
#define STAT_SEGMENT_OPAQUE_LOCK 0
#define STAT_SEGMENT_OPAQUE_DIR 1
#define STAT_SEGMENT_OPAQUE_EPOCH 2