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

Kevin Traynor ktraynor at redhat.com
Thu Jul 8 13:12:04 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>
---
 lib/dpif-netdev.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 338ffd971..9967c7b79 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -4967,4 +4967,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
@@ -5005,4 +5029,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