mirror of
https://github.com/torvalds/linux.git
synced 2026-05-23 22:52:19 +02:00
selftests/futex: Remove support for IMMUTABLE
Testing for the IMMUTABLE part of the futex interface is not needed after the removal of the interface. Remove support for IMMUTABLE from the sefltest. 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-6-bigeasy@linutronix.de
This commit is contained in:
parent
760e6f7bef
commit
16adc7f136
|
|
@ -26,14 +26,12 @@ static int counter;
|
||||||
#ifndef PR_FUTEX_HASH
|
#ifndef PR_FUTEX_HASH
|
||||||
#define PR_FUTEX_HASH 78
|
#define PR_FUTEX_HASH 78
|
||||||
# define PR_FUTEX_HASH_SET_SLOTS 1
|
# define PR_FUTEX_HASH_SET_SLOTS 1
|
||||||
# define FH_FLAG_IMMUTABLE (1ULL << 0)
|
|
||||||
# define PR_FUTEX_HASH_GET_SLOTS 2
|
# define PR_FUTEX_HASH_GET_SLOTS 2
|
||||||
# define PR_FUTEX_HASH_GET_IMMUTABLE 3
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int futex_hash_slots_set(unsigned int slots, int flags)
|
static int futex_hash_slots_set(unsigned int slots)
|
||||||
{
|
{
|
||||||
return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, slots, flags);
|
return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, slots, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int futex_hash_slots_get(void)
|
static int futex_hash_slots_get(void)
|
||||||
|
|
@ -41,16 +39,11 @@ static int futex_hash_slots_get(void)
|
||||||
return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_GET_SLOTS);
|
return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_GET_SLOTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int futex_hash_immutable_get(void)
|
|
||||||
{
|
|
||||||
return prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_GET_IMMUTABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void futex_hash_slots_set_verify(int slots)
|
static void futex_hash_slots_set_verify(int slots)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = futex_hash_slots_set(slots, 0);
|
ret = futex_hash_slots_set(slots);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
ksft_test_result_fail("Failed to set slots to %d: %m\n", slots);
|
ksft_test_result_fail("Failed to set slots to %d: %m\n", slots);
|
||||||
ksft_finished();
|
ksft_finished();
|
||||||
|
|
@ -64,13 +57,13 @@ static void futex_hash_slots_set_verify(int slots)
|
||||||
ksft_test_result_pass("SET and GET slots %d passed\n", slots);
|
ksft_test_result_pass("SET and GET slots %d passed\n", slots);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void futex_hash_slots_set_must_fail(int slots, int flags)
|
static void futex_hash_slots_set_must_fail(int slots)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = futex_hash_slots_set(slots, flags);
|
ret = futex_hash_slots_set(slots);
|
||||||
ksft_test_result(ret < 0, "futex_hash_slots_set(%d, %d)\n",
|
ksft_test_result(ret < 0, "futex_hash_slots_set(%d)\n",
|
||||||
slots, flags);
|
slots);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *thread_return_fn(void *arg)
|
static void *thread_return_fn(void *arg)
|
||||||
|
|
@ -152,18 +145,14 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int futex_slots1, futex_slotsn, online_cpus;
|
int futex_slots1, futex_slotsn, online_cpus;
|
||||||
pthread_mutexattr_t mutex_attr_pi;
|
pthread_mutexattr_t mutex_attr_pi;
|
||||||
int use_global_hash = 0;
|
|
||||||
int ret, retry = 20;
|
int ret, retry = 20;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "cghv:")) != -1) {
|
while ((c = getopt(argc, argv, "chv:")) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
log_color(1);
|
log_color(1);
|
||||||
break;
|
break;
|
||||||
case 'g':
|
|
||||||
use_global_hash = 1;
|
|
||||||
break;
|
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(basename(argv[0]));
|
usage(basename(argv[0]));
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
@ -178,7 +167,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
ksft_print_header();
|
ksft_print_header();
|
||||||
ksft_set_plan(22);
|
ksft_set_plan(21);
|
||||||
|
|
||||||
ret = pthread_mutexattr_init(&mutex_attr_pi);
|
ret = pthread_mutexattr_init(&mutex_attr_pi);
|
||||||
ret |= pthread_mutexattr_setprotocol(&mutex_attr_pi, PTHREAD_PRIO_INHERIT);
|
ret |= pthread_mutexattr_setprotocol(&mutex_attr_pi, PTHREAD_PRIO_INHERIT);
|
||||||
|
|
@ -191,10 +180,6 @@ int main(int argc, char *argv[])
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
ksft_exit_fail_msg("futex_hash_slots_get() failed: %d, %m\n", ret);
|
ksft_exit_fail_msg("futex_hash_slots_get() failed: %d, %m\n", ret);
|
||||||
|
|
||||||
ret = futex_hash_immutable_get();
|
|
||||||
if (ret != 0)
|
|
||||||
ksft_exit_fail_msg("futex_hash_immutable_get() failed: %d, %m\n", ret);
|
|
||||||
|
|
||||||
ksft_test_result_pass("Basic get slots and immutable status.\n");
|
ksft_test_result_pass("Basic get slots and immutable status.\n");
|
||||||
ret = pthread_create(&threads[0], NULL, thread_return_fn, NULL);
|
ret = pthread_create(&threads[0], NULL, thread_return_fn, NULL);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
|
|
@ -267,7 +252,7 @@ int main(int argc, char *argv[])
|
||||||
futex_hash_slots_set_verify(32);
|
futex_hash_slots_set_verify(32);
|
||||||
futex_hash_slots_set_verify(16);
|
futex_hash_slots_set_verify(16);
|
||||||
|
|
||||||
ret = futex_hash_slots_set(15, 0);
|
ret = futex_hash_slots_set(15);
|
||||||
ksft_test_result(ret < 0, "Use 15 slots\n");
|
ksft_test_result(ret < 0, "Use 15 slots\n");
|
||||||
|
|
||||||
futex_hash_slots_set_verify(2);
|
futex_hash_slots_set_verify(2);
|
||||||
|
|
@ -285,28 +270,23 @@ int main(int argc, char *argv[])
|
||||||
ksft_test_result(ret == 2, "No more auto-resize after manaul setting, got %d\n",
|
ksft_test_result(ret == 2, "No more auto-resize after manaul setting, got %d\n",
|
||||||
ret);
|
ret);
|
||||||
|
|
||||||
futex_hash_slots_set_must_fail(1 << 29, 0);
|
futex_hash_slots_set_must_fail(1 << 29);
|
||||||
|
futex_hash_slots_set_verify(4);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Once the private hash has been made immutable or global hash has been requested,
|
* Once the global hash has been requested, then this requested can not
|
||||||
* then this requested can not be undone.
|
* be undone.
|
||||||
*/
|
*/
|
||||||
if (use_global_hash) {
|
ret = futex_hash_slots_set(0);
|
||||||
ret = futex_hash_slots_set(0, 0);
|
ksft_test_result(ret == 0, "Global hash request\n");
|
||||||
ksft_test_result(ret == 0, "Global hash request\n");
|
|
||||||
} else {
|
|
||||||
ret = futex_hash_slots_set(4, FH_FLAG_IMMUTABLE);
|
|
||||||
ksft_test_result(ret == 0, "Immutable resize to 4\n");
|
|
||||||
}
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
futex_hash_slots_set_must_fail(4, 0);
|
futex_hash_slots_set_must_fail(4);
|
||||||
futex_hash_slots_set_must_fail(4, FH_FLAG_IMMUTABLE);
|
futex_hash_slots_set_must_fail(8);
|
||||||
futex_hash_slots_set_must_fail(8, 0);
|
futex_hash_slots_set_must_fail(8);
|
||||||
futex_hash_slots_set_must_fail(8, FH_FLAG_IMMUTABLE);
|
futex_hash_slots_set_must_fail(0);
|
||||||
futex_hash_slots_set_must_fail(0, FH_FLAG_IMMUTABLE);
|
futex_hash_slots_set_must_fail(6);
|
||||||
futex_hash_slots_set_must_fail(6, FH_FLAG_IMMUTABLE);
|
|
||||||
|
|
||||||
ret = pthread_barrier_init(&barrier_main, NULL, MAX_THREADS);
|
ret = pthread_barrier_init(&barrier_main, NULL, MAX_THREADS);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
|
@ -317,14 +297,7 @@ int main(int argc, char *argv[])
|
||||||
join_max_threads();
|
join_max_threads();
|
||||||
|
|
||||||
ret = futex_hash_slots_get();
|
ret = futex_hash_slots_get();
|
||||||
if (use_global_hash) {
|
ksft_test_result(ret == 0, "Continue to use global hash\n");
|
||||||
ksft_test_result(ret == 0, "Continue to use global hash\n");
|
|
||||||
} else {
|
|
||||||
ksft_test_result(ret == 4, "Continue to use the 4 hash buckets\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = futex_hash_immutable_get();
|
|
||||||
ksft_test_result(ret == 1, "Hash reports to be immutable\n");
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
ksft_finished();
|
ksft_finished();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user