[PATCH v3] Define in_int32_t_range to check if the 64 bit time_t syscall should be used
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Tue Nov 8 13:49:40 GMT 2022
On 08/11/22 10:27, Arnd Bergmann wrote:
> On Tue, Nov 8, 2022, at 13:51, Adhemerval Zanella Netto wrote:
>> On 08/11/22 09:28, Arnd Bergmann wrote:
>>
>> Sigh, I have added the use of 64 bit syscall if required for some
>> sysmbols because I assumed that 32 bit time_t syscall would be always
>> available. This is small optimization to avoid issuing a lot of
>> 64 bit syscall, specially for syscall like futex.
>>
>> But if kernel does indeed assume that COMPAT_32BIT_TIME is a supported
>> configuration I think we will need to roll out the optimization and
>> always issue the 64 bit time_t syscalls anyway. From a glibc point of
>> view it should not matter much besides some small overhead for newer
>> glibc running on older kernels (we might add a global to disable the
>> 64-bit call if kernel does not support, as we do for some specific
>> syscalls).
>
> It's possible that I have misread what glibc does at the moment,
> as I see there are checks for __ASSUME_TIME64_SYSCALLS in the
> same code path.
>
> To clarify: I think an important configuration is one where
> an embedded system assumes both kernel and userspace are
> always modern and only support time64. This means
> CONFIG_COMPAT_32BIT_TIME is disabled in the kernel, and glibc
> is built to only support a modern enough kernel to assume
> time64 support is always available. I have not tested whether
> this works at the moment, but it probably does not require
> a large rework if there is something still missing. Sorry
> for having hijacked this thread if this is already supported.
>
> If glibc is configured to support older linux-3.2 and includes
> the time32 fallbacks for that, it's not unreasonable to require
> CONFIG_COMPAT_32BIT_TIME=y for those. It would be
> good to document this dependency, or even have an early
> runtime check similar to the "kernel too old" error that
> glibc produces when there is a version mismatch.
Yes, the 32 bit fallback assumes that you either use the default minimum
kernel or configure with --enable-kernel with a value lower than 5.1.
And the optimization such as ecf2661281c was added on the basis that for
such configuration the 32 time_t is always present.
For __ASSUME_TIME64_SYSCALLS (default fro 64 bit time_t ABI and for 32
bit time_t with --enable-kernel=5.1) the 32 bit syscall should not be
issued.
There are still the issue for a default configured glibc when running
on kernels with CONFIG_COMPAT_32BIT_TIME=y, this would require to remove
the fallback optimizations for !__ASSUME_TIME64_SYSCALLS.
More information about the Libc-alpha
mailing list