Skip to content

Commit

Permalink
dpif-netdev: Fix insertion probability
Browse files Browse the repository at this point in the history
emc_conditional_insert uses pmd->last_cycles and the packet's RSS hash
to generate a random number used to determine whether or not an emc
entry should be inserted. This works for single-packet bursts as
last_cycles is updated for each burst. However, for bursts > 1 packet,
where the packets in the batch generate the same RSS hash,
pmd->last_cycles remains constant for the entire burst also, and thus
cannot be used as a random number for each packet in the burst.

This commit replaces the use of pmd->last_cycles with random_uint32()
for this purpose and subsequently fixes the behavior of the
emc_insert_inv_prob setting for high-throughput (large bursts)
single-flow cases.

Fixes: 4c30b24 ("dpif-netdev: Conditional EMC insert")
Reported-by: Kevin Traynor <[email protected]>
Acked-by: Kevin Traynor <[email protected]>
Acked-by: Darrell Ball <[email protected]>
Tested-by: Kevin Traynor <[email protected]>
Signed-off-by: Ciara Loftus <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
cloftus authored and blp committed Jul 11, 2017
1 parent 8a0d9d8 commit 656238e
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2074,11 +2074,7 @@ emc_probabilistic_insert(struct dp_netdev_pmd_thread *pmd,
uint32_t min;
atomic_read_relaxed(&pmd->dp->emc_insert_min, &min);

#ifdef DPDK_NETDEV
if (min && (key->hash ^ (uint32_t) pmd->last_cycles) <= min) {
#else
if (min && (key->hash ^ random_uint32()) <= min) {
#endif
if (min && random_uint32() <= min) {
emc_insert(&pmd->flow_cache, key, flow);
}
}
Expand Down

0 comments on commit 656238e

Please sign in to comment.