Skip to content

Commit 9f6c532

Browse files
futex: Add sys_futex_wake()
To complement sys_futex_waitv() add sys_futex_wake(). This syscall implements what was previously known as FUTEX_WAKE_BITSET except it uses 'unsigned long' for the bitmask and takes FUTEX2 flags. The 'unsigned long' allows FUTEX2_SIZE_U64 on 64bit platforms. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Acked-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 698eb82 commit 9f6c532

File tree

22 files changed

+56
-2
lines changed

22 files changed

+56
-2
lines changed

arch/alpha/kernel/syscalls/syscall.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -492,3 +492,4 @@
492492
560 common set_mempolicy_home_node sys_ni_syscall
493493
561 common cachestat sys_cachestat
494494
562 common fchmodat2 sys_fchmodat2
495+
563 common futex_wake sys_futex_wake

arch/arm/tools/syscall.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -466,3 +466,4 @@
466466
450 common set_mempolicy_home_node sys_set_mempolicy_home_node
467467
451 common cachestat sys_cachestat
468468
452 common fchmodat2 sys_fchmodat2
469+
454 common futex_wake sys_futex_wake

arch/arm64/include/asm/unistd.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5)
4040
#define __ARM_NR_COMPAT_END (__ARM_NR_COMPAT_BASE + 0x800)
4141

42-
#define __NR_compat_syscalls 453
42+
#define __NR_compat_syscalls 455
4343
#endif
4444

4545
#define __ARCH_WANT_SYS_CLONE

arch/arm64/include/asm/unistd32.h

+2
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,8 @@ __SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node)
911911
__SYSCALL(__NR_cachestat, sys_cachestat)
912912
#define __NR_fchmodat2 452
913913
__SYSCALL(__NR_fchmodat2, sys_fchmodat2)
914+
#define __NR_futex_wake 454
915+
__SYSCALL(__NR_futex_wake, sys_futex_wake)
914916

