[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250123202446.610203-16-bigeasy@linutronix.de>
Date: Thu, 23 Jan 2025 21:24:45 +0100
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: linux-kernel@...r.kernel.org
Cc: André Almeida <andrealmeid@...lia.com>,
Darren Hart <dvhart@...radead.org>,
Davidlohr Bueso <dave@...olabs.net>,
Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Valentin Schneider <vschneid@...hat.com>,
Waiman Long <longman@...hat.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Subject: [PATCH v7 15/15] futex: Avoid allocating new local hash if there is something pending.
If a new private hash has been prepared but not yet applied then
creating a new thread will lead to the allocation of another private
hash which will be freed later.
This is an optional optimisation to avoid allocating a new private hash
if the already prepared private hash matches the current requirement.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
---
kernel/futex/core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index 9e32bfa7ba4ab..7f61f734ca5d9 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1424,6 +1424,13 @@ static int futex_hash_allocate(unsigned int hash_slots)
&alloc_size)))
return -ENOMEM;
+ if (mm->futex_phash_new) {
+ scoped_guard(mutex, &mm->futex_hash_lock) {
+ if (mm->futex_phash_new && mm->futex_phash_new->hash_mask >= hash_slots - 1)
+ return 0;
+ }
+ }
+
hb_p = kvmalloc(alloc_size, GFP_KERNEL_ACCOUNT);
if (!hb_p)
return -ENOMEM;
--
2.47.2
Powered by blists - more mailing lists