]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/rcuwait.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_RCUWAIT_H_
3 #define _LINUX_RCUWAIT_H_
5 #include <linux/rcupdate.h>
8 * rcuwait provides a way of blocking and waking up a single
9 * task in an rcu-safe manner; where it is forbidden to use
10 * after exit_notify(). task_struct is not properly rcu protected,
11 * unless dealing with rcu-aware lists, ie: find_task_by_*().
13 * Alternatively we have task_rcu_dereference(), but the return
14 * semantics have different implications which would break the
15 * wakeup side. The only time @task is non-nil is when a user is
16 * blocked (or checking if it needs to) on a condition, and reset
17 * as soon as we know that the condition has succeeded and are
21 struct task_struct
*task
;
24 #define __RCUWAIT_INITIALIZER(name) \
27 static inline void rcuwait_init(struct rcuwait
*w
)
32 extern void rcuwait_wake_up(struct rcuwait
*w
);
35 * The caller is responsible for locking around rcuwait_wait_event(),
36 * such that writes to @task are properly serialized.
38 #define rcuwait_wait_event(w, condition) \
41 * Complain if we are called after do_exit()/exit_notify(), \
42 * as we cannot rely on the rcu critical region for the \
45 WARN_ON(current->exit_state); \
47 rcu_assign_pointer((w)->task, current); \
50 * Implicit barrier (A) pairs with (B) in \
51 * rcuwait_wake_up(). \
53 set_current_state(TASK_UNINTERRUPTIBLE); \
60 WRITE_ONCE((w)->task, NULL); \
61 __set_current_state(TASK_RUNNING); \
64 #endif /* _LINUX_RCUWAIT_H_ */