summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-01-23 08:44:40 -0500
committerDave Barach <openvpp@barachs.net>2020-01-23 15:35:51 +0000
commitc385a95e8ed81c39d02114f975850ea52ae7dc17 (patch)
tree99b9a247805398dde18dbe8aa4ec498acd575155
parent418b225931634f6d113d2971cb9550837d69929d (diff)
api: mark api_trace_command_fn thread-safe
Binary API trace replay with multiple worker threads depends in many cases on worker thread graph replica maintenance. If we (implicitly) assert a worker thread barrier at the debug CLI level, all graph replica changes are deferred until the replay operation completes. If an interface is deleted, the wheels may fall off. Type: fix Ticket: VPP-1824 Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I9b07d43f8501caa5519e5ff9ae4c19dc2661cc84
-rwxr-xr-xsrc/vlibmemory/vlib_api_cli.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/vlibmemory/vlib_api_cli.c b/src/vlibmemory/vlib_api_cli.c
index 0d5ce96fbdf..33bea78f56b 100755
--- a/src/vlibmemory/vlib_api_cli.c
+++ b/src/vlibmemory/vlib_api_cli.c
@@ -662,6 +662,16 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
am->replay_in_progress = 0;
}
+/** api_trace_command_fn - control the binary API trace / replay feature
+
+ Note: this command MUST be marked thread-safe. Replay with
+ multiple worker threads depends in many cases on worker thread
+ graph replica maintenance. If we (implicitly) assert a worker
+ thread barrier at the debug CLI level, all graph replica changes
+ are deferred until the replay operation completes. If an interface
+ is deleted, the wheels fall off.
+ */
+
static clib_error_t *
api_trace_command_fn (vlib_main_t * vm,
unformat_input_t * input, vlib_cli_command_t * cmd)
@@ -682,12 +692,16 @@ api_trace_command_fn (vlib_main_t * vm,
{
if (unformat (input, "nitems %d", &nitems))
;
+ vlib_worker_thread_barrier_sync (vm);
vl_msg_api_trace_configure (am, which, nitems);
vl_msg_api_trace_onoff (am, which, 1 /* on */ );
+ vlib_worker_thread_barrier_release (vm);
}
else if (unformat (input, "off"))
{
+ vlib_worker_thread_barrier_sync (vm);
vl_msg_api_trace_onoff (am, which, 0);
+ vlib_worker_thread_barrier_release (vm);
}
else if (unformat (input, "save %s", &filename))
{
@@ -709,7 +723,9 @@ api_trace_command_fn (vlib_main_t * vm,
vlib_cli_output (vm, "Couldn't create %s\n", chroot_filename);
goto out;
}
+ vlib_worker_thread_barrier_sync (vm);
rv = vl_msg_api_trace_save (am, which, fp);
+ vlib_worker_thread_barrier_release (vm);
fclose (fp);
if (rv == -1)
vlib_cli_output (vm, "API Trace data not present\n");
@@ -766,8 +782,10 @@ api_trace_command_fn (vlib_main_t * vm,
}
else if (unformat (input, "free"))
{
+ vlib_worker_thread_barrier_sync (vm);
vl_msg_api_trace_onoff (am, which, 0);
vl_msg_api_trace_free (am, which);
+ vlib_worker_thread_barrier_release (vm);
}
else if (unformat (input, "post-mortem-on"))
vl_msg_api_post_mortem_dump_enable_disable (1 /* enable */ );
@@ -792,8 +810,9 @@ VLIB_CLI_COMMAND (api_trace_command, static) =
{
.path = "api trace",
.short_help = "api trace [on|off][first <n>][last <n>][status][free]"
- "[post-mortem-on][dump|custom-dump|save|replay <file>]",
+ "[post-mortem-on][dump|custom-dump|save|replay <file>]",
.function = api_trace_command_fn,
+ .is_mp_safe = 1,
};
/* *INDENT-ON* */