lx_emul: add wake_q_add/wake_up_q in shadow impl.

The function within this commit were taken verbatim from the
original Linux implementation.

Ref 
This commit is contained in:
Josef Söntgen 2022-02-04 16:12:48 +01:00 committed by Norman Feske
parent 0f70212139
commit c851b189c5

@ -214,3 +214,41 @@ int get_nohz_timer_target(void)
#endif
#endif
static bool __wake_q_add(struct wake_q_head *head, struct task_struct *task)
{
struct wake_q_node *node = &task->wake_q;
smp_mb__before_atomic();
if (unlikely(cmpxchg_relaxed(&node->next, NULL, WAKE_Q_TAIL)))
return false;
*head->lastp = node;
head->lastp = &node->next;
return true;
}
void wake_q_add(struct wake_q_head *head, struct task_struct *task)
{
if (__wake_q_add(head, task))
get_task_struct(task);
}
void wake_up_q(struct wake_q_head *head)
{
struct wake_q_node *node = head->first;
while (node != WAKE_Q_TAIL) {
struct task_struct *task;
task = container_of(node, struct task_struct, wake_q);
node = node->next;
task->wake_q.next = NULL;
wake_up_process(task);
put_task_struct(task);
}
}