From nobody Sat Jun 1 12:31:59 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 4Vrzrs4XJjz5MpdL for ; Sat, 01 Jun 2024 12:32:13 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Vrzrs1Pmfz45st for ; Sat, 1 Jun 2024 12:32:13 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a626919d19dso531701666b.0 for ; Sat, 01 Jun 2024 05:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1717245132; x=1717849932; darn=freebsd.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=XZmleZTCSofRLnPXc5K44W5HJ9xJ4B5qCoXN+jZYAC0=; b=yGk0H2eKTc2kQ8IIpPAvu7NGtAXuKHC4gk1PjvJDeDTEmRJiDyJLx8DTTKUMAgzT9k SteJxsiM9t4eXwmjFG6F6SrU4Z1Y0CzMOZ+tpNFR7zKKCJlOIWiuZPgRclGVB7PAG6sI 8Mjyss2LZ9Uh+3iPqdUDGoVIDyv36/eBlOWG81gxel3ZLNrtO82EhRM8JcjP8s0HRmzl 62qJHV0Vhg98RcK6CVSkrxSuJqq7uhznbe+L1NyLsSwSc0rfeHIppJ02lUMJnmE3OgXI 7qURB7kDnLR9qtd071cR0H6oFPNvM6MRPxfnJqsijMOZUbOBK4ff+XWNfhCa4D+iR3+j fTKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717245132; x=1717849932; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XZmleZTCSofRLnPXc5K44W5HJ9xJ4B5qCoXN+jZYAC0=; b=PtSOMuN+UHVjLQ/Jh5c0+a2hj/GpHbf55yY+HAi6b9ZPWWfnNgZJRzVPWLjVBPKicn ZURdeF2utjJojLbbOybIahCOlRoQzrr0SUNJRT2GogOOclFXF3Yi3knQybwxGlkIlYyQ Nk7hW1bAw5vH+oLKfLo3j+1PtuqgxYAs7fTmAhunf4A6zCUXVJN2dBRT9jFXMbqSYPut J6MM3ivhaaNa41FbeLc0S//zyvFIB0p2BmON0jQCRYzxlOP9F5s6SHr+gDsJFyFy6Bgb zrUPGYmCE2IiibHwSIcSpnnuL2H3J6ENeybeouN5qrUDfEbBZhLZdyhqRXVcZSsbx5bd oYgA== X-Forwarded-Encrypted: i=1; AJvYcCXGx3WFQDkqme1f4R9KRMCTbrIYTLg2SJ1kI2U+7drKcma2XWF3g5ELHy0Snyt2CKkb8ekDp9AoclyfoIWap/sSGY5/52Fx1kaqIzHUMGLh X-Gm-Message-State: AOJu0YwfMW86nz2+WtAjKPOCcij6z5GZ14LwlvG9CT70tG2dPeAdAars wzS7jFz8t0VLohApuNRl3UacdKe8JtNVhtklGJCPlvy70p4pPmqugLUb1Snpwie1BkzCU4xbB1A H/nushOKbGs2KeOMW+BZ/kfvM7xxR4k9nvPdkCYMTa7K6cab0G4t5uQ== X-Google-Smtp-Source: AGHT+IEuH3gz9yK422gOeaIpvlfby2kvvdLCEid2wVrYiZGnSgq1eQfwdLI3GEX0iKfv+qNEWTiH+5b5dU2PUI+vh/g= X-Received: by 2002:a17:906:2c1a:b0:a59:cbcb:1cca with SMTP id a640c23a62f3a-a65f094096dmr636818166b.13.1717245131445; Sat, 01 Jun 2024 05:32:11 -0700 (PDT) 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 References: <202405311447.44VEl1G1078199@gitrepo.freebsd.org> In-Reply-To: From: Warner Losh Date: Sat, 1 Jun 2024 08:31:59 -0400 Message-ID: Subject: Re: git: 108de784513d - main - Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME To: Nuno Teixeira Cc: Warner Losh , src-committers , "" , "" Content-Type: multipart/alternative; boundary="0000000000000d72080619d34a39" X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Queue-Id: 4Vrzrs1Pmfz45st --0000000000000d72080619d34a39 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Jun 1, 2024, 4:37=E2=80=AFAM Nuno Teixeira wr= ote: > Hello, > > Having issues building graphics/mesa-dri: > > ../src/intel/common/xe/intel_gem.c:72:9: error: duplicate case value '4' > 72 | case CLOCK_BOOTTIME: > | ^ > /usr/include/sys/_clock_id.h:81:25: note: expanded from macro > 'CLOCK_BOOTTIME' > 81 | #define CLOCK_BOOTTIME CLOCK_MONOTONIC > | ^ > /usr/include/sys/_clock_id.h:56:26: note: expanded from macro > 'CLOCK_MONOTONIC' > 56 | #define CLOCK_MONOTONIC 4 > | ^ > ../src/intel/common/xe/intel_gem.c:66:9: note: previous case defined here > 66 | case CLOCK_MONOTONIC: > | ^ > /usr/include/sys/_clock_id.h:56:26: note: expanded from macro > 'CLOCK_MONOTONIC' > 56 | #define CLOCK_MONOTONIC 4 > | ^ > 1 error generated. > Mesa needs to be updated to not assume these are distinct values. Warner > Thanks > > Warner Losh escreveu (sexta, 31/05/2024 =C3=A0(s) 15:47= ): > >> The branch main has been updated by imp: >> >> URL: >> https://cgit.FreeBSD.org/src/commit/?id=3D108de784513d87bbe850e7b003a73e= 26b5b54caa >> >> 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 platfor= ms >> 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=3D1824084 >> 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 =3D CLOCK_REALTIME; >> break; >> case LINUX_CLOCK_MONOTONIC: >> - *n =3D CLOCK_MONOTONIC; >> + *n =3D CLOCK_UPTIME; >> break; >> case LINUX_CLOCK_PROCESS_CPUTIME_ID: >> *n =3D 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 =3D CLOCK_MONOTONIC_FAST; >> + *n =3D CLOCK_UPTIME_FAST; >> break; >> case LINUX_CLOCK_BOOTTIME: >> - *n =3D CLOCK_UPTIME; >> + *n =3D 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 >> >> > > -- > Nuno Teixeira > FreeBSD UNIX: Web: https://FreeBSD.org > --0000000000000d72080619d34a39 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sat, Jun 1, 2024, 4:37=E2=80=AFAM = Nuno Teixeira <= eduardo@freebsd.org> wrote:
=
Hello,

