]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/futex.h
1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/sched.h>
6 #include <linux/ktime.h>
8 #include <uapi/linux/futex.h>
14 long do_futex(u32 __user
*uaddr
, int op
, u32 val
, ktime_t
*timeout
,
15 u32 __user
*uaddr2
, u32 val2
, u32 val3
);
18 * Futexes are matched on equal values of this key.
19 * The key type depends on whether it's a shared or private mapping.
20 * Don't rearrange members without looking at hash_futex().
22 * offset is aligned to a multiple of sizeof(u32) (== 4) by definition.
23 * We use the two low order bits of offset to tell what is the kind of key :
24 * 00 : Private process futex (PTHREAD_PROCESS_PRIVATE)
25 * (no reference on an inode or mm)
26 * 01 : Shared futex (PTHREAD_PROCESS_SHARED)
27 * mapped on a file (reference on the underlying inode)
28 * 10 : Shared futex (PTHREAD_PROCESS_SHARED)
29 * (but private mapping on an mm, and reference taken on it)
32 #define FUT_OFF_INODE 1 /* We set bit 0 if key has a reference on inode */
33 #define FUT_OFF_MMSHARED 2 /* We set bit 1 if key has a reference on mm */
42 unsigned long address
;
53 #define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } }
61 static inline void futex_init_task(struct task_struct
*tsk
)
63 tsk
->robust_list
= NULL
;
65 tsk
->compat_robust_list
= NULL
;
67 INIT_LIST_HEAD(&tsk
->pi_state_list
);
68 tsk
->pi_state_cache
= NULL
;
69 tsk
->futex_state
= FUTEX_STATE_OK
;
73 * futex_exit_done - Sets the tasks futex state to FUTEX_STATE_DEAD
74 * @tsk: task to set the state on
76 * Set the futex exit state of the task lockless. The futex waiter code
77 * observes that state when a task is exiting and loops until the task has
78 * actually finished the futex cleanup. The worst case for this is that the
79 * waiter runs through the wait loop until the state becomes visible.
81 * This has two callers:
83 * - futex_mm_release() after the futex exit cleanup has been done
85 * - do_exit() from the recursive fault handling path.
87 * In case of a recursive fault this is best effort. Either the futex exit
88 * code has run already or not. If the OWNER_DIED bit has been set on the
89 * futex then the waiter can take it over. If not, the problem is pushed
90 * back to user space. If the futex exit code did not run yet, then an
91 * already queued waiter might block forever, but there is nothing which
92 * can be done about that.
94 static inline void futex_exit_done(struct task_struct
*tsk
)
96 tsk
->futex_state
= FUTEX_STATE_DEAD
;
99 void futex_mm_release(struct task_struct
*tsk
);
101 long do_futex(u32 __user
*uaddr
, int op
, u32 val
, ktime_t
*timeout
,
102 u32 __user
*uaddr2
, u32 val2
, u32 val3
);
104 static inline void futex_init_task(struct task_struct
*tsk
) { }
105 static inline void futex_mm_release(struct task_struct
*tsk
) { }
106 static inline void futex_exit_done(struct task_struct
*tsk
) { }