[04/13] linux: Extend __futex_abstimed_wait_cancelable64 comment

Message ID 20201123195256.3336217-4-adhemerval.zanella@linaro.org
State Committed
Headers
Series [01/13] linux: Remove unused internal futex functions |

Commit Message

Adhemerval Zanella Netto Nov. 23, 2020, 7:52 p.m. UTC
  And add a small optimization to avoid setting the operation for the
32-bit time fallback operation.

Checked on x86_64-linux-gnu and i686-linux-gnu.
---
 sysdeps/nptl/futex-internal.c |  8 ++------
 sysdeps/nptl/futex-internal.h | 18 +++++++++++++++---
 2 files changed, 17 insertions(+), 9 deletions(-)
  

Comments

Lukasz Majewski Nov. 24, 2020, 6:16 p.m. UTC | #1
Hi Adhemerval,

> And add a small optimization to avoid setting the operation for the
> 32-bit time fallback operation.
> 
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
>  sysdeps/nptl/futex-internal.c |  8 ++------
>  sysdeps/nptl/futex-internal.h | 18 +++++++++++++++---
>  2 files changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/sysdeps/nptl/futex-internal.c
> b/sysdeps/nptl/futex-internal.c index 457cd3cd69..e4a14b477c 100644
> --- a/sysdeps/nptl/futex-internal.c
> +++ b/sysdeps/nptl/futex-internal.c
> @@ -25,7 +25,7 @@
>  #ifndef __ASSUME_TIME64_SYSCALLS
>  static int
>  __futex_abstimed_wait_cancelable32 (unsigned int* futex_word,
> -                                    unsigned int expected, clockid_t
> clockid,
> +                                    unsigned int expected, int op,
>                                      const struct __timespec64*
> abstime, int private)
>  {
> @@ -39,10 +39,6 @@ __futex_abstimed_wait_cancelable32 (unsigned int*
> futex_word, pts32 = &ts32;
>      }
>  
> -  unsigned int clockbit = (clockid == CLOCK_REALTIME)
> -	  ? FUTEX_CLOCK_REALTIME : 0;
> -  int op = __lll_private_flag (FUTEX_WAIT_BITSET | clockbit,
> private); -
>    return INTERNAL_SYSCALL_CANCEL (futex, futex_word, op, expected,
>                                    pts32, NULL /* Unused.  */,
>                                    FUTEX_BITSET_MATCH_ANY);
> @@ -119,7 +115,7 @@ __futex_abstimed_wait_cancelable64 (unsigned int*
> futex_word, #ifndef __ASSUME_TIME64_SYSCALLS
>    if (err == -ENOSYS)
>      err = __futex_abstimed_wait_cancelable32 (futex_word, expected,
> -                                              clockid, abstime,
> private);
> +                                              op, abstime, private);
>  #endif
>  
>    switch (err)
> diff --git a/sysdeps/nptl/futex-internal.h
> b/sysdeps/nptl/futex-internal.h index d5f13d15fb..cefab74301 100644
> --- a/sysdeps/nptl/futex-internal.h
> +++ b/sysdeps/nptl/futex-internal.h
> @@ -390,9 +390,21 @@ futex_unlock_pi (unsigned int *futex_word, int
> private) }
>  }
>  
> -/* The futex_abstimed_wait_cancelable64 has been moved to a separate
> file
> -   to avoid problems with exhausting available registers on some
> architectures
> -   - e.g. on m68k architecture.  */
> +/* Like futex_wait, but will eventually time out (i.e., stop being
> blocked)
> +   after the duration of time provided (i.e., ABSTIME) has passed
> using the
> +   clock specified by CLOCKID (currently only CLOCK_REALTIME and
> +   CLOCK_MONOTONIC, the ones support by
> lll_futex_supported_clockid). ABSTIME
> +   can also equal NULL, in which case this function behaves
> equivalent to
> +   futex_wait.
> +
> +   Returns the same values as futex_wait under those same conditions;
> +   additionally, returns ETIMEDOUT if the timeout expired.
> +
> +   The call acts a cancellation entrypoint.
> +
> +   (The implementation has been moved to a separate file to avoid
> problems
> +   with exhausting available registers on some architectures - e.g.
> on
> +   m68k).  */
>  int
>  __futex_abstimed_wait_cancelable64 (unsigned int* futex_word,
>                                      unsigned int expected, clockid_t
> clockid,

Reviewed-by: Lukasz Majewski <lukma@denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
  

Patch

diff --git a/sysdeps/nptl/futex-internal.c b/sysdeps/nptl/futex-internal.c
index 457cd3cd69..e4a14b477c 100644
--- a/sysdeps/nptl/futex-internal.c
+++ b/sysdeps/nptl/futex-internal.c
@@ -25,7 +25,7 @@ 
 #ifndef __ASSUME_TIME64_SYSCALLS
 static int
 __futex_abstimed_wait_cancelable32 (unsigned int* futex_word,
-                                    unsigned int expected, clockid_t clockid,
+                                    unsigned int expected, int op,
                                     const struct __timespec64* abstime,
                                     int private)
 {
@@ -39,10 +39,6 @@  __futex_abstimed_wait_cancelable32 (unsigned int* futex_word,
       pts32 = &ts32;
     }
 
-  unsigned int clockbit = (clockid == CLOCK_REALTIME)
-	  ? FUTEX_CLOCK_REALTIME : 0;
-  int op = __lll_private_flag (FUTEX_WAIT_BITSET | clockbit, private);
-
   return INTERNAL_SYSCALL_CANCEL (futex, futex_word, op, expected,
                                   pts32, NULL /* Unused.  */,
                                   FUTEX_BITSET_MATCH_ANY);
@@ -119,7 +115,7 @@  __futex_abstimed_wait_cancelable64 (unsigned int* futex_word,
 #ifndef __ASSUME_TIME64_SYSCALLS
   if (err == -ENOSYS)
     err = __futex_abstimed_wait_cancelable32 (futex_word, expected,
-                                              clockid, abstime, private);
+                                              op, abstime, private);
 #endif
 
   switch (err)
diff --git a/sysdeps/nptl/futex-internal.h b/sysdeps/nptl/futex-internal.h
index d5f13d15fb..cefab74301 100644
--- a/sysdeps/nptl/futex-internal.h
+++ b/sysdeps/nptl/futex-internal.h
@@ -390,9 +390,21 @@  futex_unlock_pi (unsigned int *futex_word, int private)
     }
 }
 
-/* The futex_abstimed_wait_cancelable64 has been moved to a separate file
-   to avoid problems with exhausting available registers on some architectures
-   - e.g. on m68k architecture.  */
+/* Like futex_wait, but will eventually time out (i.e., stop being blocked)
+   after the duration of time provided (i.e., ABSTIME) has passed using the
+   clock specified by CLOCKID (currently only CLOCK_REALTIME and
+   CLOCK_MONOTONIC, the ones support by lll_futex_supported_clockid). ABSTIME
+   can also equal NULL, in which case this function behaves equivalent to
+   futex_wait.
+
+   Returns the same values as futex_wait under those same conditions;
+   additionally, returns ETIMEDOUT if the timeout expired.
+
+   The call acts a cancellation entrypoint.
+
+   (The implementation has been moved to a separate file to avoid problems
+   with exhausting available registers on some architectures - e.g. on
+   m68k).  */
 int
 __futex_abstimed_wait_cancelable64 (unsigned int* futex_word,
                                     unsigned int expected, clockid_t clockid,