forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sched/headers: Move the wake-queue types and interfaces from sched.h …
…into <linux/sched/wake_q.h> Acked-by: Linus Torvalds <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>
- Loading branch information
Ingo Molnar
committed
Mar 2, 2017
1 parent
5dbe91d
commit eb61baf
Showing
3 changed files
with
51 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,53 @@ | ||
#ifndef _LINUX_SCHED_WAKE_Q_H | ||
#define _LINUX_SCHED_WAKE_Q_H | ||
|
||
/* | ||
* Wake-queues are lists of tasks with a pending wakeup, whose | ||
* callers have already marked the task as woken internally, | ||
* and can thus carry on. A common use case is being able to | ||
* do the wakeups once the corresponding user lock as been | ||
* released. | ||
* | ||
* We hold reference to each task in the list across the wakeup, | ||
* thus guaranteeing that the memory is still valid by the time | ||
* the actual wakeups are performed in wake_up_q(). | ||
* | ||
* One per task suffices, because there's never a need for a task to be | ||
* in two wake queues simultaneously; it is forbidden to abandon a task | ||
* in a wake queue (a call to wake_up_q() _must_ follow), so if a task is | ||
* already in a wake queue, the wakeup will happen soon and the second | ||
* waker can just skip it. | ||
* | ||
* The DEFINE_WAKE_Q macro declares and initializes the list head. | ||
* wake_up_q() does NOT reinitialize the list; it's expected to be | ||
* called near the end of a function. Otherwise, the list can be | ||
* re-initialized for later re-use by wake_q_init(). | ||
* | ||
* Note that this can cause spurious wakeups. schedule() callers | ||
* must ensure the call is done inside a loop, confirming that the | ||
* wakeup condition has in fact occurred. | ||
*/ | ||
|
||
#include <linux/sched.h> | ||
|
||
struct wake_q_head { | ||
struct wake_q_node *first; | ||
struct wake_q_node **lastp; | ||
}; | ||
|
||
#define WAKE_Q_TAIL ((struct wake_q_node *) 0x01) | ||
|
||
#define DEFINE_WAKE_Q(name) \ | ||
struct wake_q_head name = { WAKE_Q_TAIL, &name.first } | ||
|
||
static inline void wake_q_init(struct wake_q_head *head) | ||
{ | ||
head->first = WAKE_Q_TAIL; | ||
head->lastp = &head->first; | ||
} | ||
|
||
extern void wake_q_add(struct wake_q_head *head, | ||
struct task_struct *task); | ||
extern void wake_up_q(struct wake_q_head *head); | ||
|
||
#endif /* _LINUX_SCHED_WAKE_Q_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters