From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa2b.google.com (mail-vk1-xa2b.google.com [IPv6:2607:f8b0:4864:20::a2b]) by sourceware.org (Postfix) with ESMTPS id C50033858410 for ; Thu, 25 Nov 2021 12:53:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C50033858410 Received: by mail-vk1-xa2b.google.com with SMTP id f7so3800908vkf.10 for ; Thu, 25 Nov 2021 04:53:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=QFT9XgYsi85BXGj3R0SC4nwyBPmB4Xs2EwJHuojUkpQ=; b=Hfysjc6W5rcFZ7v4i2Cgn8TDjtfUMzpI0RqPUItYiMmrzCS9zOlAg0KbGLJ/QX/KTw NyhHpP9Of7TMvv5FsEKsdxslTBySW+CuHRKFDWOgABVfO1/7YRGLGAgYrLncl4ju/pon KdnBVd8hVjnSzerHUd7l2lzPkK2J/qps73lSHuz3fBaAYhvXhTYgKIcbGNr/m2YLLW9s Hyr8VKRig7d9+oYXwbur741jpNi/xzDqjenZ0MJm3m5NfiHiS6b0EagzYyFqjfqCcrq9 +vxw7TKruUhR0KhxjmLE6M6OnohEBly5yAdqkeDxQLziGe5z8p5HOUJgvFDdbySXHm3T xPlg== X-Gm-Message-State: AOAM532Wr+L270dfVpCS7WU+W8L70vOnu+QoXCHU1AvJPWIw/RunV+F9 hgId1o91NPckq9fGmLiQnmnbnC/ajwtvIw== X-Google-Smtp-Source: ABdhPJzYU77333j78wpEhvzLzVXCgIyEpFmAKBzGuSzhvdEdM8skSnGgN/yt565uxNJqlplfaJDiPg== X-Received: by 2002:a05:6122:da1:: with SMTP id bc33mr10702460vkb.19.1637844801245; Thu, 25 Nov 2021 04:53:21 -0800 (PST) Received: from ?IPV6:2804:431:c7cb:e054:2b7b:edb0:2264:6dae? ([2804:431:c7cb:e054:2b7b:edb0:2264:6dae]) by smtp.gmail.com with ESMTPSA id c2sm1779635uab.11.2021.11.25.04.53.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Nov 2021 04:53:20 -0800 (PST) Message-ID: <7d151797-11b2-1b3f-9f31-f8c150165d17@linaro.org> Date: Thu, 25 Nov 2021 09:53:17 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH] linux: Define STAT64_IS_KERNEL_STAT64 by default Content-Language: en-US To: Stafford Horne Cc: GLIBC patches References: <20211120210901.3991578-1-shorne@gmail.com> <7bea3e23-bbde-e5c8-137d-1fc105c1a7b7@linaro.org> From: Adhemerval Zanella In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-14.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Nov 2021 12:53:23 -0000 On 24/11/2021 18:29, Stafford Horne wrote: > On Wed, Nov 24, 2021 at 12:50:40PM -0300, Adhemerval Zanella wrote: >> >> >> On 23/11/2021 18:39, Stafford Horne wrote: >>> On Mon, Nov 22, 2021 at 10:00:31AM -0300, Adhemerval Zanella wrote: >>>> >>>> >>>> On 20/11/2021 18:09, Stafford Horne via Libc-alpha wrote: >>>>> In commit 36260d5035 ("linux: Set default kernel_stat.h to LFS") th= e >>>>> default for STAT64_IS_KERNEL_STAT64 was removed. This patch adds i= t >>>>> back. >>>>> >>>>> For architectures that want to used the default kernel_stat.h and d= o not >>>>> have __NR_newfstatat, STAT64_IS_KERNEL_STAT64 needs to be defined. = Set >>>>> the default as 1 as modern port's stat64 struct should match the ke= rnel >>>>> stat64 layout. >>>>> >>>>> I tested this on the OpenRISC port and it seems to work fine. Curr= ently, >>>>> all archs that use the default kernel_stat.h define __NR_newfstatat= so >>>>> they will not use the STAT64_IS_KERNEL_STAT64 macro. However, arc = seems >>>>> to be an outlier it uses the default kernel_stat.h, but does not de= fine >>>>> __NR_newfstatat or __NR_fstatat64 I am not clear how arc works here= =2E >>>> >>>> arc and usually newer 32-bit ports will only use __NR_statx: >>>> >>>> 138 #if (__WORDSIZE =3D=3D 32 \ >>>> 139 && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE =3D=3D= 32)) \ >>>> 140 || defined STAT_HAS_TIME32 >>>> 141 # define FSTATAT_USE_STATX 1 >>>> 142 #else >>>> 143 # define FSTATAT_USE_STATX 0 >>>> 144 #endif >>>> >>>> The patch looks ok, but it seems strange that ork1 requires it since= it >>>> setting minimum required kernel to 5.10. I would expect that __ASSUM= E_STATX >>>> would be defined and only fstatat64_time64_statx would be used. >>> >>> Right, >>> >>> In that case maybe another ifdef is needed in fstatat64.c? I don't s= ee >>> fstatat64_time64_stat is actually getting compiled into the libc.so b= inary. But >>> if I don't define STAT64_IS_KERNEL_STAT64 I get the below compile err= or. >>> >>> I added a pragma to output the value of FSTATAT_USE_STATX and __ASSUM= E_STATX in >>> the compile unit and I get the below which looks right: >>> >>> * __ASSUME_STATX: 1 >>> * FSTATAT_USE_STATX: 1 >>> >>> Error: >>> >>> or1k-glibc-linux-gnu-gcc ../sysdeps/unix/sysv/linux/fstatat64.c -c -s= td=3Dgnu11 -fgnu89-inline -g -O2 -Wall -Wwrite-strings -Wundef -Werror -= fmerge-all-constants -frounding-math -fno-stack-protector -fno-common -Ws= trict-prototypes -Wold-style-definition -fmath-errno -ftls-model=3Di= nitial-exec -I../include -I/home/shorne/work/gnu-toolchain/build-man= y/build/glibcs/or1k-linux-gnu-soft/glibc/io -I/home/shorne/work/gnu-tool= chain/build-many/build/glibcs/or1k-linux-gnu-soft/glibc -I../sysdeps/uni= x/sysv/linux/or1k -I../sysdeps/or1k/nptl -I../sysdeps/unix/sysv/linux/g= eneric/wordsize-32 -I../sysdeps/unix/sysv/linux/generic -I../sysdeps/un= ix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I= =2E./sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysd= eps/unix/sysv -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/or1k/n= ofpu -I../sysdeps/ieee754/soft-fp -I../sysdeps/or1k -I../sysdeps/words= ize-32 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sy= sdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -D_LIBC_REENTRA= NT -include /home/shorne/work/gnu-toolchain/build-many/build/glibcs/or1k-= linux-gnu-soft/glibc/libc-modules.h -DMODULE_NAME=3Dlibc -include ../incl= ude/libc-symbols.h -DTOP_NAMESPACE=3Dglibc -o /home/shorne/work/gnu= -toolchain/build-many/build/glibcs/or1k-linux-gnu-soft/glibc/io/fstatat64= =2Eo -MD -MP -MF /home/shorne/work/gnu-toolchain/build-many/build/glibcs/= or1k-linux-gnu-soft/glibc/io/fstatat64.o.dt -MT /home/shorne/work/gnu-too= lchain/build-many/build/glibcs/or1k-linux-gnu-soft/glibc/io/fstatat64.o >>> ../sysdeps/unix/sysv/linux/fstatat64.c: In function =E2=80=98fstatat6= 4_time64_stat=E2=80=99: >>> ../sysdeps/unix/sysv/linux/fstatat64.c:89:7: error: "STAT64_IS_KERNEL= _STAT64" is not defined, evaluates to 0 [-Werror=3Dundef] >>> 89 | # if STAT64_IS_KERNEL_STAT64 >>> | ^~~~~~~~~~~~~~~~~~~~~~~ >>> ../sysdeps/unix/sysv/linux/fstatat64.c:94:24: error: storage size of = =E2=80=98kst64=E2=80=99 isn=E2=80=99t known >>> 94 | struct kernel_stat64 kst64; >>> | ^~~~~ >>> ../sysdeps/unix/sysv/linux/fstatat64.c:97:5: error: implicit declarat= ion of function =E2=80=98__cp_stat64_kstat64=E2=80=99 [-Werror=3Dimplicit= -function-declaration] >>> 97 | __cp_stat64_kstat64 (buf, &kst64); >>> | ^~~~~~~~~~~~~~~~~~~ >>> ../sysdeps/unix/sysv/linux/fstatat64.c:94:24: error: unused variable = =E2=80=98kst64=E2=80=99 [-Werror=3Dunused-variable] >>> 94 | struct kernel_stat64 kst64; >>> | ^~~~~ >>> ../sysdeps/unix/sysv/linux/fstatat64.c: At top level: >>> ../sysdeps/unix/sysv/linux/fstatat64.c:149:9: note: =E2=80=98#pragma = message: The value of FSTATAT_USE_STATX: 1=E2=80=99 >>> 149 | #pragma message "The value of FSTATAT_USE_STATX: " XSTR(FSTAT= AT_USE_STATX) >>> | ^~~~~~~ >>> ../sysdeps/unix/sysv/linux/fstatat64.c:150:9: note: =E2=80=98#pragma = message: The value of __ASSUME_STATX: 1=E2=80=99 >>> 150 | #pragma message "The value of __ASSUME_STATX: " XSTR(__ASSUME= _STATX) >>> | ^~~~~~~ >>> >>> Again I am not sure how arc avoids this error I shall try to compile = it too. >> >> The problem is 'fstatat64_time64_stat' should not be build for 32-bit = architectures >> with __ASSUME_STATX (since only statx provides 64-bit timestamps). Ot= her architecture >> might get an improved codegen using older syscalls (specially 64-bit o= nes), so statx >> should be used only when really required. >> >> The patch below fixes it: >=20 > Right, this was what I was thinking too. However, I am still not sure = why or1k > needs it and arc does not. I tested the arc build and confirmed with t= he same > version of GCC the arc build passes but or1k fails with the above error= =2E So as > you said, maybe there is better codegen somewhere. ARC has: sysdeps/unix/sysv/linux/arc/fixup-asm-unistd.h:24:#undef __NR_fstatat64 Which leads fstatat64_time64_stat to be an empty function: static inline int fstatat64_time64_stat (int fd, const char *file, struct stat64 *buf, int flag) {=20 int r; # 135 "../sysdeps/unix/sysv/linux/fstatat64.c" return r; }=20 >=20 >> diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/l= inux/fstatat64.c >> index f968e4ef05..50ae5ad748 100644 >> --- a/sysdeps/unix/sysv/linux/fstatat64.c >> +++ b/sysdeps/unix/sysv/linux/fstatat64.c >> @@ -74,6 +74,17 @@ fstatat64_time64_statx (int fd, const char *file, s= truct __stat64_t64 *buf, >> return r; >> } >> =20 >> +#if (__WORDSIZE =3D=3D 32 \ >> + && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE =3D=3D 32)= ) \ >> + || defined STAT_HAS_TIME32 >> +# define FSTATAT_USE_STATX 1 >> +#else >> +# define FSTATAT_USE_STATX 0 >> +#endif >> + >> +/* Only statx supports 64-bit timestamps for 32-bit architectures wit= h >> + __ASSUME_STATX, so there is no point in building the fallback. */= >> +#if !FSTATAT_USE_STATX || (FSTATAT_USE_STATX && !defined __ASSUME_STA= TX) >> static inline int >> fstatat64_time64_stat (int fd, const char *file, struct __stat64_t64 = *buf, >> int flag) >> @@ -134,13 +145,6 @@ fstatat64_time64_stat (int fd, const char *file, = struct __stat64_t64 *buf, >> =20 >> return r; >> } >> - >> -#if (__WORDSIZE =3D=3D 32 \ >> - && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE =3D=3D 32)= ) \ >> - || defined STAT_HAS_TIME32 >> -# define FSTATAT_USE_STATX 1 >> -#else >> -# define FSTATAT_USE_STATX 0 >> #endif >> >> int >=20 > I tested this patch and it works. Thanks, I will push it upstream.