From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id DE4493858028 for ; Fri, 26 Mar 2021 09:24:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DE4493858028 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12Q94YgF118466 for ; Fri, 26 Mar 2021 05:24:35 -0400 Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 37h767g447-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Mar 2021 05:24:34 -0400 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12Q9CX8g006522 for ; Fri, 26 Mar 2021 09:24:32 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma01fra.de.ibm.com with ESMTP id 37h15188q3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Mar 2021 09:24:32 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 12Q9OBwh36045180 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 26 Mar 2021 09:24:11 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1C15EA4040 for ; Fri, 26 Mar 2021 09:24:30 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA162A4051 for ; Fri, 26 Mar 2021 09:24:29 +0000 (GMT) Received: from li-ab9d22cc-354d-11b2-a85c-e984af76f811.ibm.com (unknown [9.171.2.19]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Fri, 26 Mar 2021 09:24:29 +0000 (GMT) From: Stefan Liebler Subject: Re: [PATCH 2/5] linux: Disable fstatat64 fallback if __ASSUME_STATX is defined To: libc-alpha@sourceware.org References: <20210319183121.2252064-1-adhemerval.zanella@linaro.org> <20210319183121.2252064-3-adhemerval.zanella@linaro.org> Message-ID: <0b9ffaea-2daf-9dd3-f2fa-5909b45bf1a4@linux.ibm.com> Date: Fri, 26 Mar 2021 10:24:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210319183121.2252064-3-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: vy-jYRI7KRbW1vwcQeQ-7W7blb4cm7Al X-Proofpoint-GUID: vy-jYRI7KRbW1vwcQeQ-7W7blb4cm7Al X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-03-26_02:2021-03-26, 2021-03-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=975 mlxscore=0 bulkscore=0 adultscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 clxscore=1015 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103260067 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Fri, 26 Mar 2021 09:24:37 -0000 On 19/03/2021 19:31, Adhemerval Zanella via Libc-alpha wrote: > If the minimum kernel supports statx there is no need to call the > fallback stat legacy syscalls. > > The statx is also called on compat xstat syscall, but different > than the fstatat it calls no fallback and it is assumed to be > always present. > > Checked on powerpc-linux-gnu (with and without --enable-kernel=4.11) > and on powerpc64-linux-gnu. > --- > sysdeps/unix/sysv/linux/fstatat64.c | 57 +++++++++++++++++++++-------- > 1 file changed, 41 insertions(+), 16 deletions(-) > > diff --git a/sysdeps/unix/sysv/linux/fstatat64.c b/sysdeps/unix/sysv/linux/fstatat64.c > index 490226a8ec..c3a030af58 100644 > --- a/sysdeps/unix/sysv/linux/fstatat64.c > +++ b/sysdeps/unix/sysv/linux/fstatat64.c > @@ -31,6 +31,7 @@ > #if __TIMESIZE == 64 \ > && (__WORDSIZE == 32 \ > && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) > +# define FSTATAT_USE_STATX 1 This will lead to a redefinition later in the file. > /* Sanity check to avoid newer 32-bit ABI to support non-LFS calls. */ > _Static_assert (sizeof (__off_t) == sizeof (__off64_t), > "__blkcnt_t and __blkcnt64_t must match"); > @@ -40,27 +41,25 @@ _Static_assert (sizeof (__blkcnt_t) == sizeof (__blkcnt64_t), > "__blkcnt_t and __blkcnt64_t must match"); > #endif > > -int > -__fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf, > - int flag) > +static inline int > +fstatat64_time64_statx (int fd, const char *file, struct __stat64_t64 *buf, > + int flag) > { > - int r; > - > -#if (__WORDSIZE == 32 \ > - && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) > /* 32-bit kABI with default 64-bit time_t, e.g. arc, riscv32. Also > 64-bit time_t support is done through statx syscall. */ > struct statx tmp; > - r = INTERNAL_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag, > - STATX_BASIC_STATS, &tmp); > + int r = INTERNAL_SYSCALL_CALL (statx, fd, file, AT_NO_AUTOMOUNT | flag, > + STATX_BASIC_STATS, &tmp); > if (r == 0) > - { > - __cp_stat64_t64_statx (buf, &tmp); > - return 0; > - } > - if (-r != ENOSYS) > - return INLINE_SYSCALL_ERROR_RETURN_VALUE (-r); > -#endif > + __cp_stat64_t64_statx (buf, &tmp); > + return r; > +} > + > +static inline int > +fstatat64_time64_stat (int fd, const char *file, struct __stat64_t64 *buf, > + int flag) > +{ > + int r; > > #if XSTAT_IS_XSTAT64 > # ifdef __NR_newfstatat > @@ -114,6 +113,32 @@ __fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf, > # endif > #endif > > + return r; > +} > + > +#if (__WORDSIZE == 32 \ > + && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32)) > +# define FSTATAT_USE_STATX 1 > +#else > +# define FSTATAT_USE_STATX 0 > +#endif FSTATAT_USE_STATX will be redefined as mentioned earlier > + > +int > +__fstatat64_time64 (int fd, const char *file, struct __stat64_t64 *buf, > + int flag) > +{ > + int r; > + > +#if FSTATAT_USE_STATX > + r = fstatat64_time64_statx (fd, file, buf, flag); > +# ifndef __ASSUME_STATX > + if (r == -ENOSYS) > + r = fstatat64_time64_stat (fd, file, buf, flag); > +# endif > +#else > + r = fstatat64_time64_stat (fd, file, buf, flag); > +#endif > + The former __fstatat64_time64 is splitted into fstatat64_time64_statx and fstatat64_time64_stat. And if statx is always available, we can skip the stat part. OK > return INTERNAL_SYSCALL_ERROR_P (r) > ? INLINE_SYSCALL_ERROR_RETURN_VALUE (-r) > : 0; >