mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
dpif-netdev: includes microsecond delta in meter bucket calculation
When dp-netdev meter rate is higher than 200Mbps, observe more than 10% bias from configured rate value with UDP traffic. In dp-netdev meter, millisecond delta between now and last used is taken into bucket size calcualtion, while sub-millisecond part is truncated. If traffic rate is pretty high, time delta can be few milliseconds, its ratio to truncated part is less than 10:1, the loss of bucket size caused by truncated can be observed obviously by commited traffic rate. In this patch, microsend delta part is included in calculation of meter bucket to make it more precise. Signed-off-by: Jiang Lidong <jianglidong3@jd.com> Signed-off-by: William Tu <u9012063@gmail.com>
This commit is contained in:
@@ -5735,6 +5735,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
|
||||
struct dp_packet *packet;
|
||||
long long int long_delta_t; /* msec */
|
||||
uint32_t delta_t; /* msec */
|
||||
uint32_t delta_in_us; /* usec */
|
||||
const size_t cnt = dp_packet_batch_size(packets_);
|
||||
uint32_t bytes, volume;
|
||||
int exceeded_band[NETDEV_MAX_BURST];
|
||||
@@ -5765,6 +5766,9 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
|
||||
Assuming that all racing threads received packets at the same time
|
||||
to avoid overflow. */
|
||||
long_delta_t = 0;
|
||||
delta_in_us = 0;
|
||||
} else {
|
||||
delta_in_us = (now - meter->used) % 1000;
|
||||
}
|
||||
|
||||
/* Make sure delta_t will not be too large, so that bucket will not
|
||||
@@ -5800,6 +5804,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
|
||||
|
||||
/* Update band's bucket. */
|
||||
band->bucket += delta_t * band->up.rate;
|
||||
band->bucket += delta_in_us * band->up.rate / 1000;
|
||||
if (band->bucket > band->up.burst_size) {
|
||||
band->bucket = band->up.burst_size;
|
||||
}
|
||||
|
Reference in New Issue
Block a user