Skip to content

Commit 0048fbb

Browse files
committed
Merge tag 'locking-futex-2025-12-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull futex updates from Ingo Molnar: - Standardize on ktime_t in restart_block::time as well (Thomas Weißschuh) - Futex selftests: - Add robust list testcases (André Almeida) - Formatting fixes/cleanups (Carlos Llamas) * tag 'locking-futex-2025-12-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: futex: Store time as ktime_t in restart block selftests/futex: Create test for robust list selftests/futex: Skip tests if shmget unsupported selftests/futex: Add newline to ksft_exit_fail_msg() selftests/futex: Remove unused test_futex_mpol()
2 parents 2137cb8 + c42ba5a commit 0048fbb

8 files changed

Lines changed: 567 additions & 15 deletions

File tree

include/linux/restart_block.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct restart_block {
3232
u32 val;
3333
u32 flags;
3434
u32 bitset;
35-
u64 time;
35+
ktime_t time;
3636
u32 __user *uaddr2;
3737
} futex;
3838
/* For nanosleep */

kernel/futex/waitwake.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -738,12 +738,11 @@ int futex_wait(u32 __user *uaddr, unsigned int flags, u32 val, ktime_t *abs_time
738738
static long futex_wait_restart(struct restart_block *restart)
739739
{
740740
u32 __user *uaddr = restart->futex.uaddr;
741-
ktime_t t, *tp = NULL;
741+
ktime_t *tp = NULL;
742+
743+
if (restart->futex.flags & FLAGS_HAS_TIMEOUT)
744+
tp = &restart->futex.time;
742745

743-
if (restart->futex.flags & FLAGS_HAS_TIMEOUT) {
744-
t = restart->futex.time;
745-
tp = &t;
746-
}
747746
restart->fn = do_no_restart_syscall;
748747

749748
return (long)futex_wait(uaddr, restart->futex.flags,

tools/testing/selftests/futex/functional/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ futex_wait_uninitialized_heap
1212
futex_wait_wouldblock
1313
futex_waitv
1414
futex_numa
15+
robust_list

tools/testing/selftests/futex/functional/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ TEST_GEN_PROGS := \
2222
futex_priv_hash \
2323
futex_numa_mpol \
2424
futex_waitv \
25-
futex_numa
25+
futex_numa \
26+
robust_list
2627

2728
TEST_PROGS := run.sh
2829

tools/testing/selftests/futex/functional/futex_numa_mpol.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,6 @@ static void test_futex(void *futex_ptr, int err_value)
131131
__test_futex(futex_ptr, err_value, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG | FUTEX2_NUMA);
132132
}
133133

134-
static void test_futex_mpol(void *futex_ptr, int err_value)
135-
{
136-
__test_futex(futex_ptr, err_value, FUTEX2_SIZE_U32 | FUTEX_PRIVATE_FLAG | FUTEX2_NUMA | FUTEX2_MPOL);
137-
}
138-
139134
TEST(futex_numa_mpol)
140135
{
141136
struct futex32_numa *futex_numa;

tools/testing/selftests/futex/functional/futex_wait.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ TEST(anon_page)
7171
/* Testing an anon page shared memory */
7272
shm_id = shmget(IPC_PRIVATE, 4096, IPC_CREAT | 0666);
7373
if (shm_id < 0) {
74+
if (errno == ENOSYS)
75+
ksft_exit_skip("shmget syscall not supported\n");
7476
perror("shmget");
7577
exit(1);
7678
}
@@ -108,14 +110,14 @@ TEST(file_backed)
108110
/* Testing a file backed shared memory */
109111
fd = open(SHM_PATH, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
110112
if (fd < 0)
111-
ksft_exit_fail_msg("open");
113+
ksft_exit_fail_msg("open\n");
112114

113115
if (ftruncate(fd, sizeof(f_private)))
114-
ksft_exit_fail_msg("ftruncate");
116+
ksft_exit_fail_msg("ftruncate\n");
115117

116118
shm = mmap(NULL, sizeof(f_private), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
117119
if (shm == MAP_FAILED)
118-
ksft_exit_fail_msg("mmap");
120+
ksft_exit_fail_msg("mmap\n");
119121

120122
memcpy(shm, &f_private, sizeof(f_private));
121123

tools/testing/selftests/futex/functional/futex_waitv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ TEST(shared_waitv)
8686
int shm_id = shmget(IPC_PRIVATE, 4096, IPC_CREAT | 0666);
8787

8888
if (shm_id < 0) {
89+
if (errno == ENOSYS)
90+
ksft_exit_skip("shmget syscall not supported\n");
8991
perror("shmget");
9092
exit(1);
9193
}

0 commit comments

Comments
 (0)