@@ -47,6 +47,11 @@ static inline void wake_q_init(struct wake_q_head *head)
head->lastp = &head->first;
}
+static inline bool task_in_wake_q(struct task_struct *task)
+{
+ return READ_ONCE(task->wake_q.next) != NULL;
+}
+
extern void wake_q_add(struct wake_q_head *head,
struct task_struct *task);
extern void wake_up_q(struct wake_q_head *head);
@@ -420,6 +420,7 @@ void wake_q_add(struct wake_q_head *head, struct task_struct *task)
*head->lastp = node;
head->lastp = &node->next;
}
+EXPORT_SYMBOL_GPL(wake_q_add);
void wake_up_q(struct wake_q_head *head)
{
@@ -442,6 +443,7 @@ void wake_up_q(struct wake_q_head *head)
put_task_struct(task);
}
}
+EXPORT_SYMBOL_GPL(wake_up_q);
/*
* resched_curr - mark rq's current task 'to be rescheduled now'.
The use of wake_q_add() and wake_up_q() functions help to do task wakeup without holding lock can help to reduce lock hold time. They should be available to kernel modules as well. A new task_in_wake_q() inline function is also added to check if the given task is in a wake_q. Signed-off-by: Waiman Long <longman@redhat.com> --- include/linux/sched/wake_q.h | 5 +++++ kernel/sched/core.c | 2 ++ 2 files changed, 7 insertions(+)