unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
To: Kurt Kanzenbach <kurt@linutronix.de>, libc-alpha@sourceware.org
Cc: Florian Weimer <fweimer@redhat.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Joseph Myers <joseph@codesourcery.com>
Subject: Re: [PATCH v1 3/6] nptl: Use futex_lock_pi2()
Date: Fri, 9 Jul 2021 11:21:03 -0300	[thread overview]
Message-ID: <32e889eb-345a-7941-b719-82eea5b15411@linaro.org> (raw)
In-Reply-To: <20210625081104.1134598-4-kurt@linutronix.de>



On 25/06/2021 05:11, Kurt Kanzenbach wrote:
> Currently it is not possible to specify CLOCK_MONOTONIC for timeouts for PI
> mutexes. The FUTEX_LOCK_PI2 operation can be used to implement that.
> 
> Therefore, use it by default. In case FUTEX_LOCK_PI2 is not available on the
> running kernel, then EINVAL is returned as of now.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  nptl/pthread_mutex_timedlock.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
> index 5afd6222d61e..95892a32a6af 100644
> --- a/nptl/pthread_mutex_timedlock.c
> +++ b/nptl/pthread_mutex_timedlock.c
> @@ -300,13 +300,6 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex,
>      case PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP:
>      case PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP:
>        {
> -	/* Currently futex FUTEX_LOCK_PI operation only provides support for
> -	   CLOCK_REALTIME and trying to emulate by converting a
> -	   CLOCK_MONOTONIC to CLOCK_REALTIME will take in account possible
> -	   changes to the wall clock.  */
> -	if (__glibc_unlikely (clockid != CLOCK_REALTIME))
> -	  return EINVAL;
> -
>  	int kind, robust;
>  	{
>  	  /* See concurrency notes regarding __kind in struct __pthread_mutex_s
> @@ -370,7 +363,8 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex,
>  	    int private = (robust
>  			   ? PTHREAD_ROBUST_MUTEX_PSHARED (mutex)
>  			   : PTHREAD_MUTEX_PSHARED (mutex));
> -	    int e = futex_lock_pi64 (&mutex->__data.__lock, abstime, private);
> +	    int e = futex_lock_pi2_64 (&mutex->__data.__lock, clockid, abstime,
> +                                       private);
>  	    if (e == ETIMEDOUT)
>  	      return ETIMEDOUT;
>  	    else if (e == ESRCH || e == EDEADLK)
> 

I think we should change futex_lock_pi64() to use FUTEX_LOCK_PI2 and only
exports it instead of both futex_lock_pi64() and futex_lock_pi2_64.  It
can simplify the implementation and provide a complete internal futex
functionality (since by using two different PI-futex operation caller
should be aware that only futex_lock_pi2_64 supports FUTEX_LOCK_PI2).

  reply	other threads:[~2021-07-09 14:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-25  8:10 [PATCH v1 0/6] nptl: Introduce and use FUTEX_LOCK_PI2 Kurt Kanzenbach via Libc-alpha
2021-06-25  8:10 ` [PATCH v1 1/6] Linux: Add FUTEX_LOCK_PI2 Kurt Kanzenbach via Libc-alpha
2021-07-09 13:32   ` Adhemerval Zanella via Libc-alpha
2021-06-25  8:11 ` [PATCH v1 2/6] nptl: Introduce futex_lock_pi2() Kurt Kanzenbach via Libc-alpha
2021-07-09 14:13   ` Adhemerval Zanella via Libc-alpha
2021-06-25  8:11 ` [PATCH v1 3/6] nptl: Use futex_lock_pi2() Kurt Kanzenbach via Libc-alpha
2021-07-09 14:21   ` Adhemerval Zanella via Libc-alpha [this message]
2021-06-25  8:11 ` [PATCH v1 4/6] nptl: Remove mutex test 10 Kurt Kanzenbach via Libc-alpha
2021-07-09 14:23   ` Adhemerval Zanella via Libc-alpha
2021-06-25  8:11 ` [PATCH v1 5/6] nptl: mutex-test5: Include CLOCK_MONOTONIC for PI Kurt Kanzenbach via Libc-alpha
2021-06-25  8:11 ` [PATCH v1 6/6] nptl: mutex-test9: " Kurt Kanzenbach via Libc-alpha
2021-07-09  6:57 ` [PATCH v1 0/6] nptl: Introduce and use FUTEX_LOCK_PI2 Kurt Kanzenbach via Libc-alpha
2021-07-09 13:30 ` Adhemerval Zanella via Libc-alpha
2021-07-09 14:20   ` Kurt Kanzenbach via Libc-alpha

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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=32e889eb-345a-7941-b719-82eea5b15411@linaro.org \
    --to=libc-alpha@sourceware.org \
    --cc=adhemerval.zanella@linaro.org \
    --cc=bigeasy@linutronix.de \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=kurt@linutronix.de \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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).