Having issues buildin= g graphics/mesa-dri:

../src/intel/common/xe/intel_= gem.c:72:9: error: duplicate case value '4'
=C2=A0 =C2=A072 | = =C2=A0 =C2=A0case CLOCK_BOOTTIME:
=C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 = =C2=A0 =C2=A0 ^
/usr/include/sys/_clock_id.h:81:25: note: expanded from = macro 'CLOCK_BOOTTIME'
=C2=A0 =C2=A081 | #define CLOCK_BOOTTIME = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0CLOCK_MONOTONIC
=C2=A0 =C2=A0 =C2=A0 |= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^
/usr/include/sys/_clock_id.h:56= :26: note: expanded from macro 'CLOCK_MONOTONIC'
=C2=A0 =C2=A056= | #define CLOCK_MONOTONIC =C2=A0 =C2=A0 =C2=A0 =C2=A0 4
=C2=A0 =C2=A0 = =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^
../src/intel/common/xe/i= ntel_gem.c:66:9: note: previous case defined here
=C2=A0 =C2=A066 | =C2= =A0 =C2=A0case CLOCK_MONOTONIC:
=C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2= =A0 =C2=A0 ^
/usr/include/sys/_clock_id.h:56:26: note: expanded from mac= ro 'CLOCK_MONOTONIC'
=C2=A0 =C2=A056 | #define CLOCK_MONOTONIC = =C2=A0 =C2=A0 =C2=A0 =C2=A0 4
=C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 ^
1 error generated.
=

Mesa needs to be updated to not assume these are distinct values.<= /div>

Warner
=C2=A0
Thanks

Warner Losh <imp@freebsd.org> escreveu= (sexta, 31/05/2024 =C3=A0(s) 15:47):
The branch main has been updated by imp:

URL: ht= tps://cgit.FreeBSD.org/src/commit/?id=3D108de784513d87bbe850e7b003a73e26b5b= 54caa

commit 108de784513d87bbe850e7b003a73e26b5b54caa
Author:=C2=A0 =C2=A0 =C2=A0Val Packett <val@packett.cool>
AuthorDate: 2024-05-31 14:45:02 +0000
Commit:=C2=A0 =C2=A0 =C2=A0Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-05-31 14:45:02 +0000

=C2=A0 =C2=A0 Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_U= PTIME

=C2=A0 =C2=A0 The suspend-awareness situation with monotonic clocks across = platforms
=C2=A0 =C2=A0 is kind of a mess, let's try not making it worse.

=C2=A0 =C2=A0 On Linux, CLOCK_MONOTONIC does NOT count suspended time, and<= br> =C2=A0 =C2=A0 CLOCK_BOOTTIME was introduced to INCLUDE suspended time.

