Created attachment 221720 [details] Patch to x11-servers/xorg-server This patches the X server to use CLOCK_MONOTONIC_FAST instead of CLOCK_MONOTONIC for the clock. This is basically a reintroduction of r208485 by jkim@ that was removed by accident(?). Since the X server is fine with the Linux _COARSE clock the accuracy of the FreeBSD _FAST clock should work too. I have run with this patch for a long time without ill effects.
(In reply to Sean Farley from comment #0) Do you happen to know when this was dropped? It would also help us to not drop it again if you could submit it upstream.
https://cgit.freebsd.org/ports/commit/?id=29e347e19709b94e2a25b8f749afaa22b4613213 is the commit that removed it.
LGTM
Might be worth noting that modern libc has a VDSO implementation of clock_gettime(3), under which CLOCK_MONOTONIC and the _FAST variant behave identically (see the switch statement in lib/libc/sys/__vdso_gettimeofday.c). It seems likely that for any system interested in running X11, this patch will be a no-op. This may include the system you tested on, unless you made specific provisions against this. This is merely a passing observation; I'm not nay-saying the patch.
(In reply to Mitchell Horne from comment #4) Well, the two cases that are the same are CLOCK_MONOTONIC and CLOCK_MONOTONIC_PRECISE which call binuptime(). The CLOCK_MONOTONIC_FAST is different. It calls getnanouptime(). The latter just looks at the cached time, the former gets the TC from the kernel, reads the time hardware and does math. So I still thinks there's a difference between the two.
(In reply to Mitchell Horne from comment #4) This is not true as of five days ago :) https://cgit.freebsd.org/src/commit/?id=60b0ad10dd0fc7ff6892ecc7ba3458482fcc064c
(In reply to Mark Johnston from comment #6) Yes, we should do this because the bug is fixed now.
(In reply to Mark Johnston from comment #6) Ahh very nice, I missed this. Sorry for the noise everyone!
(In reply to Mitchell Horne from comment #8) Yea, we should fix this by adding _COARSE to base as an alias, but I'll do that seperately.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=227228845cd678bfb6cc8e9183e259f88e55567b commit 227228845cd678bfb6cc8e9183e259f88e55567b Author: Sean Farley <scf@FreeBSD.org> AuthorDate: 2021-07-01 18:22:00 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2021-07-01 18:30:11 +0000 x11-servers/xorg-server: patch to utilize CLOCK_MONOTONIC_FAST for the clock This patches the X server to use CLOCK_MONOTONIC_FAST instead of CLOCK_MONOTONIC for the clock. This is basically a reintroduction of r208485 by jkim@ that was removed by accident(?). Since the X server is fine with the Linux _COARSE clock the accuracy of the FreeBSD _FAST clock should work too. I have run with this patch for a long time without ill effects. PR: 252816 Reviewed by: imp, markj, jkim, mhorne Approved by: x11 x11-servers/xorg-server/Makefile | 2 +- x11-servers/xorg-server/files/patch-os-utils.c (new) | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-)