public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/14] futex: Add support task local hash maps.
@ 2024-12-15 23:00 Sebastian Andrzej Siewior
  2024-12-15 23:00 ` [PATCH v5 01/14] futex: Create helper function to initialize a hash slot Sebastian Andrzej Siewior
                   ` (13 more replies)
  0 siblings, 14 replies; 19+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-12-15 23:00 UTC (permalink / raw)
  To: linux-kernel
  Cc: André Almeida, Darren Hart, Davidlohr Bueso, Ingo Molnar,
	Juri Lelli, Peter Zijlstra, Thomas Gleixner, Valentin Schneider,
	Waiman Long

Hi,

this is a follow up on
	https://lore.kernel.org/ZwVOMgBMxrw7BU9A@jlelli-thinkpadt14gen4.remote.csb

and adds support for task local futex_hash_bucket. It can be created via
prctl().

This version supports resize at runtime, auto resize while creating
threads. The upper limit is at 256 * num_possible_cpus() but I guess we
can lower that.

I posted performance numbers of "perf bench futex hash"
	https://lore.kernel.org/all/20241101110810.R3AnEqdu@linutronix.de/

I didn't do any new but the lkp bot reported an improvement
	https://lore.kernel.org/all/202412122315.1a745d81-lkp@intel.com/

While the performance of the 16 default bucket look worse than the 512
(after that the performance hardly changes while before that doubles) be
aware those are now task local (and not shared with others) and it seems
to be sufficient in general.
For the systems with 512CPUs and one db application we can have the
resize. So either the application needs to resize it or we offer auto
resize based on threads and CPUs. But be aware that workloads like
"xz huge_file.tar" will happily acquire all CPUs in the system and only
use a few locks in total and not very often. So it would probably
perform with two hash buckets as good as 512 in this scenario.

v4…v5: https://lore.kernel.org/all/20241203164335.1125381-1-bigeasy@linutronix.de/
  - Changed the the reference-tracking scheme: The reference is now
    dropped once the lock is dropped. The resize operation also requeues
    all users on the hash bucket from the old one to the new one.

v3…v4: https://lore.kernel.org/all/20241115172035.795842-1-bigeasy@linutronix.de/
  - Completed resize. Tested with wait/wake, lock_pi, requeue and
    requeue_pi.
  - Added auto resize during thread creation.
  - Fixed bucket initialisation of the global hash bucket resilting in a
    crash sometimes.

v2…v3 https://lore.kernel.org/all/20241028121921.1264150-1-bigeasy@linutronix.de/
  - The default auto size for auto creation is 16.
  - For the private hash jhash2 is used and only for the address.
  - My "perf bench futex hash" hacks have been added.
  - The structure moved from signal's struct to mm.
  - It is possible resize it at runtime.

v1…v2 https://lore.kernel.org/all/20241026224306.982896-1-bigeasy@linutronix.de/:
  - Moved to struct signal_struct and is used process wide.
  - Automaticly allocated once the first thread is created.

Sebastian


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-12-17 17:07 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-15 23:00 [PATCH v5 0/14] futex: Add support task local hash maps Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 01/14] futex: Create helper function to initialize a hash slot Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 02/14] futex: Add basic infrastructure for local task local hash Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 03/14] futex: Allow automatic allocation of process wide futex hash Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 04/14] futex: Hash only the address for private futexes Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 05/14] futex: Move private hashing into its own function Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 06/14] futex: Add helper which include the put of a hb after end of operation Sebastian Andrzej Siewior
2024-12-16 18:48   ` Thomas Gleixner
2024-12-17 17:07     ` Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 07/14] futex: Move the retry_private label Sebastian Andrzej Siewior
2024-12-16 20:41   ` Thomas Gleixner
2024-12-15 23:00 ` [PATCH v5 08/14] futex: Introduce futex_get_locked_hb() Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 09/14] futex: Allow to re-allocate the private hash bucket Sebastian Andrzej Siewior
2024-12-17 14:58   ` Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 10/14] futex: Resize futex hash table based on number of threads Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 11/14] futex: Use a hashmask instead of hashsize Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 12/14] tools/perf: Add the prctl(PR_FUTEX_HASH,…) to futex-hash Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 13/14] tools/perf: The the current affinity for CPU pinning in futex-hash Sebastian Andrzej Siewior
2024-12-15 23:00 ` [PATCH v5 14/14] tools/perf: Allocate futex locks on the local CPU-node Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox