[PATCH 17/15] [HACK] futex: Force futex hash collision

From: Peter Zijlstra
Date: Fri Sep 22 2023 - 16:59:50 EST


If you hate performance -- use this.

Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
kernel/futex/core.c | 6 ++++++
kernel/sched/features.h | 2 ++
2 files changed, 8 insertions(+)

--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -128,6 +128,9 @@ static int futex_put_value(u32 val, u32
}
}

+#include <linux/sched/cputime.h>
+#include "../sched/sched.h"
+
/**
* futex_hash - Return the hash bucket in the global hash
* @key: Pointer to the futex key for which the hash is calculated
@@ -159,6 +162,9 @@ struct futex_hash_bucket *futex_hash(uni
}
}

+ if (sched_feat(FUTEX_SQUASH))
+ hash = 0;
+
return &futex_queues[node][hash & (futex_hashsize - 1)];
}

--- a/kernel/sched/features.h
+++ b/kernel/sched/features.h
@@ -89,3 +89,5 @@ SCHED_FEAT(UTIL_EST_FASTUP, true)
SCHED_FEAT(LATENCY_WARN, false)

SCHED_FEAT(HZ_BW, true)
+
+SCHED_FEAT(FUTEX_SQUASH, false)