Bug 252816 - x11-servers/xorg-server: patch to utilize CLOCK_MONOTONIC_FAST for the clock
Summary: x11-servers/xorg-server: patch to utilize CLOCK_MONOTONIC_FAST for the clock
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-x11 (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-18 22:48 UTC by Sean Farley
Modified: 2021-07-01 18:37 UTC (History)
5 users (show)

See Also:
jkim: maintainer-feedback+


Attachments
Patch to x11-servers/xorg-server (1.52 KB, patch)
2021-01-18 22:48 UTC, Sean Farley
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sean Farley freebsd_committer freebsd_triage 2021-01-18 22:48:37 UTC
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.
Comment 1 Warner Losh freebsd_committer freebsd_triage 2021-06-28 17:27:27 UTC
(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.
Comment 2 Warner Losh freebsd_committer freebsd_triage 2021-06-28 17:37:24 UTC
https://cgit.freebsd.org/ports/commit/?id=29e347e19709b94e2a25b8f749afaa22b4613213 is the commit that removed it.
Comment 3 Jung-uk Kim freebsd_committer freebsd_triage 2021-06-28 17:49:07 UTC
LGTM
Comment 4 Mitchell Horne freebsd_committer freebsd_triage 2021-06-28 18:27:38 UTC
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.
Comment 5 Warner Losh freebsd_committer freebsd_triage 2021-06-28 19:51:52 UTC
(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.
Comment 6 Mark Johnston freebsd_committer freebsd_triage 2021-06-28 19:56:28 UTC
(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
Comment 7 Jung-uk Kim freebsd_committer freebsd_triage 2021-06-28 20:02:37 UTC
(In reply to Mark Johnston from comment #6)
Yes, we should do this because the bug is fixed now.
Comment 8 Mitchell Horne freebsd_committer freebsd_triage 2021-06-28 20:03:48 UTC
(In reply to Mark Johnston from comment #6)

Ahh very nice, I missed this. Sorry for the noise everyone!
Comment 9 Warner Losh freebsd_committer freebsd_triage 2021-07-01 18:24:34 UTC
(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.
Comment 10 commit-hook freebsd_committer freebsd_triage 2021-07-01 18:35:07 UTC
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(-)