In preparation for having another waker that isn't futex_wake_mark(), add a wake handler in futex_q and rename the futex_q->task field to just be wake_data. futex_wake_mark() is defined as the standard wakeup helper. Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> --- kernel/futex/core.c | 2 +- kernel/futex/futex.h | 3 ++- kernel/futex/requeue.c | 7 ++++--- kernel/futex/waitwake.c | 8 ++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/futex/core.c b/kernel/futex/core.c index 514e4582b863..6223cce3d876 100644 --- a/kernel/futex/core.c +++ b/kernel/futex/core.c @@ -556,7 +556,7 @@ void __futex_queue(struct futex_q *q, struct futex_hash_bucket *hb) plist_node_init(&q->list, prio); plist_add(&q->list, &hb->chain); - q->task = current; + q->wake_data = current; } /** diff --git a/kernel/futex/futex.h b/kernel/futex/futex.h index d2949fca37d1..1b7dd5266dd2 100644 --- a/kernel/futex/futex.h +++ b/kernel/futex/futex.h @@ -96,7 +96,6 @@ struct futex_pi_state { struct futex_q { struct plist_node list; - struct task_struct *task; spinlock_t *lock_ptr; union futex_key key; struct futex_pi_state *pi_state; @@ -107,6 +106,8 @@ struct futex_q { #ifdef CONFIG_PREEMPT_RT struct rcuwait requeue_wait; #endif + void (*wake)(struct wake_q_head *wake_q, struct futex_q *); + void *wake_data; } __randomize_layout; extern const struct futex_q futex_q_init; diff --git a/kernel/futex/requeue.c b/kernel/futex/requeue.c index cba8b1a6a4cc..6aee8408c341 100644 --- a/kernel/futex/requeue.c +++ b/kernel/futex/requeue.c @@ -61,6 +61,7 @@ const struct futex_q futex_q_init = { .key = FUTEX_KEY_INIT, .bitset = FUTEX_BITSET_MATCH_ANY, .requeue_state = ATOMIC_INIT(Q_REQUEUE_PI_NONE), + .wake = futex_wake_mark, }; /** @@ -234,7 +235,7 @@ void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key, /* Signal locked state to the waiter */ futex_requeue_pi_complete(q, 1); - wake_up_state(q->task, TASK_NORMAL); + wake_up_state(q->wake_data, TASK_NORMAL); } /** @@ -316,7 +317,7 @@ futex_proxy_trylock_atomic(u32 __user *pifutex, struct futex_hash_bucket *hb1, * the user space lock can be acquired then PI state is attached to * the new owner (@top_waiter->task) when @set_waiters is true. */ - ret = futex_lock_pi_atomic(pifutex, hb2, key2, ps, top_waiter->task, + ret = futex_lock_pi_atomic(pifutex, hb2, key2, ps, top_waiter->wake_data, exiting, set_waiters); if (ret == 1) { /* @@ -626,7 +627,7 @@ int futex_requeue(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2, ret = rt_mutex_start_proxy_lock(&pi_state->pi_mutex, this->rt_waiter, - this->task); + this->wake_data); if (ret == 1) { /* diff --git a/kernel/futex/waitwake.c b/kernel/futex/waitwake.c index ba01b9408203..5151c83e2db8 100644 --- a/kernel/futex/waitwake.c +++ b/kernel/futex/waitwake.c @@ -114,7 +114,7 @@ */ void futex_wake_mark(struct wake_q_head *wake_q, struct futex_q *q) { - struct task_struct *p = q->task; + struct task_struct *p = q->wake_data; if (WARN(q->pi_state || q->rt_waiter, "refusing to wake PI futex\n")) return; @@ -174,7 +174,7 @@ int futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset) if (!(this->bitset & bitset)) continue; - futex_wake_mark(&wake_q, this); + this->wake(&wake_q, this); if (++ret >= nr_wake) break; } @@ -289,7 +289,7 @@ int futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2, ret = -EINVAL; goto out_unlock; } - futex_wake_mark(&wake_q, this); + this->wake(&wake_q, this); if (++ret >= nr_wake) break; } @@ -303,7 +303,7 @@ int futex_wake_op(u32 __user *uaddr1, unsigned int flags, u32 __user *uaddr2, ret = -EINVAL; goto out_unlock; } - futex_wake_mark(&wake_q, this); + this->wake(&wake_q, this); if (++op_ret >= nr_wake2) break; } -- 2.39.2