switching ARC to 64-bit time_t (Re: [RFC v6 07/23] RISC-V: Use 64-bit time_t and off_t for RV32 and RV64)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alistair, Arnd

On 2/14/20 2:39 PM, Alistair Francis wrote:
> On Tue, Feb 11, 2020 at 5:30 PM Joseph Myers <joseph@xxxxxxxxxxxxxxxx> wrote:
>> On Tue, 11 Feb 2020, Alistair Francis wrote:
>>
>>>>> diff --git a/sysdeps/unix/sysv/linux/riscv/bits/typesizes.h b/sysdeps/unix/sysv/linux/riscv/bits/typesizes.h
>>>>> new file mode 100644
>>>>> index 0000000000..0da3bdeb5d
>>>>> --- /dev/null
>>>>> +++ b/sysdeps/unix/sysv/linux/riscv/bits/typesizes.h
>>>> I was hoping newer arches could simply use the asm-generic one ?
>>> We need to specify that RV32 uses a 64-bit time_t. The generic ones
>>> don't do that for 32-bit arches.
>> Since it seems we'd like future 32-bit ports of glibc to use 64-bit time
>> and offsets, we should make that as easy as possible.
>>
>> That is, you need an RISC-V-specific bits/timesize.h.  But you shouldn't
>> need an RISC-V-specific bits/typesizes.h - rather, make the linux/generic
>> one do the right thing for __TIME_T_TYPE based on bits/timesize.h.  And
>> have some other header that 32-bit linux/generic ports can use to say
>> whether they use the 64-bit offset/stat/statfs interface, that
>> bits/typesizes.h can use together with its existing __LP64__ check, and
>> make the definitions of __OFF_T_TYPE etc. check that as well, and then you
>> shouldn't need an RISC-V-specific bits/typesizes.h - the RISC-V-specific
>> headers should be strictly minimal.  (No architecture-specific
>> bits/time64.h headers should be needed in any case.)
> Ok, I have updated this. I'll send the patch once my "Always use
> 32-bit time_t for certain syscalls" series is in (the headers are
> changed in that series).

I guess you haven't pushed changes yet, which don't make full copy of typesizes.h ?

Anyhow I have a version based on your prior next branch where I switched ARC to
64-bit time_t - things work fine in general but I see some additional failures
with the testsuite.

Consider io/test-stat2.c which calls stat() and stat64() and compares the results:
it now fails for ctime mismatch

| ...
| st_atime: [72] 644245094405576070 vs [72] 644245094405576070  OK
| st_mtime: [88] 1975684956160000000 vs [88] 1975684956160000000  OK
| st_ctime: [104] 0 vs [104] 2306351876938924035  FAIL


In kernel asm-generic stat64 has 32-bit ctime (secs)

    struct stat64 {
    ...
        int                   st_atime;            <-- offset 72
        unsigned int    st_atime_nsec;
        int                   st_mtime;            <-- offset *80*
        unsigned int    st_mtime_nsec;
        int                   st_ctime;            <-- offset 92
        unsigned int    st_ctime_nsec;
    ...
    };

In glibc, we have 64-bit time_t based timestamps so the structure diverges with
kernel counterpart from time fields onwards.

    __extension__ typedef __int64_t __time_t;        <-- ARC switched to 64-bit time_t

    struct timespec
    {
      __time_t tv_sec;    <-- 8
      long int tv_nsec;    <-- 4
      int: 32;                   <-- 4
    };

    struct stat64
      {
    ...
        struct timespec st_atim;    <-- offset 72
        struct timespec st_mtim;    <-- offset *88*
        struct timespec st_ctim;    <-- offset 104
        int __glibc_reserved[2];
      };

However glibc stat64()wrapper calls
sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c

which for ARC is just doing a pass thru syscall because we do have __NR_fstatat64
- hence the issues I see.

It needs itemized copy

    __xstat64 (int vers, const char *name, struct stat64 *buf)
    {
    #ifdef __NR_fstatat64
          return INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf, 0);
    #else
    ....
          int rc = INLINE_SYSCALL (statx, 5, AT_FDCWD, name, AT_NO_AUTOMOUNT,
                               STATX_BASIC_STATS, &tmp);
        __cp_stat64_statx (buf, &tmp);
    #endif

An the reason this all works on RISCV is that your kernel doesn't define
__ARCH_WANT_STAT64 -> lacks __NR_statat64 and instead uses the statx call which
does itemized copy and would work fine when copying from 32-bits time (in kernel)
to 64-bits container in glibc. Is this is right understanding or am I missing
something here.

How do I build a latest RISCV 32-bit kernel + userland - do you have a buildroot
branch somewhere that I can build / test with qemu ?

Thx,
-Vineet



_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/linux-snps-arc




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux