public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Stefan Liebler <stli@linux.ibm.com>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH 2/5] linux: Disable fstatat64 fallback if __ASSUME_STATX is defined
Date: Fri, 26 Mar 2021 10:24:29 +0100	[thread overview]
Message-ID: <0b9ffaea-2daf-9dd3-f2fa-5909b45bf1a4@linux.ibm.com> (raw)
In-Reply-To: <20210319183121.2252064-3-adhemerval.zanella@linaro.org>

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;
> 


  reply	other threads:[~2021-03-26  9:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19 18:31 [PATCH 0/5] More stat fixes Adhemerval Zanella
2021-03-19 18:31 ` [PATCH 1/5] linux: Implement fstatat with __fstatat64_time64 Adhemerval Zanella
2021-03-23 16:13   ` Stefan Liebler
2021-03-26  9:24   ` Stefan Liebler
2021-03-26 19:32     ` Adhemerval Zanella
2021-03-19 18:31 ` [PATCH 2/5] linux: Disable fstatat64 fallback if __ASSUME_STATX is defined Adhemerval Zanella
2021-03-26  9:24   ` Stefan Liebler [this message]
2021-03-26 19:38     ` Adhemerval Zanella
2021-03-19 18:31 ` [PATCH 3/5] linux: Use statx for MIPSn64 Adhemerval Zanella
2021-03-29 12:48   ` Adhemerval Zanella
2021-04-01  0:07   ` Maciej W. Rozycki
2021-04-01 12:45     ` Adhemerval Zanella
2021-04-01 18:00       ` Maciej W. Rozycki
2021-03-19 18:31 ` [PATCH 4/5] support: Add support_path_support_time64_value Adhemerval Zanella
2021-03-26  9:24   ` Stefan Liebler
2021-03-19 18:31 ` [PATCH 5/5] linux: Add y2106 support on utimensat tests Adhemerval Zanella
2021-03-26  9:24   ` Stefan Liebler
2021-03-26 19:40     ` Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0b9ffaea-2daf-9dd3-f2fa-5909b45bf1a4@linux.ibm.com \
    --to=stli@linux.ibm.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).