telemetry: keep threads separate from data plane
authorCiara Power <ciara.power@intel.com>
Tue, 12 May 2020 15:28:58 +0000 (16:28 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 19 May 2020 13:05:56 +0000 (15:05 +0200)
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 <ciara.power@intel.com>
Acked-by: Kevin Laatz <kevin.laatz@intel.com>
lib/librte_eal/freebsd/eal.c
lib/librte_eal/linux/eal.c
lib/librte_telemetry/rte_telemetry.h
lib/librte_telemetry/telemetry.c

index f681bc7..14b5216 100644 (file)
@@ -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;
                }
index 6123bb7..9620d25 100644 (file)
@@ -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;
                }
index 1965aff..2c3c96c 100644 (file)
@@ -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
index 56a2fed..7b6f8a7 100644 (file)
@@ -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);
        }