linux(4): Handle FUTEX_LOCK_PI2 oeration.

FUTEX_LOCK_PI2 was added to support clock selection as FUTEX_LOCK_PI uses a
CLOCK_REALTIME based absolute value since it was implemented, but it does not
require that the FUTEX_CLOCK_REALTIME bit is set, because that was introduced
later.

MFC after:		2 weeks
This commit is contained in:
Dmitry Chagin 2021-07-29 12:55:02 +03:00
parent bd25bf092a
commit a9bb1b1c18
2 changed files with 7 additions and 1 deletions

View File

@ -288,6 +288,9 @@ linux_futex(struct thread *td, struct linux_futex_args *args)
case LINUX_FUTEX_LOCK_PI:
args->clockrt = true;
/* FALLTHROUGH */
case LINUX_FUTEX_LOCK_PI2:
LINUX_CTR2(sys_futex, "LOCKPI uaddr %p val 0x%x",
args->uaddr, args->val);
@ -789,7 +792,7 @@ linux_umtx_abs_timeout_init(struct umtx_abs_timeout *timo,
/*
* The FUTEX_CLOCK_REALTIME option bit can be employed only with the
* FUTEX_WAIT_BITSET, FUTEX_WAIT_REQUEUE_PI.
* FUTEX_WAIT_BITSET, FUTEX_WAIT_REQUEUE_PI, FUTEX_LOCK_PI2.
* For FUTEX_WAIT, timeout is interpreted as a relative value, for other
* futex operations timeout is interpreted as an absolute value.
* If FUTEX_CLOCK_REALTIME option bit is set, the Linux kernel measures
@ -820,6 +823,7 @@ linux_sys_futex(struct thread *td, struct linux_sys_futex_args *args)
case LINUX_FUTEX_WAIT:
case LINUX_FUTEX_WAIT_BITSET:
case LINUX_FUTEX_LOCK_PI:
case LINUX_FUTEX_LOCK_PI2:
if (args->timeout != NULL) {
error = copyin(args->timeout, &lts, sizeof(lts));
if (error != 0)
@ -857,6 +861,7 @@ linux_sys_futex_time64(struct thread *td,
case LINUX_FUTEX_WAIT:
case LINUX_FUTEX_WAIT_BITSET:
case LINUX_FUTEX_LOCK_PI:
case LINUX_FUTEX_LOCK_PI2:
if (args->timeout != NULL) {
error = copyin(args->timeout, &lts, sizeof(lts));
if (error != 0)

View File

@ -51,6 +51,7 @@
#define LINUX_FUTEX_WAKE_BITSET 10
#define LINUX_FUTEX_WAIT_REQUEUE_PI 11
#define LINUX_FUTEX_CMP_REQUEUE_PI 12
#define LINUX_FUTEX_LOCK_PI2 13
#define LINUX_FUTEX_PRIVATE_FLAG 128
#define LINUX_FUTEX_CLOCK_REALTIME 256