Skip to content

Commit

Permalink
dpif-netdev: Split function to find lowest loaded PMD thread core.
Browse files Browse the repository at this point in the history
This splits up the looping through each PMD thread core on a numa node
with the check to compare cycles or rxqs.

This is done so in future the compare could be reused with any group
of PMD thread cores.

There is no user visible change in behaviour.

Signed-off-by: Kevin Traynor <[email protected]>
Acked-by: David Marchand <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
kevintraynor authored and igsilya committed May 30, 2022
1 parent 04e5adf commit 37ccbd9
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
@@ -5744,28 +5744,43 @@ compare_rxq_cycles(const void *a, const void *b)
}
}

static bool
sched_pmd_new_lowest(struct sched_pmd *current_lowest, struct sched_pmd *pmd,
bool has_proc)
{
uint64_t current_num, pmd_num;

if (current_lowest == NULL) {
return true;
}

if (has_proc) {
current_num = current_lowest->pmd_proc_cycles;
pmd_num = pmd->pmd_proc_cycles;
} else {
current_num = current_lowest->n_rxq;
pmd_num = pmd->n_rxq;
}

if (pmd_num < current_num) {
return true;
}
return false;
}

static struct sched_pmd *
sched_pmd_get_lowest(struct sched_numa *numa, bool has_cyc)
{
struct sched_pmd *lowest_sched_pmd = NULL;
uint64_t lowest_num = UINT64_MAX;

for (unsigned i = 0; i < numa->n_pmds; i++) {
struct sched_pmd *sched_pmd;
uint64_t pmd_num;

sched_pmd = &numa->pmds[i];
if (sched_pmd->isolated) {
continue;
}
if (has_cyc) {
pmd_num = sched_pmd->pmd_proc_cycles;
} else {
pmd_num = sched_pmd->n_rxq;
}

if (pmd_num < lowest_num) {
lowest_num = pmd_num;
if (sched_pmd_new_lowest(lowest_sched_pmd, sched_pmd, has_cyc)) {
lowest_sched_pmd = sched_pmd;
}
}

0 comments on commit 37ccbd9

Please sign in to comment.