[PATCH v3] mach: Use the host_get_time64 to replace the deprecated host_get_time for CLOCK_REALTIME when it's available

2025-03-23 Thread Zhaoming Luo
Check the availability of host_get_time64 and use it to replace host_get_time for CLOCK_REALTIME when it's available. Fall back to host_get_time if gnumach does not support host_get_time64 but the gnumach headers do. host_get_time is deprecated See https://git.savannah.gnu.org/cgit/hurd/gnumach.g

[PATCH mach v4 0/1] Integrate HPET so the functions used for getting time can have a higher accuracy

2025-03-23 Thread Zhaoming Luo
Compared with RFC v3: - Use #ifdef APIC in hpclock_read_counter() to avoid the runtime check of the availability of HPET. - Remove the redundant check in hpclock_get_counter_period_nsec(). - Fix a small bug in time_value64_add_hpc(). - Some comment improvements Zhaoming Luo (1): Integrate HPET

[PATCH mach v4 1/1] Integrate HPET so the functions used for getting time can have a higher accuracy

2025-03-23 Thread Zhaoming Luo
Integrate HPET so host_get_time, host_get_time64, and host_get_uptime64 are more precise. The highest precision can be 10ns when this patch is applied. * i386/i386/apic.c: Implement the two high-precision clock interface functions added in this patch for i386. * i386/i386at/model_dep.c: Initiali

Re: [PATCH v2 1/1] mach: Use the host_get_time64 to replace the deprecated host_get_time for CLOCK_REALTIME when it's available

2025-03-23 Thread Samuel Thibault
Zhaoming Luo, le dim. 23 mars 2025 10:47:14 +0800, a ecrit: > Check the availability of host_get_time64 and use it to replace > host_get_time for CLOCK_REALTIME when it's available. > case CLOCK_REALTIME: >{ > - /* __host_get_time can only fail if passed an invalid host_t. > +

Re: [RFC PATCH v3] Integrate HPET so the functions used for getting time can have a higher accuracy

2025-03-23 Thread Samuel Thibault
Damien Zammit via Bug reports for the GNU Hurd, le dim. 23 mars 2025 10:20:37 +, a ecrit: > You probably want to disable it entirely so it doesn't need to execute a > branch condition every time it reads the timer, ie with #ifdef. The if is precisely meant for the case where hpet is not avai

Re: [RFC PATCH v3] Integrate HPET so the functions used for getting time can have a higher accuracy

2025-03-23 Thread Samuel Thibault
Hello, Almost there! Samuel Zhaoming Luo, le dim. 23 mars 2025 18:13:55 +0800, a ecrit: > +uint32_t > +hpclock_get_counter_period_nsec(void) > +{ > +if (hpet_addr != NULL) > + return hpet_period_nsec; > +else > + return 0; When hpet_addr is NULL, hpet_period_nsec will already be

Re: [RFC PATCH gnumach] kern: Integrate HPET so the functions used for getting time can have a higher accuracy

2025-03-23 Thread Samuel Thibault
Damien Zammit via Bug reports for the GNU Hurd, le dim. 23 mars 2025 08:22:23 +, a ecrit: > I think we are assuming any machine with ACPI has HPET. This is true since > ~2005. Yes, but we currently still support the non-APIC case too. Samuel

Re: [RFC PATCH v3] Integrate HPET so the functions used for getting time can have a higher accuracy

2025-03-23 Thread Zhaoming Luo
On Sun, Mar 23, 2025 at 10:20:37AM +, Damien Zammit wrote: > You probably want to disable it entirely so it doesn't need to execute a > branch condition every time it reads the timer, ie with #ifdef. > This code path would be critical for timing. Fair enough :/. Thanks :). Zhaoming > > > --

Re: [RFC PATCH v3] Integrate HPET so the functions used for getting time can have a higher accuracy

2025-03-23 Thread Damien Zammit via Bug reports for the GNU Hurd
You probably want to disable it entirely so it doesn't need to execute a branch condition every time it reads the timer, ie with #ifdef. This code path would be critical for timing. Damien Sent from Proton Mail Android Original Message On 23/3/25 9:13 pm, Zhaoming Luo wrote:

[RFC PATCH v3] Integrate HPET so the functions used for getting time can have a higher accuracy

2025-03-23 Thread Zhaoming Luo
Hi, I'm wondering the code for checking whether a high-precision code is available should be in mach_clock.c or in the machine-dependent directory. In this patch it's in the machine-dependent directory. It can ensure the backward compactability. Otherwise compiling a gnumach with only '../configur

Re: [RFC PATCH gnumach] kern: Integrate HPET so the functions used for getting time can have a higher accuracy

2025-03-23 Thread Zhaoming Luo
On Sun, Mar 23, 2025 at 09:03:01AM +0100, Samuel Thibault wrote: > Zhaoming Luo, le dim. 23 mars 2025 13:29:47 +0800, a ecrit: > > On Sun, Mar 23, 2025 at 12:48:52AM +0100, Samuel Thibault wrote: > > > Zhaoming Luo, le sam. 22 mars 2025 15:24:50 +0800, a ecrit: > > > > > > > diff --git a/i386/i386

Re: [RFC PATCH gnumach] kern: Integrate HPET so the functions used for getting time can have a higher accuracy

2025-03-23 Thread Damien Zammit via Bug reports for the GNU Hurd
I think we are assuming any machine with ACPI has HPET. This is true since ~2005. Damien Sent from Proton Mail Android Original Message On 23/3/25 7:03 pm, Samuel Thibault wrote: > Zhaoming Luo, le dim. 23 mars 2025 13:29:47 +0800, a ecrit: > > On Sun, Mar 23, 2025 at 12:

Re: [RFC PATCH gnumach] kern: Integrate HPET so the functions used for getting time can have a higher accuracy

2025-03-23 Thread Samuel Thibault
Zhaoming Luo, le dim. 23 mars 2025 13:29:47 +0800, a ecrit: > On Sun, Mar 23, 2025 at 12:48:52AM +0100, Samuel Thibault wrote: > > Zhaoming Luo, le sam. 22 mars 2025 15:24:50 +0800, a ecrit: > > > > > diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c > > > index 30449c37..aa8451ac 100