public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org,
	"André Almeida" <andrealmeid@igalia.com>,
	"Darren Hart" <dvhart@infradead.org>,
	"Davidlohr Bueso" <dave@stgolabs.net>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Juri Lelli" <juri.lelli@redhat.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Valentin Schneider" <vschneid@redhat.com>,
	"Waiman Long" <longman@redhat.com>
Subject: Re: [PATCH v8 08/15] futex: Prepare for reference counting of the process private hash end of operation.
Date: Tue, 4 Feb 2025 10:49:22 +0100	[thread overview]
Message-ID: <20250204094922.GS7145@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20250203135935.440018-9-bigeasy@linutronix.de>

On Mon, Feb 03, 2025 at 02:59:28PM +0100, Sebastian Andrzej Siewior wrote:

> @@ -555,11 +558,12 @@ struct futex_hash_bucket *futex_q_lock(struct futex_q *q)
>  	return hb;
>  }
>  
> -void futex_q_unlock(struct futex_hash_bucket *hb)
> +void futex_q_unlock_put(struct futex_hash_bucket *hb)
>  	__releases(&hb->lock)
>  {
>  	futex_hb_waiters_dec(hb);
>  	spin_unlock(&hb->lock);
> +	futex_hash_put(hb);
>  }

Here you don't

> @@ -288,23 +289,29 @@ extern void __futex_unqueue(struct futex_q *q);
>  extern void __futex_queue(struct futex_q *q, struct futex_hash_bucket *hb);
>  extern int futex_unqueue(struct futex_q *q);
>  
> +static inline void futex_hb_unlock_put(struct futex_hash_bucket *hb)
> +{
> +	spin_unlock(&hb->lock);
> +	futex_hash_put(hb);
> +}
> +
>  /**
> - * futex_queue() - Enqueue the futex_q on the futex_hash_bucket
> + * futex_queue_put() - Enqueue the futex_q on the futex_hash_bucket
>   * @q:	The futex_q to enqueue
>   * @hb:	The destination hash bucket
>   *
> - * The hb->lock must be held by the caller, and is released here. A call to
> - * futex_queue() is typically paired with exactly one call to futex_unqueue().  The
> - * exceptions involve the PI related operations, which may use futex_unqueue_pi()
> - * or nothing if the unqueue is done as part of the wake process and the unqueue
> - * state is implicit in the state of woken task (see futex_wait_requeue_pi() for
> - * an example).
> + * The hb->lock must be held by the caller, and is released here and the reference
> + * on the hb is dropped. A call to futex_queue_put() is typically paired with
> + * exactly one call to futex_unqueue(). The exceptions involve the PI related
> + * operations, which may use futex_unqueue_pi() or nothing if the unqueue is
> + * done as part of the wake process and the unqueue state is implicit in the
> + * state of woken task (see futex_wait_requeue_pi() for an example).
>   */
> -static inline void futex_queue(struct futex_q *q, struct futex_hash_bucket *hb)
> +static inline void futex_queue_put(struct futex_q *q, struct futex_hash_bucket *hb)
>  	__releases(&hb->lock)
>  {
>  	__futex_queue(q, hb);
> -	spin_unlock(&hb->lock);
> +	futex_hb_unlock_put(hb);
>  }

And here you do.