915917
/*
916918
* Please add new compat syscalls above this comment and update

arch/ia64/kernel/syscalls/syscall.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,4 @@
373373
450 common set_mempolicy_home_node sys_set_mempolicy_home_node
374374
451 common cachestat sys_cachestat
375375
452 common fchmodat2 sys_fchmodat2
376+
454 common futex_wake sys_futex_wake

arch/m68k/kernel/syscalls/syscall.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,4 @@
452452
450 common set_mempolicy_home_node sys_set_mempolicy_home_node
453453
451 common cachestat sys_cachestat
454454
452 common fchmodat2 sys_fchmodat2
455+
454 common futex_wake sys_futex_wake

arch/microblaze/kernel/syscalls/syscall.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -458,3 +458,4 @@
458458
450 common set_mempolicy_home_node sys_set_mempolicy_home_node
459459
451 common cachestat sys_cachestat
460460
452 common fchmodat2 sys_fchmodat2
461+
454 common futex_wake sys_futex_wake

arch/mips/kernel/syscalls/syscall_n32.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,4 @@
391391
450 n32 set_mempolicy_home_node sys_set_mempolicy_home_node
392392
451 n32 cachestat sys_cachestat
393393
452 n32 fchmodat2 sys_fchmodat2
394+
454 n32 futex_wake sys_futex_wake

arch/mips/kernel/syscalls/syscall_n64.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,4 @@
367367
450 common set_mempolicy_home_node sys_set_mempolicy_home_node
368368
451 n64 cachestat sys_cachestat
369369
452 n64 fchmodat2 sys_fchmodat2
370+
454 n64 futex_wake sys_futex_wake

arch/mips/kernel/syscalls/syscall_o32.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -440,3 +440,4 @@
440440
450 o32 set_mempolicy_home_node sys_set_mempolicy_home_node
441441
451 o32 cachestat sys_cachestat
442442
452 o32 fchmodat2 sys_fchmodat2
443+
454 o32 futex_wake sys_futex_wake

arch/parisc/kernel/syscalls/syscall.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -451,3 +451,4 @@
451451
450 common set_mempolicy_home_node sys_set_mempolicy_home_node
452452
451 common cachestat sys_cachestat
453453
452 common fchmodat2 sys_fchmodat2
454+
454 common futex_wake sys_futex_wake

arch/powerpc/kernel/syscalls/syscall.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -539,3 +539,4 @@
539539
450 nospu set_mempolicy_home_node sys_set_mempolicy_home_node
540540
451 common cachestat sys_cachestat
541541
452 common fchmodat2 sys_fchmodat2
542+
454 common futex_wake sys_futex_wake

arch/s390/kernel/syscalls/syscall.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,4 @@
455455
450 common set_mempolicy_home_node sys_set_mempolicy_home_node sys_set_mempolicy_home_node
456456
451 common cachestat sys_cachestat sys_cachestat
457457
452 common fchmodat2 sys_fchmodat2 sys_fchmodat2
458+
454 common futex_wake sys_futex_wake sys_futex_wake

arch/sh/kernel/syscalls/syscall.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,4 @@
455455
450 common set_mempolicy_home_node sys_set_mempolicy_home_node
456456
451 common cachestat sys_cachestat
457457
452 common fchmodat2 sys_fchmodat2
458+
454 common futex_wake sys_futex_wake

arch/sparc/kernel/syscalls/syscall.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -498,3 +498,4 @@
498498
450 common set_mempolicy_home_node sys_set_mempolicy_home_node
499499
451 common cachestat sys_cachestat
500500
452 common fchmodat2 sys_fchmodat2
501+
454 common futex_wake sys_futex_wake

arch/x86/entry/syscalls/syscall_32.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,4 @@
457457
450 i386 set_mempolicy_home_node sys_set_mempolicy_home_node
458458
451 i386 cachestat sys_cachestat
459459
452 i386 fchmodat2 sys_fchmodat2
460+
454 i386 futex_wake sys_futex_wake

arch/x86/entry/syscalls/syscall_64.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@
375375
451 common cachestat sys_cachestat
376376
452 common fchmodat2 sys_fchmodat2
377377
453 64 map_shadow_stack sys_map_shadow_stack
378+
454 common futex_wake sys_futex_wake
378379

379380
#
380381
# Due to a historical design error, certain syscalls are numbered differently

arch/xtensa/kernel/syscalls/syscall.tbl

+1
Original file line numberDiff line numberDiff line change
@@ -423,3 +423,4 @@
423423
450 common set_mempolicy_home_node sys_set_mempolicy_home_node
424424
451 common cachestat sys_cachestat
425425
452 common fchmodat2 sys_fchmodat2
426+
454 common futex_wake sys_futex_wake

include/linux/syscalls.h

+3
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,9 @@ asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,
549549
asmlinkage long sys_futex_waitv(struct futex_waitv *waiters,
550550
unsigned int nr_futexes, unsigned int flags,
551551
struct __kernel_timespec __user *timeout, clockid_t clockid);
552+
553+
asmlinkage long sys_futex_wake(void __user *uaddr, unsigned long mask, int nr, unsigned int flags);
554+
552555
asmlinkage long sys_nanosleep(struct __kernel_timespec __user *rqtp,
553556
struct __kernel_timespec __user *rmtp);
554557
asmlinkage long sys_nanosleep_time32(struct old_timespec32 __user *rqtp,

include/uapi/asm-generic/unistd.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -822,9 +822,11 @@ __SYSCALL(__NR_cachestat, sys_cachestat)
822822

823823
#define __NR_fchmodat2 452
824824
__SYSCALL(__NR_fchmodat2, sys_fchmodat2)
825+
#define __NR_futex_wake 454
826+
__SYSCALL(__NR_futex_wake, sys_futex_wake)
825827

826828
#undef __NR_syscalls
827-
#define __NR_syscalls 453
829+
#define __NR_syscalls 455
828830

829831
/*
830832
* 32 bit systems traditionally used different

kernel/futex/syscalls.c

+30
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,36 @@ SYSCALL_DEFINE5(futex_waitv, struct futex_waitv __user *, waiters,
306306
return ret;
307307
}
308308

309+
/*
310+
* sys_futex_wake - Wake a number of futexes
311+
* @uaddr: Address of the futex(es) to wake
312+
* @mask: bitmask
313+
* @nr: Number of the futexes to wake
314+
* @flags: FUTEX2 flags
315+
*
316+
* Identical to the traditional FUTEX_WAKE_BITSET op, except it is part of the
317+
* futex2 family of calls.
318+
*/
319+
320+
SYSCALL_DEFINE4(futex_wake,
321+
void __user *, uaddr,
322+
unsigned long, mask,
323+
int, nr,
324+
unsigned int, flags)
325+
{
326+
if (flags & ~FUTEX2_VALID_MASK)
327+
return -EINVAL;
328+
329+
flags = futex2_to_flags(flags);
330+
if (!futex_flags_valid(flags))
331+
return -EINVAL;
332+
333+
if (!futex_validate_input(flags, mask))
334+
return -EINVAL;
335+
336+
return futex_wake(uaddr, flags, nr, mask);
337+
}
338+
309339
#ifdef CONFIG_COMPAT
310340
COMPAT_SYSCALL_DEFINE2(set_robust_list,
311341
struct compat_robust_list_head __user *, head,

kernel/sys_ni.c

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ COND_SYSCALL_COMPAT(set_robust_list);
8787
COND_SYSCALL(get_robust_list);
8888
COND_SYSCALL_COMPAT(get_robust_list);
8989
COND_SYSCALL(futex_waitv);
90+
COND_SYSCALL(futex_wake);
9091
COND_SYSCALL(kexec_load);
9192
COND_SYSCALL_COMPAT(kexec_load);
9293
COND_SYSCALL(init_module);

0 commit comments

Comments
 (0)