History

futex: Mark the begin of futex exit explicitly

Instead of relying on PF_EXITING use an explicit state for the futex exit and set it in the futex exit function. This moves the smp barrier and the lock/unlock serialization into the futex code. As with the DEAD state this is restricted to the exit path as exec continues to use the same task struct. This allows to simplify that logic in a next step.

Thomas Gleixner committed 7 years ago

Commit 18f69431 parent f24f2243 files · +40 −41Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/futex.h+3−28
@@ -52,6 +52,7 @@ union futex_key { · 51 unmodified lines
52#ifdef CONFIG_FUTEX52#ifdef CONFIG_FUTEX
53enum {53enum {
54 FUTEX_STATE_OK,54 FUTEX_STATE_OK,
55 FUTEX_STATE_EXITING,
55 FUTEX_STATE_DEAD,56 FUTEX_STATE_DEAD,
56};57};
57 58
@@ -66,33 +67,7 @@ static inline void futex_init_task(struct task_struct *tsk) · 8 unmodified lines
66 tsk->futex_state = FUTEX_STATE_OK;67 tsk->futex_state = FUTEX_STATE_OK;
67}68}
68 69
69/**70void futex_exit_recursive(struct task_struct *tsk);
70 * futex_exit_done - Sets the tasks futex state to FUTEX_STATE_DEAD
71 * @tsk: task to set the state on
72 *
73 * Set the futex exit state of the task lockless. The futex waiter code
74 * observes that state when a task is exiting and loops until the task has
75 * actually finished the futex cleanup. The worst case for this is that the
76 * waiter runs through the wait loop until the state becomes visible.
77 *
78 * This has two callers:
79 *
80 * - futex_mm_release() after the futex exit cleanup has been done
81 *
82 * - do_exit() from the recursive fault handling path.
83 *
84 * In case of a recursive fault this is best effort. Either the futex exit
85 * code has run already or not. If the OWNER_DIED bit has been set on the
86 * futex then the waiter can take it over. If not, the problem is pushed
87 * back to user space. If the futex exit code did not run yet, then an
88 * already queued waiter might block forever, but there is nothing which
89 * can be done about that.
90 */
91static inline void futex_exit_done(struct task_struct *tsk)
92{
93 tsk->futex_state = FUTEX_STATE_DEAD;
94}
95
96void futex_exit_release(struct task_struct *tsk);71void futex_exit_release(struct task_struct *tsk);
97void futex_exec_release(struct task_struct *tsk);72void futex_exec_release(struct task_struct *tsk);
98 73
@@ -100,7 +75,7 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, · 1 unmodified line
100 u32 __user *uaddr2, u32 val2, u32 val3);75 u32 __user *uaddr2, u32 val2, u32 val3);
101#else76#else
102static inline void futex_init_task(struct task_struct *tsk) { }77static inline void futex_init_task(struct task_struct *tsk) { }
103static inline void futex_exit_done(struct task_struct *tsk) { }78static inline void futex_exit_recursive(struct task_struct *tsk) { }
104static inline void futex_exit_release(struct task_struct *tsk) { }79static inline void futex_exit_release(struct task_struct *tsk) { }
105static inline void futex_exec_release(struct task_struct *tsk) { }80static inline void futex_exec_release(struct task_struct *tsk) { }
106static inline long do_futex(u32 __user *uaddr, int op, u32 val,81static inline long do_futex(u32 __user *uaddr, int op, u32 val,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t