git: 3886f1b488e4 - stable/14 - kern_time: Honor the precise option when counting diff

From: ShengYi Hung <aokblast_at_FreeBSD.org>
Date: Fri, 29 May 2026 15:27:05 UTC
The branch stable/14 has been updated by aokblast:

URL: https://cgit.FreeBSD.org/src/commit/?id=3886f1b488e47eba98e1523f85cb570694e97385

commit 3886f1b488e47eba98e1523f85cb570694e97385
Author:     ShengYi Hung <aokblast@FreeBSD.org>
AuthorDate: 2026-03-12 09:16:24 +0000
Commit:     ShengYi Hung <aokblast@FreeBSD.org>
CommitDate: 2026-05-29 15:25:36 +0000

    kern_time: Honor the precise option when counting diff
    
    When preecise option is used, the true elapsed time should also use the
    precise timer.
    
    This fixes the test case sleep_for.signals.pass.cpp in libcxx.
    
    Reviewed by:    kib, imp
    Approved by:    lwhsu (mentor)
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D55824
    
    (cherry picked from commit 728ae49a6b81edb3eec5ab70a63bb83db8f5dce5)
---
 sys/kern/kern_time.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 64eef90fc740..0e3062d2a394 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -564,7 +564,9 @@ kern_clock_nanosleep(struct thread *td, clockid_t clock_id, int flags,
 	} while (error == 0 && is_abs_real && td->td_rtcgen == 0);
 	td->td_rtcgen = 0;
 	if (error != EWOULDBLOCK) {
-		if (TIMESEL(&sbtt, tmp))
+		if (precise)
+			sbtt = sbinuptime();
+		else if (TIMESEL(&sbtt, tmp))
 			sbtt += tc_tick_sbt;
 		if (sbtt >= sbt)
 			return (0);