From: Ciara Power Date: Tue, 12 May 2020 15:28:58 +0000 (+0100) Subject: telemetry: keep threads separate from data plane X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=febbebf7f25558ed9261416269d3b5e6358c6262;p=dpdk.git telemetry: keep threads separate from data plane The threads for listening on the telemetry sockets are control threads and should be separated from those on the data plane. Since telemetry cannot use the rte_ctrl_thread_create() API, as it does not depend on EAL, we pass the ctrl thread cpu_set to telemetry init and use it directly to ensure that telemetry cannot interfere with the data plane threads. Signed-off-by: Ciara Power Acked-by: Kevin Laatz --- diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c index f681bc7a22..14b52168e2 100644 --- a/lib/librte_eal/freebsd/eal.c +++ b/lib/librte_eal/freebsd/eal.c @@ -958,7 +958,8 @@ rte_eal_init(int argc, char **argv) if (!internal_config.no_telemetry) { const char *error_str; if (rte_telemetry_init(rte_eal_get_runtime_dir(), - &error_str) != 0) { + &internal_config.ctrl_cpuset, &error_str) + != 0) { rte_eal_init_alert(error_str); return -1; } diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index 6123bb7c46..9620d25444 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -1296,7 +1296,8 @@ rte_eal_init(int argc, char **argv) if (!internal_config.no_telemetry) { const char *error_str; if (rte_telemetry_init(rte_eal_get_runtime_dir(), - &error_str) != 0) { + &internal_config.ctrl_cpuset, &error_str) + != 0) { rte_eal_init_alert(error_str); return -1; } diff --git a/lib/librte_telemetry/rte_telemetry.h b/lib/librte_telemetry/rte_telemetry.h index 1965affba3..2c3c96cf73 100644 --- a/lib/librte_telemetry/rte_telemetry.h +++ b/lib/librte_telemetry/rte_telemetry.h @@ -250,6 +250,7 @@ rte_telemetry_register_cmd(const char *cmd, telemetry_cb fn, const char *help); */ __rte_experimental int -rte_telemetry_init(const char *runtime_dir, const char **err_str); +rte_telemetry_init(const char *runtime_dir, rte_cpuset_t *cpuset, + const char **err_str); #endif diff --git a/lib/librte_telemetry/telemetry.c b/lib/librte_telemetry/telemetry.c index 56a2fed3f5..7b6f8a79e4 100644 --- a/lib/librte_telemetry/telemetry.c +++ b/lib/librte_telemetry/telemetry.c @@ -341,7 +341,7 @@ error: } static int -telemetry_legacy_init(const char *runtime_dir) +telemetry_legacy_init(const char *runtime_dir, rte_cpuset_t *cpuset) { pthread_t t_old; @@ -363,12 +363,13 @@ telemetry_legacy_init(const char *runtime_dir) if (v1_socket.sock < 0) return -1; pthread_create(&t_old, NULL, socket_listener, &v1_socket); + pthread_setaffinity_np(t_old, sizeof(*cpuset), cpuset); return 0; } static int -telemetry_v2_init(const char *runtime_dir) +telemetry_v2_init(const char *runtime_dir, rte_cpuset_t *cpuset) { pthread_t t_new; @@ -390,20 +391,22 @@ telemetry_v2_init(const char *runtime_dir) if (v2_socket.sock < 0) return -1; pthread_create(&t_new, NULL, socket_listener, &v2_socket); + pthread_setaffinity_np(t_new, sizeof(*cpuset), cpuset); atexit(unlink_sockets); return 0; } int32_t -rte_telemetry_init(const char *runtime_dir, const char **err_str) +rte_telemetry_init(const char *runtime_dir, rte_cpuset_t *cpuset, + const char **err_str) { - if (telemetry_v2_init(runtime_dir) != 0) { + if (telemetry_v2_init(runtime_dir, cpuset) != 0) { *err_str = telemetry_log_error; printf("Error initialising telemetry - %s\n", *err_str); return -1; } - if (telemetry_legacy_init(runtime_dir) != 0) { + if (telemetry_legacy_init(runtime_dir, cpuset) != 0) { *err_str = telemetry_log_error; printf("No telemetry legacy support - %s\n", *err_str); }