CJ_GLOBAL_LOG_PROTOTYPE;
-
-//#define VLIB_ELOG_MAIN_LOOP 1
-
/* Actually allocate a few extra slots of vector data to support
speculative vector enqueues which overflow vector data in next frame. */
#define VLIB_FRAME_SIZE_ALLOC (VLIB_FRAME_SIZE + 4)
}
else
{
- f = clib_mem_alloc_aligned_no_fail (n, CLIB_CACHE_LINE_BYTES);
+ f = clib_mem_alloc_aligned_no_fail (n, VLIB_FRAME_ALIGN);
f->cpu_index = vm->cpu_index;
fi = vlib_frame_index_no_check (vm, f);
}
}
VLIB_CLI_COMMAND (elog_clear_cli, static) = {
- .path = "clear event-logger",
- .short_help = "Clear current event log",
+ .path = "event-logger clear",
+ .short_help = "Clear the event log",
.function = vlib_cli_elog_clear,
};
}
VLIB_CLI_COMMAND (elog_save_cli, static) = {
- .path = "save event-logger",
- .short_help = "save event-logger <filename> (saves log in /tmp/<filename>)",
+ .path = "event-logger save",
+ .short_help = "event-logger save <filename> (saves log in /tmp/<filename>)",
.function = elog_save_buffer,
};
+static clib_error_t *
+elog_stop (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ elog_main_t * em = &vm->elog_main;
+
+ em->n_total_events_disable_limit = em->n_total_events;
+
+ vlib_cli_output (vm, "Stopped the event logger...");
+ return 0;
+}
+
+VLIB_CLI_COMMAND (elog_stop_cli, static) = {
+ .path = "event-logger stop",
+ .short_help = "Stop the event-logger",
+ .function = elog_stop,
+};
+
+static clib_error_t *
+elog_restart (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ elog_main_t * em = &vm->elog_main;
+
+ em->n_total_events_disable_limit = ~0;
+
+ vlib_cli_output (vm, "Restarted the event logger...");
+ return 0;
+}
+
+VLIB_CLI_COMMAND (elog_restart_cli, static) = {
+ .path = "event-logger restart",
+ .short_help = "Restart the event-logger",
+ .function = elog_restart,
+};
+
+static clib_error_t *
+elog_resize (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ elog_main_t * em = &vm->elog_main;
+ u32 tmp;
+
+ /* Stop the parade */
+ elog_reset_buffer (&vm->elog_main);
+
+ if (unformat (input, "%d", &tmp))
+ {
+ elog_alloc (em, tmp);
+ em->n_total_events_disable_limit = ~0;
+ }
+ else
+ return clib_error_return (0, "Must specify how many events in the ring");
+
+ vlib_cli_output (vm, "Resized ring and restarted the event logger...");
+ return 0;
+}
+
+VLIB_CLI_COMMAND (elog_resize_cli, static) = {
+ .path = "event-logger resize",
+ .short_help = "event-logger resize <nnn>",
+ .function = elog_resize,
+};
+
#endif /* CLIB_UNIX */
static void elog_show_buffer_internal (vlib_main_t * vm, u32 n_events_to_show)
* vm->clib_time.seconds_per_clock;
es = elog_peek_events (em);
- vlib_cli_output (vm, "%d events in buffer", vec_len (es));
+ vlib_cli_output (vm, "%d of %d events in buffer, logger %s", vec_len (es),
+ em->event_ring_size,
+ em->n_total_events < em->n_total_events_disable_limit ?
+ "running" : "stopped");
vec_foreach (e, es)
{
vlib_cli_output (vm, "%18.9f: %U",
elog_show_buffer_internal (vlib_get_main(), (u32)~0);
}
-always_inline void
+static inline void
vlib_elog_main_loop_event (vlib_main_t * vm,
u32 node_index,
u64 time,
u32 n_vectors,
u32 is_return)
{
- elog_main_t * em = &vm->elog_main;
+ vlib_main_t * evm = &vlib_global_main;
+ elog_main_t * em = &evm->elog_main;
- if (VLIB_ELOG_MAIN_LOOP)
- elog (em,
+ if (VLIB_ELOG_MAIN_LOOP && n_vectors)
+ elog_track (em,
/* event type */
vec_elt_at_index (is_return
- ? vm->node_return_elog_event_types
- : vm->node_call_elog_event_types,
+ ? evm->node_return_elog_event_types
+ : evm->node_call_elog_event_types,
node_index),
+ /* track */
+ (vm->cpu_index ? &vlib_worker_threads[vm->cpu_index].elog_track :
+ &em->default_track),
/* data to log */ n_vectors);
}
/* frame */ 0,
cpu_time_now);
- if (PREDICT_FALSE(vm->queue_signal_pending))
- if (vm->queue_signal_callback)
- vm->queue_signal_callback (vm);
+ if (PREDICT_TRUE (vm->queue_signal_pending == 0))
+ vm->queue_signal_callback (vm);
/* Next handle interrupts. */
{
void * data;
data = vlib_process_signal_event_helper (nm, n, p, te->event_type_index, te->n_data_elts, te->n_data_elt_bytes);
if (te->n_data_bytes < sizeof (te->inline_event_data))
- memcpy (data, te->inline_event_data, te->n_data_bytes);
+ clib_memcpy (data, te->inline_event_data, te->n_data_bytes);
else
{
- memcpy (data, te->event_data_as_vector, te->n_data_bytes);
+ clib_memcpy (data, te->event_data_as_vector, te->n_data_bytes);
vec_free (te->event_data_as_vector);
}
pool_put (nm->signal_timed_event_data_pool, te);
VLIB_EARLY_CONFIG_FUNCTION (vlib_main_configure, "vlib");
+static void dummy_queue_signal_callback (vlib_main_t * vm) { }
+
/* Main function. */
int vlib_main (vlib_main_t * vm, unformat_input_t * input)
{
clib_error_t * error;
+ vm->queue_signal_callback = dummy_queue_signal_callback;
+
clib_time_init (&vm->clib_time);
/* Turn on event log. */
vm->random_seed = clib_cpu_time_now ();
clib_random_buffer_init (&vm->random_buffer, vm->random_seed);
- /* See unix/main.c; most likely already set up */
- if (vm->init_functions_called == 0)
- vm->init_functions_called = hash_create (0, /* value bytes */ 0);
- if ((error = vlib_call_all_init_functions (vm)))
- goto done;
-
/* Initialize node graph. */
if ((error = vlib_node_main_init (vm)))
{
goto done;
}
+ /* See unix/main.c; most likely already set up */
+ if (vm->init_functions_called == 0)
+ vm->init_functions_called = hash_create (0, /* value bytes */ 0);
+ if ((error = vlib_call_all_init_functions (vm)))
+ goto done;
+
/* Create default buffer free list. */
vlib_buffer_get_or_create_free_list (vm, VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES,
"default");