From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id 8347E3858413 for ; Wed, 24 Nov 2021 21:29:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8347E3858413 Received: by mail-pj1-x1029.google.com with SMTP id cq22-20020a17090af99600b001a9550a17a5so6091618pjb.2 for ; Wed, 24 Nov 2021 13:29:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=ToIIoEnmZWxUtLuaGtinDAJkLjr3J4KrapzstKtzQEI=; b=B33UIc3QCJj8vPxIB7wLn7IfrV+Ra+voGqxUgTzYzwDnWI3LpgGrEw+0/t3FJixDRF jfc1dE+AjC+/zvseJTn+3+wt+udMpfkX2vaGBlEAeq+Dmkcrh4clmel6G8ORjf79bOED klSLFJrbq5KVBwzvNA15QwRRho6wC+mVEnjecMHsrlHRz+V1ykuFi+AFsM/nT0O4hAnv lPqKD5+PMfGcVIc68T0e3bsYYoucYNBWYLTH75VoV3JqZtRKVjy7wMtfJZKvU17hlJaS kXcXnoix9lAmgLje4Vk0VixI5NUbimuPsyLyAARsV6ImFTo2mu8RXBZnXJ2gdTTHHNHp i/sw== X-Gm-Message-State: AOAM533mdZo6UN4ArzqWATNR/cpszcXWE9sBh1T143zTiOXcAlSXysyN G6vUZR0GlQ1PxU1XxCzw9Oc= X-Google-Smtp-Source: ABdhPJzcoOvxV7q2AWtpAPlKKQshuYMMOT0M86rx/GjIIXu1Cbe4vOB0WXzLL2vRgAmGhh7HHCEMuA== X-Received: by 2002:a17:90b:4d0e:: with SMTP id mw14mr164922pjb.43.1637789358542; Wed, 24 Nov 2021 13:29:18 -0800 (PST) Received: from localhost ([2409:10:24a0:4700:e8ad:216a:2a9d:6d0c]) by smtp.gmail.com with ESMTPSA id e14sm451642pga.76.2021.11.24.13.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 13:29:17 -0800 (PST) Date: Thu, 25 Nov 2021 06:29:15 +0900 From: Stafford Horne To: Adhemerval Zanella Cc: GLIBC patches Subject: Re: [PATCH] linux: Define STAT64_IS_KERNEL_STAT64 by default Message-ID: References: <20211120210901.3991578-1-shorne@gmail.com> <7bea3e23-bbde-e5c8-137d-1fc105c1a7b7@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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: Wed, 24 Nov 2021 21:29:21 -0000 On Wed, Nov 24, 2021 at 12:50:40PM -0300, Adhemerval Zanella wrote: >=20 >=20 > 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") the > >>> default for STAT64_IS_KERNEL_STAT64 was removed. This patch adds it > >>> back. > >>> > >>> For architectures that want to used the default kernel_stat.h and do = not > >>> have __NR_newfstatat, STAT64_IS_KERNEL_STAT64 needs to be defined. S= et > >>> the default as 1 as modern port's stat64 struct should match the kern= el > >>> stat64 layout. > >>> > >>> I tested this on the OpenRISC port and it seems to work fine. Curren= tly, > >>> 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 se= ems > >>> to be an outlier it uses the default kernel_stat.h, but does not defi= ne > >>> __NR_newfstatat or __NR_fstatat64 I am not clear how arc works here. > >> > >> 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 __ASSUME_= STATX > >> would be defined and only fstatat64_time64_statx would be used. > >=20 > > Right, > >=20 > > In that case maybe another ifdef is needed in fstatat64.c? I don't see > > fstatat64_time64_stat is actually getting compiled into the libc.so bin= ary. But > > if I don't define STAT64_IS_KERNEL_STAT64 I get the below compile error. > >=20 > > I added a pragma to output the value of FSTATAT_USE_STATX and __ASSUME_= STATX in > > the compile unit and I get the below which looks right: > >=20 > > * __ASSUME_STATX: 1 > > * FSTATAT_USE_STATX: 1 > >=20 > > Error: > >=20 > > or1k-glibc-linux-gnu-gcc ../sysdeps/unix/sysv/linux/fstatat64.c -c -std= =3Dgnu11 -fgnu89-inline -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmer= ge-all-constants -frounding-math -fno-stack-protector -fno-common -Wstrict-= prototypes -Wold-style-definition -fmath-errno -ftls-model=3Dinitial-e= xec -I../include -I/home/shorne/work/gnu-toolchain/build-many/build/gl= ibcs/or1k-linux-gnu-soft/glibc/io -I/home/shorne/work/gnu-toolchain/build-= many/build/glibcs/or1k-linux-gnu-soft/glibc -I../sysdeps/unix/sysv/linux/o= r1k -I../sysdeps/or1k/nptl -I../sysdeps/unix/sysv/linux/generic/wordsize-= 32 -I../sysdeps/unix/sysv/linux/generic -I../sysdeps/unix/sysv/linux/incl= ude -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread = -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysd= eps/unix -I../sysdeps/posix -I../sysdeps/or1k/nofpu -I../sysdeps/ieee754= /soft-fp -I../sysdeps/or1k -I../sysdeps/wordsize-32 -I../sysdeps/ieee754= /dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/ge= neric -I.. -I../libio -I. -D_LIBC_REENTRANT -include /home/shorne/work/gn= u-toolchain/build-many/build/glibcs/or1k-linux-gnu-soft/glibc/libc-modules.= h -DMODULE_NAME=3Dlibc -include ../include/libc-symbols.h -DTOP_NAMES= PACE=3Dglibc -o /home/shorne/work/gnu-toolchain/build-many/build/glibcs/or1= k-linux-gnu-soft/glibc/io/fstatat64.o -MD -MP -MF /home/shorne/work/gnu-too= lchain/build-many/build/glibcs/or1k-linux-gnu-soft/glibc/io/fstatat64.o.dt = -MT /home/shorne/work/gnu-toolchain/build-many/build/glibcs/or1k-linux-gnu-= soft/glibc/io/fstatat64.o > > ../sysdeps/unix/sysv/linux/fstatat64.c: In function =E2=80=98fstatat64_= time64_stat=E2=80=99: > > ../sysdeps/unix/sysv/linux/fstatat64.c:89:7: error: "STAT64_IS_KERNEL_S= TAT64" 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 declaratio= n of function =E2=80=98__cp_stat64_kstat64=E2=80=99 [-Werror=3Dimplicit-fun= ction-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 me= ssage: The value of FSTATAT_USE_STATX: 1=E2=80=99 > > 149 | #pragma message "The value of FSTATAT_USE_STATX: " XSTR(FSTATAT= _USE_STATX) > > | ^~~~~~~ > > ../sysdeps/unix/sysv/linux/fstatat64.c:150:9: note: =E2=80=98#pragma me= ssage: The value of __ASSUME_STATX: 1=E2=80=99 > > 150 | #pragma message "The value of __ASSUME_STATX: " XSTR(__ASSUME_S= TATX) > > | ^~~~~~~ > >=20 > > Again I am not sure how arc avoids this error I shall try to compile it= too. >=20 > The problem is 'fstatat64_time64_stat' should not be build for 32-bit arc= hitectures > with __ASSUME_STATX (since only statx provides 64-bit timestamps). Other= architecture > might get an improved codegen using older syscalls (specially 64-bit ones= ), so statx > should be used only when really required. >=20 > The patch below fixes it: 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 the s= ame version of GCC the arc build passes but or1k fails with the above error. S= o as you said, maybe there is better codegen somewhere. > diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linu= x/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, stru= ct __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 with > + __ASSUME_STATX, so there is no point in building the fallback. */ > +#if !FSTATAT_USE_STATX || (FSTATAT_USE_STATX && !defined __ASSUME_STATX) > static inline int > fstatat64_time64_stat (int fd, const char *file, struct __stat64_t64 *bu= f, > int flag) > @@ -134,13 +145,6 @@ fstatat64_time64_stat (int fd, const char *file, str= uct __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 I tested this patch and it works. -Stafford