[PATCH v5 v5 2/3] app: add topology aware test case

Varghese, Vipin Vipin.Varghese at amd.com
Thu Apr 16 15:19:36 CEST 2026


[Public]

<snipped>
>
> Unable to find `Sudheendra Sampath` in dpdk mailing list and Slack. Can you please
> connect with me email address or slack.

Hi Sudheendra,

Thank you for the suggestion and welcome to dpdk review too.

My initial code design were

```
#ifdef RTE_LIBHWLOC_PROBE
+static int
+get_same_domains(struct lcore_pair *lcp, uint32_t domain_sel)
+{
+       if (rte_topo_get_domain_count(domain_sel) == 0)
+               return 1;
+
+       unsigned int id1 = RTE_MAX_LCORE, id2 = RTE_MAX_LCORE;
+       unsigned int domain = 0;
+
+       RTE_TOPO_FOREACH_DOMAIN(domain, domain_sel) {
+               if ((id1 != RTE_MAX_LCORE) && (id2 != RTE_MAX_LCORE))
+                       break;
+
+               if (rte_topo_get_lcore_count_from_domain(domain_sel, domain) < 2)
+                       continue;
+
+               id1 = rte_topo_get_nth_lcore_from_domain(domain, 0, 0, domain_sel);
+               id2 = rte_topo_get_nth_lcore_from_domain(domain, 1, 0, domain_sel);
+       }
+
+       if ((id1 == RTE_MAX_LCORE) || (id2 == RTE_MAX_LCORE))
+               return 2;
+
+       if (id1 == id2)
+               return 3;
+
+       lcp->c1 = id1;
+       lcp->c2 = id2;
+
+       return 0;
+}
+
+static int
+get_two_domains(struct lcore_pair *lcp, uint32_t domain_sel)
+{
+       if (rte_topo_get_domain_count(domain_sel) < 2)
+               return 1;
+
+       unsigned int id1 = RTE_MAX_LCORE, id2 = RTE_MAX_LCORE;
+       unsigned int domain = 0;
+
+       RTE_TOPO_FOREACH_DOMAIN(domain, domain_sel) {
+               if ((id1 != RTE_MAX_LCORE) && (id2 != RTE_MAX_LCORE))
+                       break;
+
+               if (rte_topo_get_lcore_count_from_domain(domain_sel, domain) == 0)
+                       continue;
+
+               if (id1 == RTE_MAX_LCORE) {
+                       id1 = rte_topo_get_nth_lcore_from_domain(domain,
+                               0, 0, domain_sel);
+                       continue;
+               }
+               if (id2 == RTE_MAX_LCORE) {
+                       id2 = rte_topo_get_nth_lcore_from_domain(domain,
+                               0, 0, domain_sel);
+                       continue;
+               }
+       }
+
+       if ((id1 == RTE_MAX_LCORE) || (id2 == RTE_MAX_LCORE))
+               return 2;
+
+       if (id1 == id2)
+               return 3;
+
+       lcp->c1 = id1;
+       lcp->c2 = id2;
+
+       return 0;
+}
+#endif
+
 /* Get cycle counts for dequeuing from an empty ring. Should be 2 or 3 cycles */
 static void
 test_empty_dequeue(struct rte_ring *r, const int esize,
@@ -488,6 +574,33 @@ test_ring_perf_esize_run_on_two_cores(
                if (run_on_core_pair(&cores, param1, param2) < 0)
                        return -1;
        }
+#ifdef RTE_LIBHWLOC_PROBE
+       if (rte_lcore_count() > 2) {
+               for (uint32_t d = 0; d < RTE_DIM(domain_types); d++) {
+                       if (get_same_domains(&cores, domain_types[d]) == 0) {
+                               printf("\n### Testing using same %s domain nodes ###\n",
+                                       (domain_types[d] == RTE_TOPO_DOMAIN_NUMA) ? "NUMA" :
+                                       (domain_types[d] == RTE_TOPO_DOMAIN_L4) ? "L4" :
+                                       (domain_types[d] == RTE_TOPO_DOMAIN_L3) ? "L3" :
+                                       (domain_types[d] == RTE_TOPO_DOMAIN_L2) ? "L2" :
+                                       (domain_types[d] == RTE_TOPO_DOMAIN_L1) ? "L1" : NULL);
+                               if (run_on_core_pair(&cores, param1, param2) < 0)
+                                       return -1;
+                       }
+
+                       if (get_two_domains(&cores, domain_types[d]) == 0) {
+                               printf("\n### Testing using two %s domain nodes ###\n",
+                                       (domain_types[d] == RTE_TOPO_DOMAIN_NUMA) ? "NUMA" :
+                                       (domain_types[d] == RTE_TOPO_DOMAIN_L4) ? "L4" :
+                                       (domain_types[d] == RTE_TOPO_DOMAIN_L3) ? "L3" :
+                                       (domain_types[d] == RTE_TOPO_DOMAIN_L2) ? "L2" :
+                                       (domain_types[d] == RTE_TOPO_DOMAIN_L1) ? "L1" : NULL);
+                               if (run_on_core_pair(&cores, param1, param2) < 0)
+                                       return -1;
+                       }
+               }
+       }
+#endif
        return 0;
 }

```

Since it breaks the current function test format, I went ahead with current approach.
I will re-introduce the domain iterator design in v6 for you. Please try it out and let me know.

Regards
Vipin Varghese


More information about the dev mailing list