[ovs-dev] [PATCH v6 3/7] dpif-netdev: Sort PMD list by core id for rxq scheduling.

Kevin Traynor ktraynor at redhat.com
Fri Jul 16 14:22:23 UTC 2021


The list of PMDs is round robined through for the selection
when assigning an rxq to a PMD. The list is based on a
hash map, so there is no defined order.

It means the same set of PMDs may get assigned different rxqs
on different runs for no reason other than how the PMDs are stored
in the hash map.

This can be easily changed by sorting the PMDs by core id after
they are extracted, so the PMDs will be used in a consistent order.

Signed-off-by: Kevin Traynor <ktraynor at redhat.com>
Acked-by: Sunil Pai G <sunil.pai.g at intel.com>
Acked-by: David Marchand <david.marchand at redhat.com>
---
 lib/dpif-netdev.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 9d2b10781..aa8e42503 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -4819,4 +4819,28 @@ sched_numa_list_lookup(struct sched_numa_list *numa_list, int numa_id)
 }
 
+static int
+compare_sched_pmd_list(const void *a_, const void *b_)
+{
+    struct sched_pmd *a, *b;
+
+    a = (struct sched_pmd *) a_;
+    b = (struct sched_pmd *) b_;
+
+    return compare_poll_thread_list(&a->pmd, &b->pmd);
+}
+
+static void
+sort_numa_list_pmds(struct sched_numa_list *numa_list)
+{
+    struct sched_numa *numa;
+
+    HMAP_FOR_EACH (numa, node, &numa_list->numas) {
+        if (numa->n_pmds > 1) {
+            qsort(numa->pmds, numa->n_pmds, sizeof *numa->pmds,
+                  compare_sched_pmd_list);
+        }
+    }
+}
+
 /* Populate numas and pmds on those numas. */
 static void
@@ -4857,4 +4881,5 @@ sched_numa_list_populate(struct sched_numa_list *numa_list,
         numa->rr_idx_inc = true;
     }
+    sort_numa_list_pmds(numa_list);
 }
 
-- 
2.31.1



More information about the dev mailing list