Skip to content

Commit

Permalink
net: openvswitch: add likely in flow_lookup
Browse files Browse the repository at this point in the history
The most case *index < ma->max, and flow-mask is not NULL.
We add un/likely for performance.

Signed-off-by: Tonghao Zhang <[email protected]>
Tested-by: Greg Rose <[email protected]>
Acked-by: William Tu <[email protected]>
Acked-by: Pravin B Shelar <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
xpu22 authored and davem330 committed Nov 4, 2019
1 parent 515b65a commit 0a3e013
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/openvswitch/flow_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ static struct sw_flow *flow_lookup(struct flow_table *tbl,
struct sw_flow_mask *mask;
int i;

if (*index < ma->max) {
if (likely(*index < ma->max)) {
mask = rcu_dereference_ovsl(ma->masks[*index]);
if (mask) {
flow = masked_flow_lookup(ti, key, mask, n_mask_hit);
Expand All @@ -534,7 +534,7 @@ static struct sw_flow *flow_lookup(struct flow_table *tbl,
continue;

mask = rcu_dereference_ovsl(ma->masks[i]);
if (!mask)
if (unlikely(!mask))
break;

flow = masked_flow_lookup(ti, key, mask, n_mask_hit);
Expand Down

0 comments on commit 0a3e013

Please sign in to comment.