Skip to content

Commit

Permalink
dpif-netdev: fix meter at high packet rate.
Browse files Browse the repository at this point in the history
When testing packet rate around 1Mpps with meter enabled, the frequency
of hitting meter action becomes much higher, around 30us each time.
As a result, the meter's calculation of 'uint32_t delta_t' becomes
always 0 and meter action has no effect.  This is due to the previous
commit 05f9e70 divides the delta by 1000, in order to convert to
msec granularity.  The patch fixes it updating the time when across
millisecond boundary.

Fixes: 05f9e70 ("dpif-netdev: Use microsecond granularity.")
Acked-by: Yi-Hung Wei <[email protected]>
Acked-by: Ilya Maximets <[email protected]>
Signed-off-by: William Tu <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
williamtu authored and blp committed Apr 22, 2019
1 parent abf85df commit 42697ca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -5549,7 +5549,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
memset(exceeded_rate, 0, cnt * sizeof *exceeded_rate);

/* All packets will hit the meter at the same time. */
long_delta_t = (now - meter->used) / 1000; /* msec */
long_delta_t = now / 1000 - meter->used / 1000; /* msec */

/* Make sure delta_t will not be too large, so that bucket will not
* wrap around below. */
Expand Down

0 comments on commit 42697ca

Please sign in to comment.