From nobody Fri May 31 14:47:01 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VrQts6SG6z5N1n0; Fri, 31 May 2024 14:47:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VrQts4P93z51LP; Fri, 31 May 2024 14:47:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717166821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LEmfm8t3XMca5amt1LehVfsqrlh0yD+57vDZnzp2CiA=; b=GWrvGUWvAfW8L8LgRH4qr9gcUh8wXlFK/7UHsvrwUTCZ97+etLn1a19Himx5nDVyuDdDR0 XuU4bKHO1e9vmk3ZJ9e8ADq5L4J/UDTbviZVVtO37R3K6I9CY0Sq21AkxokYXwhz+KivfE p/NPC6BHlpvQLV/wAVDxYe1iraqxbQfNu1cWxLXU53SI9y551adxei5FmHIPT6BZ9JGMs6 aT7sesqsBUJ4g6JeO7GIFNvq6qLevOlasReVTmkMu6KBol4BoV5ARpM3i6J/aAtBJ49Xol DRQCmdxl3qAGl7inUVNFReua8mqgWa4RXKt1na5pP7aW0TvT48OsI+akUNLJBQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717166821; a=rsa-sha256; cv=none; b=pkWo+wE6TEKRerN23B9orVu9yO2hS6y421HGCIJ11MAW/5Eq+P2YmG9HMKANxaBe3WF4Gs BPzQlAN7XCNDvqsB/ZNNFhBEghkymDyWoZ7MXLNHPZ6FhcI4WkC3/qILjKqqiNjXjA8DUO APovk7cA9ua0fNbK6IB8R1cLJYMiU4RSSm498K5K3k5gL/jzhFen4wEmwVYziyStmRLjs9 Tevd7vG4mt+iqI5LSOApRPPN4oG4AFswqjwWhraToImYQ423MPDmRJUIUEiN2h6kWghAah KhAq5PzMbzwnBAVXWHfgTxJygk/+ep/23OoGFOwXkU+NHYgVb710YldnoauJuQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717166821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LEmfm8t3XMca5amt1LehVfsqrlh0yD+57vDZnzp2CiA=; b=PqXM2KqVMFwT3OC5Ym0zI3vc8JdyS9R7XcquENUrtPXslOzACZ88VKIW8fIs715RnMX4Yp nEO+v+Y2qsJnDCapsiZWT2B4BGlAO9xJikx+PEtnJxqU8PDXv/s/kT6YU2Van54lomJhPu NREwsNwnnDc/EBzu1Mi7GRGbUpiKWfBD7mVWy/xeZAWb4uoxw6UY/8/z76cKOPGagdtf8e uP74KdfnVA/CGRnDZQB+hLh01CxEhOGT39xQZy4UFC3t8tG1OPjbZJvWg4iPAmfQqU0XTN KjTP7sUM1ZGD3dbhCykNkcFAu/6i7NO08ZbP6Yy5DQA2Km7ZxRUQ555O12+Vtw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VrQts400dzSZx; Fri, 31 May 2024 14:47:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44VEl18E078202; Fri, 31 May 2024 14:47:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44VEl1G1078199; Fri, 31 May 2024 14:47:01 GMT (envelope-from git) Date: Fri, 31 May 2024 14:47:01 GMT Message-Id: <202405311447.44VEl1G1078199@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 108de784513d - main - Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 108de784513d87bbe850e7b003a73e26b5b54caa Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=108de784513d87bbe850e7b003a73e26b5b54caa commit 108de784513d87bbe850e7b003a73e26b5b54caa Author: Val Packett AuthorDate: 2024-05-31 14:45:02 +0000 Commit: Warner Losh CommitDate: 2024-05-31 14:45:02 +0000 Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME The suspend-awareness situation with monotonic clocks across platforms is kind of a mess, let's try not making it worse. On Linux, CLOCK_MONOTONIC does NOT count suspended time, and CLOCK_BOOTTIME was introduced to INCLUDE suspended time. On OpenBSD, CLOCK_MONOTONIC DOES count suspended time, and CLOCK_UPTIME was introduced to EXCLUDE suspended time. On macOS, it's the same as OpenBSD, but with CLOCK_UPTIME_RAW. Right now, we do not have a monotonic clock that counts suspended time. We have CLOCK_UPTIME as a distinct ID alias, and CLOCK_BOOTTIME as a preprocessor alias, both being effectively `CLOCK_MONOTONIC` for now. When we introduce a suspend-aware clock in the future, it would make a lot more sense to do it the OpenBSD/macOS way, i.e. to make CLOCK_MONOTONIC include suspended time and make CLOCK_UPTIME exclude it, because that's what the name CLOCK_UPTIME implies: a deviation from the default intended for the uptime command to allow it to only show the time the system was actually up and not suspended. Let's change the define right now to make sure software using the define would not end up using the ID of the wrong clock in the future, and fix the IDs in the Linux compat code to match the expected changes too. See https://bugzilla.mozilla.org/show_bug.cgi?id=1824084 for more discussion. Fixes: 155f15118a77 ("clock_gettime: Add Linux aliases for CLOCK_*") Fixes: 25ada637362d ("Map Linux CLOCK_BOOTTIME to native CLOCK_UPTIME.") Sponsored by: https://www.patreon.com/valpackett Reviewed by: kib, imp Differential Revision: https://reviews.freebsd.org/D39270 --- sys/compat/linux/linux_time.c | 6 +++--- sys/sys/_clock_id.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c index e9e5cf075210..f4dd26dd3d2a 100644 --- a/sys/compat/linux/linux_time.c +++ b/sys/compat/linux/linux_time.c @@ -287,7 +287,7 @@ linux_to_native_clockid(clockid_t *n, clockid_t l) *n = CLOCK_REALTIME; break; case LINUX_CLOCK_MONOTONIC: - *n = CLOCK_MONOTONIC; + *n = CLOCK_UPTIME; break; case LINUX_CLOCK_PROCESS_CPUTIME_ID: *n = CLOCK_PROCESS_CPUTIME_ID; @@ -300,10 +300,10 @@ linux_to_native_clockid(clockid_t *n, clockid_t l) break; case LINUX_CLOCK_MONOTONIC_COARSE: case LINUX_CLOCK_MONOTONIC_RAW: - *n = CLOCK_MONOTONIC_FAST; + *n = CLOCK_UPTIME_FAST; break; case LINUX_CLOCK_BOOTTIME: - *n = CLOCK_UPTIME; + *n = CLOCK_MONOTONIC; break; case LINUX_CLOCK_REALTIME_ALARM: case LINUX_CLOCK_BOOTTIME_ALARM: diff --git a/sys/sys/_clock_id.h b/sys/sys/_clock_id.h index 47a551428dc3..728346a0f0ab 100644 --- a/sys/sys/_clock_id.h +++ b/sys/sys/_clock_id.h @@ -78,7 +78,7 @@ * Linux compatible names. */ #if __BSD_VISIBLE -#define CLOCK_BOOTTIME CLOCK_UPTIME +#define CLOCK_BOOTTIME CLOCK_MONOTONIC #define CLOCK_REALTIME_COARSE CLOCK_REALTIME_FAST #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST #endif