Skip to content

: Time cleanups

Patrick McHardy netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5: Use tc_calc_xmittime where appropriatetc/q_cbq.c tc/tc_core.c tc/tc_red.c+3 -35 replies
2/5: Introduce tc_calc_xmitsize and use where appropriatetc/m_police.c tc/q_htb.c tc/q_tbf.c +2 more+11 -52 replies
3/5: Introduce TIME_UNITS_PER_SEC to represent internal clock resolutiontc/q_hfsc.c tc/q_tbf.c tc/tc_cbq.c +4 more+36 -220 replies
4/5: Replace "usec" by "time" in function namestc/m_estimator.c tc/q_cbq.c tc/q_hfsc.c +7 more+37 -372 replies
5/5: Add sprint_ticks() function and use in CBQtc/q_cbq.c tc/q_netem.c tc/tc_util.c +1 more+10 -90 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [IPROUTE 00/05]: Time cleanups

These patches clean up the tc time handling a bit, with the goal of making it easier to audit for integer overflows when increasing the internal clock resolution, which is necessary for all token bucket based schedulers to take advantage of a higher kernel clock resolution (ktime) because the kernel only does lookups and additions/subtractions, which can never result in values that have a higher precision that those passed from userspace.

The way I imagine it we have to keep (at least on of) the old clock sources around for userspace compatibility since they can't deal with the higher precision values. iproute is changed to use nsec internally and reads the kernel clock resulution from /proc/net/psched (third value, currently assumed to always be 10^6) to convert it's internal resolution to that of the kernel. With ktime as clocksource the kernel will report a resulution of 10^9. The downside is that distributors can't enable ktime unless they want to break compatibility with old iproute versions, but I can't see a way around this.

 tc/m_estimator.c  |    4 ++--
 tc/m_police.c     |    2 +-
 tc/q_cbq.c        |   15 ++++++++-------
 tc/q_hfsc.c       |   18 +++++++++---------
 tc/q_htb.c        |    4 ++--
 tc/q_netem.c      |   12 +++---------
 tc/q_tbf.c        |   20 ++++++++++----------
 tc/tc_cbq.c       |    8 ++++----
 tc/tc_core.c      |   35 +++++++++++++++++++++++++----------
 tc/tc_core.h      |   11 ++++++++---
 tc/tc_estimator.c |    2 +-
 tc/tc_red.c       |    2 +-
 tc/tc_util.c      |   33 +++++++++++++++++++--------------
 tc/tc_util.h      |    7 ++++---
 14 files changed, 97 insertions(+), 76 deletions(-)

Patrick McHardy:
[IPROUTE]: Use tc_calc_xmittime where appropriate
[IPROUTE]: Introduce tc_calc_xmitsize and use where appropriate [IPROUTE]: Introduce TIME_UNITS_PER_SEC to represent internal clock resolution [IPROUTE]: Replace "usec" by "time" in function names
[IPROUTE]: Add sprint_ticks() function and use in CBQ