Skip to content

Commit

Permalink
dpif-netdev: Calculate rxq cycles prior to compare_rxq_cycles calls.
Browse files Browse the repository at this point in the history
compare_rxq_cycles sums the latest cycles from each queue for
comparison with each other. While each comparison correctly
gets the latest cycles, the cycles could change between calls
to compare_rxq_cycle. In order to use consistent values through
each call of compare_rxq_cycles, sum the cycles before qsort is
called.

Requested-by: Ilya Maximets <[email protected]>
Signed-off-by: Kevin Traynor <[email protected]>
Signed-off-by: Ian Stokes <[email protected]>
  • Loading branch information
kevintraynor authored and istokes committed Dec 8, 2017
1 parent cc131ac commit 8368866
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3449,22 +3449,16 @@ compare_rxq_cycles(const void *a, const void *b)
{
struct dp_netdev_rxq *qa;
struct dp_netdev_rxq *qb;
uint64_t total_qa, total_qb;
unsigned i;
uint64_t cycles_qa, cycles_qb;

qa = *(struct dp_netdev_rxq **) a;
qb = *(struct dp_netdev_rxq **) b;

total_qa = total_qb = 0;
for (i = 0; i < PMD_RXQ_INTERVAL_MAX; i++) {
total_qa += dp_netdev_rxq_get_intrvl_cycles(qa, i);
total_qb += dp_netdev_rxq_get_intrvl_cycles(qb, i);
}
dp_netdev_rxq_set_cycles(qa, RXQ_CYCLES_PROC_HIST, total_qa);
dp_netdev_rxq_set_cycles(qb, RXQ_CYCLES_PROC_HIST, total_qb);
cycles_qa = dp_netdev_rxq_get_cycles(qa, RXQ_CYCLES_PROC_HIST);
cycles_qb = dp_netdev_rxq_get_cycles(qb, RXQ_CYCLES_PROC_HIST);

if (total_qa != total_qb) {
return (total_qa < total_qb) ? 1 : -1;
if (cycles_qa != cycles_qb) {
return (cycles_qa < cycles_qb) ? 1 : -1;
} else {
/* Cycles are the same so tiebreak on port/queue id.
* Tiebreaking (as opposed to return 0) ensures consistent
Expand Down Expand Up @@ -3520,11 +3514,19 @@ rxq_scheduling(struct dp_netdev *dp, bool pinned) OVS_REQUIRES(dp->port_mutex)
dp_netdev_pmd_unref(pmd);
}
} else if (!pinned && q->core_id == OVS_CORE_UNSPEC) {
uint64_t cycle_hist = 0;

if (n_rxqs == 0) {
rxqs = xmalloc(sizeof *rxqs);
} else {
rxqs = xrealloc(rxqs, sizeof *rxqs * (n_rxqs + 1));
}
/* Sum the queue intervals and store the cycle history. */
for (unsigned i = 0; i < PMD_RXQ_INTERVAL_MAX; i++) {
cycle_hist += dp_netdev_rxq_get_intrvl_cycles(q, i);
}
dp_netdev_rxq_set_cycles(q, RXQ_CYCLES_PROC_HIST, cycle_hist);

/* Store the queue. */
rxqs[n_rxqs++] = q;
}
Expand Down

0 comments on commit 8368866

Please sign in to comment.