1 #ifndef _LINUX_RCUWAIT_H_
2 #define _LINUX_RCUWAIT_H_
4 #include <linux/rcupdate.h>
7 * rcuwait provides a way of blocking and waking up a single
8 * task in an rcu-safe manner; where it is forbidden to use
9 * after exit_notify(). task_struct is not properly rcu protected,
10 * unless dealing with rcu-aware lists, ie: find_task_by_*().
12 * Alternatively we have task_rcu_dereference(), but the return
13 * semantics have different implications which would break the
14 * wakeup side. The only time @task is non-nil is when a user is
15 * blocked (or checking if it needs to) on a condition, and reset
16 * as soon as we know that the condition has succeeded and are
20 struct task_struct
*task
;
23 #define __RCUWAIT_INITIALIZER(name) \
26 static inline void rcuwait_init(struct rcuwait
*w
)
31 extern void rcuwait_wake_up(struct rcuwait
*w
);
34 * The caller is responsible for locking around rcuwait_wait_event(),
35 * such that writes to @task are properly serialized.
37 #define rcuwait_wait_event(w, condition) \
40 * Complain if we are called after do_exit()/exit_notify(), \
41 * as we cannot rely on the rcu critical region for the \
44 WARN_ON(current->exit_state); \
46 rcu_assign_pointer((w)->task, current); \
49 * Implicit barrier (A) pairs with (B) in \
50 * rcuwait_wake_up(). \
52 set_current_state(TASK_UNINTERRUPTIBLE); \
59 WRITE_ONCE((w)->task, NULL); \
60 __set_current_state(TASK_RUNNING); \
63 #endif /* _LINUX_RCUWAIT_H_ */