=C2=A0 =C2=A0 On OpenBSD, CLOCK_MONOTONIC DOES count suspended time, and CL= OCK_UPTIME
=C2=A0 =C2=A0 was introduced to EXCLUDE suspended time.

=C2=A0 =C2=A0 On macOS, it's the same as OpenBSD, but with CLOCK_UPTIME= _RAW.

=C2=A0 =C2=A0 Right now, we do not have a monotonic clock that counts suspe= nded time.
=C2=A0 =C2=A0 We have CLOCK_UPTIME as a distinct ID alias, and CLOCK_BOOTTI= ME as a
=C2=A0 =C2=A0 preprocessor alias, both being effectively `CLOCK_MONOTONIC` = for now.

=C2=A0 =C2=A0 When we introduce a suspend-aware clock in the future, it wou= ld make a
=C2=A0 =C2=A0 lot more sense to do it the OpenBSD/macOS way, i.e. to make =C2=A0 =C2=A0 CLOCK_MONOTONIC include suspended time and make CLOCK_UPTIME = exclude it,
=C2=A0 =C2=A0 because that's what the name CLOCK_UPTIME implies: a devi= ation from the
=C2=A0 =C2=A0 default intended for the uptime command to allow it to only s= how the
=C2=A0 =C2=A0 time the system was actually up and not suspended.

=C2=A0 =C2=A0 Let's change the define right now to make sure software u= sing the define
=C2=A0 =C2=A0 would not end up using the ID of the wrong clock in the futur= e, and fix
=C2=A0 =C2=A0 the IDs in the Linux compat code to match the expected change= s too.

=C2=A0 =C2=A0 See https://bugzill= a.mozilla.org/show_bug.cgi?id=3D1824084
=C2=A0 =C2=A0 for more discussion.

=C2=A0 =C2=A0 Fixes:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 155f15118a77 ("= clock_gettime: Add Linux aliases for CLOCK_*")
=C2=A0 =C2=A0 Fixes:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 25ada637362d ("= Map Linux CLOCK_BOOTTIME to native CLOCK_UPTIME.")
=C2=A0 =C2=A0 Sponsored by:=C2=A0 =C2=A0https://www.pat= reon.com/valpackett
=C2=A0 =C2=A0 Reviewed by:=C2=A0 =C2=A0 kib, imp
=C2=A0 =C2=A0 Differential Revision:=C2=A0 https://revi= ews.freebsd.org/D39270
---
=C2=A0sys/compat/linux/linux_time.c | 6 +++---
=C2=A0sys/sys/_clock_id.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 2 +- =C2=A02 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c<= br> 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)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *n =3D CLOCK_REALTI= ME;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case LINUX_CLOCK_MONOTONIC:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*n =3D CLOCK_MONOTO= NIC;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*n =3D CLOCK_UPTIME= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case LINUX_CLOCK_PROCESS_CPUTIME_ID:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *n =3D CLOCK_PROCES= S_CPUTIME_ID;
@@ -300,10 +300,10 @@ linux_to_native_clockid(clockid_t *n, clockid_t l) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case LINUX_CLOCK_MONOTONIC_COARSE:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case LINUX_CLOCK_MONOTONIC_RAW:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*n =3D CLOCK_MONOTO= NIC_FAST;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*n =3D CLOCK_UPTIME= _FAST;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case LINUX_CLOCK_BOOTTIME:
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*n =3D CLOCK_UPTIME= ;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*n =3D CLOCK_MONOTO= NIC;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case LINUX_CLOCK_REALTIME_ALARM:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 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 @@
=C2=A0 * Linux compatible names.
=C2=A0 */
=C2=A0#if __BSD_VISIBLE
-#define=C2=A0 =C2=A0 =C2=A0 =C2=A0 CLOCK_BOOTTIME=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 CLOCK_UPTIME
+#define=C2=A0 =C2=A0 =C2=A0 =C2=A0 CLOCK_BOOTTIME=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 CLOCK_MONOTONIC
=C2=A0#define=C2=A0 =C2=A0 =C2=A0 =C2=A0 CLOCK_REALTIME_COARSE=C2=A0 =C2=A0= CLOCK_REALTIME_FAST
=C2=A0#define=C2=A0 =C2=A0 =C2=A0 =C2=A0 CLOCK_MONOTONIC_COARSE=C2=A0 CLOCK= _MONOTONIC_FAST
=C2=A0#endif



--
Nuno Teixeira
FreeBSD UNIX:=C2=A0 <eduardo@FreeBSD.org>=C2=A0 =C2=A0Web:=C2=A0 https://FreeBSD.org
--0000000000000d72080619d34a39--