Summary: | Two imprecisions in cputime counters | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | firk | ||||||
Component: | kern | Assignee: | freebsd-bugs (Nobody) <bugs> | ||||||
Status: | Closed FIXED | ||||||||
Severity: | Affects Only Me | CC: | arrowd, davidxu, eugen, phk | ||||||
Priority: | --- | ||||||||
Version: | 13.0-RELEASE | ||||||||
Hardware: | Any | ||||||||
OS: | Any | ||||||||
Attachments: |
|
Description
firk
2022-02-26 23:11:31 UTC
Adding phk and davidxu to the CC list as they worked on the code in question and could have some opinion on the topic. In terms of efficiency, I suspect the if() hurts more than the extra divides, so maybe just get rid of the if() and always take the "expensive" path ? (In reply to Poul-Henning Kamp from comment #2) May be, and the code will look cleaner. Created attachment 232178 [details]
updated patch
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=bb53dd56c30c6360fc82be762ed98b0af6b9f69f commit bb53dd56c30c6360fc82be762ed98b0af6b9f69f Author: firk <firk@cantconnect.ru> AuthorDate: 2022-03-21 13:33:11 +0000 Commit: George V. Neville-Neil <gnn@FreeBSD.org> CommitDate: 2022-03-21 13:33:46 +0000 kern_tc.c/cputick2usec() (which is used to calculate cputime from cpu ticks) has some imprecision and, worse, huge timestep (about 20 minutes on 4GHz CPU) near 53.4 days of elapsed time. kern_time.c/cputick2timespec() (it is used for clock_gettime() for querying process or thread consumed cpu time) Uses cputick2usec() and then needlessly converting usec to nsec, obviously losing precision even with fixed cputick2usec(). kern_time.c/kern_clock_getres() uses some weird (anyway wrong) formula for getting cputick resolution. PR: 262215 Reviewed by: gnn Differential Revision: https://reviews.freebsd.org/D34558 lib/libkvm/kvm_proc.c | 9 ++------- sys/kern/kern_tc.c | 12 +++--------- sys/kern/kern_time.c | 12 +++++------- 3 files changed, 10 insertions(+), 23 deletions(-) |