> @@ -380,11 +387,13 @@ double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
>  }
>  
>  static inline void
> -double_unlock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
> +double_unlock_hb_put(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
>  {
>  	spin_unlock(&hb1->lock);
>  	if (hb1 != hb2)
>  		spin_unlock(&hb2->lock);
> +	futex_hash_put(hb1);
> +	futex_hash_put(hb2);
>  }
>  

This seems horribly inconsistent and makes my head hurt. Where are the
matching gets for double_lock_hb() ?

  reply	other threads:[~2025-02-04  9:49 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-03 13:59 [PATCH v8 00/15] futex: Add support task local hash maps Sebastian Andrzej Siewior
2025-02-03 13:59 ` [PATCH v8 01/15] rcuref: Avoid false positive "imbalanced put" report Sebastian Andrzej Siewior
2025-02-03 13:59 ` [PATCH v8 02/15] futex: Create helper function to initialize a hash slot Sebastian Andrzej Siewior
2025-02-03 13:59 ` [PATCH v8 03/15] futex: Add basic infrastructure for local task local hash Sebastian Andrzej Siewior
2025-02-03 14:27   ` Peter Zijlstra
2025-02-03 15:51     ` Sebastian Andrzej Siewior
2025-02-04 10:34       ` Peter Zijlstra
2025-02-05  8:39         ` Sebastian Andrzej Siewior
2025-02-07  9:41           ` Juri Lelli
2025-02-07 11:00             ` Sebastian Andrzej Siewior
2025-02-07 11:06               ` Peter Zijlstra
2025-02-07 14:47                 ` Juri Lelli
2025-02-03 14:29   ` Peter Zijlstra
2025-02-03 14:41   ` Peter Zijlstra
2025-02-03 15:39     ` Peter Zijlstra
2025-02-03 15:52     ` Sebastian Andrzej Siewior
2025-02-04  8:41       ` Peter Zijlstra
2025-02-04  9:28         ` Thomas Gleixner
2025-02-03 13:59 ` [PATCH v8 04/15] futex: Allow automatic allocation of process wide futex hash Sebastian Andrzej Siewior
2025-02-03 14:36   ` Peter Zijlstra
2025-02-03 15:54     ` Sebastian Andrzej Siewior
2025-02-03 13:59 ` [PATCH v8 05/15] futex: Hash only the address for private futexes Sebastian Andrzej Siewior
2025-02-03 14:41   ` Peter Zijlstra
2025-02-03 13:59 ` [PATCH v8 06/15] futex: Move private hashing into its own function Sebastian Andrzej Siewior
2025-02-04  9:34   ` Peter Zijlstra
2025-02-05  7:51     ` Sebastian Andrzej Siewior
2025-02-03 13:59 ` [PATCH v8 07/15] futex: Decrease the waiter count before the unlock operation Sebastian Andrzej Siewior
2025-02-03 13:59 ` [PATCH v8 08/15] futex: Prepare for reference counting of the process private hash end of operation Sebastian Andrzej Siewior
2025-02-04  9:49   ` Peter Zijlstra [this message]
2025-02-05  7:54     ` Sebastian Andrzej Siewior
2025-02-05  9:37       ` Peter Zijlstra
2025-02-03 13:59 ` [PATCH v8 09/15] futex: Re-evaluate the hash bucket after dropping the lock Sebastian Andrzej Siewior
2025-02-03 13:59 ` [PATCH v8 10/15] futex: Introduce futex_get_locked_hb() Sebastian Andrzej Siewior
2025-02-03 13:59 ` [PATCH v8 11/15] futex: Acquire a hash reference in futex_wait_multiple_setup() Sebastian Andrzej Siewior
2025-02-03 13:59 ` [PATCH v8 12/15] futex: Allow to re-allocate the private local hash Sebastian Andrzej Siewior
2025-02-04 11:05   ` Peter Zijlstra
2025-02-05  8:00     ` Sebastian Andrzej Siewior
2025-02-03 13:59 ` [PATCH v8 13/15] futex: Resize local futex hash table based on number of threads Sebastian Andrzej Siewior
2025-02-04 10:21   ` Peter Zijlstra
2025-02-05  8:05     ` Sebastian Andrzej Siewior
2025-02-07  9:07     ` Sebastian Andrzej Siewior
2025-02-03 13:59 ` [PATCH v8 14/15] futex: Use a hashmask instead of hashsize Sebastian Andrzej Siewior
2025-02-03 13:59 ` [PATCH v8 15/15] futex: Avoid allocating new local hash if there is something pending Sebastian Andrzej Siewior
2025-02-04 15:14 ` [PATCH v8 00/15] futex: Add support task local hash maps Peter Zijlstra
2025-02-05  8:46   ` Sebastian Andrzej Siewior
2025-02-05 12:20   ` Sebastian Andrzej Siewior
2025-02-05 12:52     ` Peter Zijlstra
2025-02-05 16:52       ` Sebastian Andrzej Siewior
2025-02-20 15:12     ` Peter Zijlstra
2025-02-20 15:57       ` Sebastian Andrzej Siewior
2025-02-21 16:00       ` Sebastian Andrzej Siewior
2025-02-21 19:21         ` Peter Zijlstra

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=20250204094922.GS7145@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=andrealmeid@igalia.com \
    --cc=bigeasy@linutronix.de \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vschneid@redhat.com \
    /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