[PATCH 03/10] sched/headers: Make task_struct::wake_q an opaque pointer

Ingo Molnar
2017-02-08T18:36:07Z

To be able to decouple wake_q functionality from <linux/sched.h> make
the basic task_struct::wake_q pointer an opaque void *.

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/sched.h | 2 +-
kernel/fork.c | 2 +-
kernel/sched/core.c | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 54651e828ac4..255780f95de1 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1725,7 +1725,7 @@ struct task_struct {
/* Protection of the PI data structures: */
raw_spinlock_t pi_lock;

- struct wake_q_node wake_q;
+ void *wake_q;

#ifdef CONFIG_RT_MUTEXES
/* PI waiters blocked on a rt_mutex held by this task */
diff --git a/kernel/fork.c b/kernel/fork.c
index 077ce3b4c0ef..9aa2ca28a76c 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -538,7 +538,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
#endif
tsk->splice_pipe = NULL;
tsk->task_frag.page = NULL;
- tsk->wake_q.next = NULL;
+ tsk->wake_q = NULL;

account_kernel_stack(tsk, 1);

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 675647b0b84b..c4cebf6628de 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -426,7 +426,7 @@ static bool set_nr_if_polling(struct task_struct *p)

void wake_q_add(struct wake_q_head *head, struct task_struct *task)
{
- struct wake_q_node *node = &task->wake_q;
+ struct wake_q_node *node = (void *)&task->wake_q;

/*
* Atomically grab the task, if ->wake_q is !nil already it means
@@ -455,11 +455,11 @@ void wake_up_q(struct wake_q_head *head)
while (node != WAKE_Q_TAIL) {
struct task_struct *task;

- task = container_of(node, struct task_struct, wake_q);
+ task = container_of((void *)node, struct task_struct, wake_q);
BUG_ON(!task);
/* Task can safely be re-inserted now: */
node = node->next;
- task->wake_q.next = NULL;
+ task->wake_q = NULL;

/*
* wake_up_process() implies a wmb() to pair with the queueing
--
2.7.4