Skip to content

Commit 760e6f7

Browse files
Sebastian Andrzej SiewiorPeter Zijlstra
authored andcommitted
futex: Remove support for IMMUTABLE
The FH_FLAG_IMMUTABLE flag was meant to avoid the reference counting on the private hash and so to avoid the performance regression on big machines. With the switch to per-CPU counter this is no longer needed. That flag was never useable on any released kernel. Remove any support for IMMUTABLE while preserve the flags argument and enforce it to be zero. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20250710110011.384614-5-bigeasy@linutronix.de
1 parent fb3c553 commit 760e6f7

2 files changed

Lines changed: 3 additions & 35 deletions

File tree

include/uapi/linux/prctl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,6 @@ struct prctl_mm_map {
367367
/* FUTEX hash management */
368368
#define PR_FUTEX_HASH 78
369369
# define PR_FUTEX_HASH_SET_SLOTS 1
370-
# define FH_FLAG_IMMUTABLE (1ULL << 0)
371370
# define PR_FUTEX_HASH_GET_SLOTS 2
372-
# define PR_FUTEX_HASH_GET_IMMUTABLE 3
373371

374372
#endif /* _LINUX_PRCTL_H */

kernel/futex/core.c

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ struct futex_private_hash {
6969
struct rcu_head rcu;
7070
void *mm;
7171
bool custom;
72-
bool immutable;
7372
struct futex_hash_bucket queues[];
7473
};
7574

@@ -145,15 +144,11 @@ static inline bool futex_key_is_private(union futex_key *key)
145144

146145
static bool futex_private_hash_get(struct futex_private_hash *fph)
147146
{
148-
if (fph->immutable)
149-
return true;
150147
return futex_ref_get(fph);
151148
}
152149

153150
void futex_private_hash_put(struct futex_private_hash *fph)
154151
{
155-
if (fph->immutable)
156-
return;
157152
if (futex_ref_put(fph))
158153
wake_up_var(fph->mm);
159154
}
@@ -1530,7 +1525,6 @@ static void futex_hash_bucket_init(struct futex_hash_bucket *fhb,
15301525
}
15311526

15321527
#define FH_CUSTOM 0x01
1533-
#define FH_IMMUTABLE 0x02
15341528

15351529
#ifdef CONFIG_FUTEX_PRIVATE_HASH
15361530

@@ -1800,7 +1794,7 @@ static int futex_hash_allocate(unsigned int hash_slots, unsigned int flags)
18001794
*/
18011795
scoped_guard(rcu) {
18021796
fph = rcu_dereference(mm->futex_phash);
1803-
if (fph && (!fph->hash_mask || fph->immutable)) {
1797+
if (fph && !fph->hash_mask) {
18041798
if (custom)
18051799
return -EBUSY;
18061800
return 0;
@@ -1814,7 +1808,6 @@ static int futex_hash_allocate(unsigned int hash_slots, unsigned int flags)
18141808

18151809
fph->hash_mask = hash_slots ? hash_slots - 1 : 0;
18161810
fph->custom = custom;
1817-
fph->immutable = !!(flags & FH_IMMUTABLE);
18181811
fph->mm = mm;
18191812

18201813
for (i = 0; i < hash_slots; i++)
@@ -1838,7 +1831,7 @@ static int futex_hash_allocate(unsigned int hash_slots, unsigned int flags)
18381831
mm->futex_phash_new = NULL;
18391832

18401833
if (fph) {
1841-
if (cur && (!cur->hash_mask || cur->immutable)) {
1834+
if (cur && !cur->hash_mask) {
18421835
/*
18431836
* If two threads simultaneously request the global
18441837
* hash then the first one performs the switch,
@@ -1931,19 +1924,6 @@ static int futex_hash_get_slots(void)
19311924
return 0;
19321925
}
19331926

1934-
static int futex_hash_get_immutable(void)
1935-
{
1936-
struct futex_private_hash *fph;
1937-
1938-
guard(rcu)();
1939-
fph = rcu_dereference(current->mm->futex_phash);
1940-
if (fph && fph->immutable)
1941-
return 1;
1942-
if (fph && !fph->hash_mask)
1943-
return 1;
1944-
return 0;
1945-
}
1946-
19471927
#else
19481928

19491929
static int futex_hash_allocate(unsigned int hash_slots, unsigned int flags)
@@ -1956,10 +1936,6 @@ static int futex_hash_get_slots(void)
19561936
return 0;
19571937
}
19581938

1959-
static int futex_hash_get_immutable(void)
1960-
{
1961-
return 0;
1962-
}
19631939
#endif
19641940

19651941
int futex_hash_prctl(unsigned long arg2, unsigned long arg3, unsigned long arg4)
@@ -1969,21 +1945,15 @@ int futex_hash_prctl(unsigned long arg2, unsigned long arg3, unsigned long arg4)
19691945

19701946
switch (arg2) {
19711947
case PR_FUTEX_HASH_SET_SLOTS:
1972-
if (arg4 & ~FH_FLAG_IMMUTABLE)
1948+
if (arg4)
19731949
return -EINVAL;
1974-
if (arg4 & FH_FLAG_IMMUTABLE)
1975-
flags |= FH_IMMUTABLE;
19761950
ret = futex_hash_allocate(arg3, flags);
19771951
break;
19781952

19791953
case PR_FUTEX_HASH_GET_SLOTS:
19801954
ret = futex_hash_get_slots();
19811955
break;
19821956

1983-
case PR_FUTEX_HASH_GET_IMMUTABLE:
1984-
ret = futex_hash_get_immutable();
1985-
break;
1986-
19871957
default:
19881958
ret = -EINVAL;
19891959
break;

0 commit comments

Comments
 (0)