sched: fix port time rounding
authorAlan Dewar <alan.dewar@att.com>
Thu, 25 Jun 2020 09:59:30 +0000 (10:59 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 6 Jul 2020 22:58:31 +0000 (00:58 +0200)
commit83415d4fd88c925002655aa755601998a3cdef2c
treedea071f39545493ff3788ba5fbd52d63d867ab64
parentf66967d21878ceada957d1aa02b931424f066c18
sched: fix port time rounding

The QoS scheduler works off port time that is computed from the number
of CPU cycles that have elapsed since the last time the port was
polled.   It divides the number of elapsed cycles to calculate how
many bytes can be sent, however this division can generate rounding
errors, where some fraction of a byte sent may be lost.

Lose enough of these fractional bytes and the QoS scheduler
underperforms.  The problem is worse with low bandwidths.

To compensate for this rounding error this fix doesn't advance the
port's time_cpu_cycles by the number of cycles that have elapsed,
but by multiplying the computed number of bytes that can be sent
(which has been rounded down) by number of cycles per byte.
This will mean that port's time_cpu_cycles will lag behind the CPU
cycles momentarily.  At the next poll, the lag will be taken into
account.

Fixes: de3cfa2c98 ("sched: initial import")
Cc: stable@dpdk.org
Signed-off-by: Alan Dewar <alan.dewar@att.com>
Acked-by: Jasvinder Singh <jasvinder.singh@intel.com>
lib/librte_sched/rte_sched.c