Expose per-lcore cpuset information to telemetry.

Signed-off-by: Anatoly Burakov <anatoly.bura...@intel.com>
---
 .../common/eal_common_lcore_telemetry.c       | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_lcore_telemetry.c 
b/lib/librte_eal/common/eal_common_lcore_telemetry.c
index 5e4ea15ff5..39fffe2b93 100644
--- a/lib/librte_eal/common/eal_common_lcore_telemetry.c
+++ b/lib/librte_eal/common/eal_common_lcore_telemetry.c
@@ -19,6 +19,8 @@ int __rte_lcore_telemetry_enabled;
 
 #ifdef RTE_LCORE_BUSYNESS
 
+#include "eal_private.h"
+
 struct lcore_telemetry {
        int busyness;
        /**< Calculated busyness (gets set/returned by the API) */
@@ -235,6 +237,48 @@ lcore_handle_busyness(const char *cmd __rte_unused,
        return 0;
 }
 
+static int
+lcore_handle_cpuset(const char *cmd __rte_unused,
+                   const char *params __rte_unused,
+                   struct rte_tel_data *d)
+{
+       char corenum[64];
+       int i;
+
+       rte_tel_data_start_dict(d);
+
+       RTE_LCORE_FOREACH(i) {
+               const struct lcore_config *cfg = &lcore_config[i];
+               const rte_cpuset_t *cpuset = &cfg->cpuset;
+               struct rte_tel_data *ld;
+               unsigned int cpu;
+
+               if (!rte_lcore_is_enabled(i))
+                       continue;
+
+               /* create an array of integers */
+               ld = rte_tel_data_alloc();
+               if (ld == NULL)
+                       return -ENOMEM;
+               rte_tel_data_start_array(ld, RTE_TEL_INT_VAL);
+
+               /* add cpu ID's from cpuset to the array */
+               for (cpu = 0; cpu < CPU_SETSIZE; cpu++) {
+                       if (!CPU_ISSET(cpu, cpuset))
+                               continue;
+                       rte_tel_data_add_array_int(ld, cpu);
+               }
+
+               /* add array to the per-lcore container */
+               snprintf(corenum, sizeof(corenum), "%d", i);
+
+               /* tell telemetry library to free this array automatically */
+               rte_tel_data_add_dict_container(d, corenum, ld, 0);
+       }
+
+       return 0;
+}
+
 RTE_INIT(lcore_init_telemetry)
 {
        __rte_lcore_telemetry_enabled = true;
@@ -249,6 +293,9 @@ RTE_INIT(lcore_init_telemetry)
 
        rte_telemetry_register_cmd("/eal/lcore/busyness_disable", 
lcore_busyness_disable,
                                   "disable lcore busyness measurement");
+
+       rte_telemetry_register_cmd("/eal/lcore/cpuset", lcore_handle_cpuset,
+                                  "list physical core affinity for each 
lcore");
 }
 
 #else
-- 
2.25.1

Reply via email to