Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched/headers: Move the wake-queue types and interfaces from sched.h into <linux/sched/wake_q.h>

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

+51 -51
+4 -50
include/linux/sched.h
··· 953 953 # define SCHED_FIXEDPOINT_SHIFT 10 954 954 # define SCHED_FIXEDPOINT_SCALE (1L << SCHED_FIXEDPOINT_SHIFT) 955 955 956 - /* 957 - * Wake-queues are lists of tasks with a pending wakeup, whose 958 - * callers have already marked the task as woken internally, 959 - * and can thus carry on. A common use case is being able to 960 - * do the wakeups once the corresponding user lock as been 961 - * released. 962 - * 963 - * We hold reference to each task in the list across the wakeup, 964 - * thus guaranteeing that the memory is still valid by the time 965 - * the actual wakeups are performed in wake_up_q(). 966 - * 967 - * One per task suffices, because there's never a need for a task to be 968 - * in two wake queues simultaneously; it is forbidden to abandon a task 969 - * in a wake queue (a call to wake_up_q() _must_ follow), so if a task is 970 - * already in a wake queue, the wakeup will happen soon and the second 971 - * waker can just skip it. 972 - * 973 - * The DEFINE_WAKE_Q macro declares and initializes the list head. 974 - * wake_up_q() does NOT reinitialize the list; it's expected to be 975 - * called near the end of a function. Otherwise, the list can be 976 - * re-initialized for later re-use by wake_q_init(). 977 - * 978 - * Note that this can cause spurious wakeups. schedule() callers 979 - * must ensure the call is done inside a loop, confirming that the 980 - * wakeup condition has in fact occurred. 981 - */ 982 - struct wake_q_node { 983 - struct wake_q_node *next; 984 - }; 985 - 986 - struct wake_q_head { 987 - struct wake_q_node *first; 988 - struct wake_q_node **lastp; 989 - }; 990 - 991 - #define WAKE_Q_TAIL ((struct wake_q_node *) 0x01) 992 - 993 - #define DEFINE_WAKE_Q(name) \ 994 - struct wake_q_head name = { WAKE_Q_TAIL, &name.first } 995 - 996 - static inline void wake_q_init(struct wake_q_head *head) 997 - { 998 - head->first = WAKE_Q_TAIL; 999 - head->lastp = &head->first; 1000 - } 1001 - 1002 - extern void wake_q_add(struct wake_q_head *head, 1003 - struct task_struct *task); 1004 - extern void wake_up_q(struct wake_q_head *head); 1005 - 1006 956 struct io_context; /* See blkdev.h */ 1007 957 1008 958 ··· 1182 1232 perf_hw_context = 0, 1183 1233 perf_sw_context, 1184 1234 perf_nr_task_contexts, 1235 + }; 1236 + 1237 + struct wake_q_node { 1238 + struct wake_q_node *next; 1185 1239 }; 1186 1240 1187 1241 /* Track pages that require TLB flushes */
+47
include/linux/sched/wake_q.h
··· 1 1 #ifndef _LINUX_SCHED_WAKE_Q_H 2 2 #define _LINUX_SCHED_WAKE_Q_H 3 3 4 + /* 5 + * Wake-queues are lists of tasks with a pending wakeup, whose 6 + * callers have already marked the task as woken internally, 7 + * and can thus carry on. A common use case is being able to 8 + * do the wakeups once the corresponding user lock as been 9 + * released. 10 + * 11 + * We hold reference to each task in the list across the wakeup, 12 + * thus guaranteeing that the memory is still valid by the time 13 + * the actual wakeups are performed in wake_up_q(). 14 + * 15 + * One per task suffices, because there's never a need for a task to be 16 + * in two wake queues simultaneously; it is forbidden to abandon a task 17 + * in a wake queue (a call to wake_up_q() _must_ follow), so if a task is 18 + * already in a wake queue, the wakeup will happen soon and the second 19 + * waker can just skip it. 20 + * 21 + * The DEFINE_WAKE_Q macro declares and initializes the list head. 22 + * wake_up_q() does NOT reinitialize the list; it's expected to be 23 + * called near the end of a function. Otherwise, the list can be 24 + * re-initialized for later re-use by wake_q_init(). 25 + * 26 + * Note that this can cause spurious wakeups. schedule() callers 27 + * must ensure the call is done inside a loop, confirming that the 28 + * wakeup condition has in fact occurred. 29 + */ 30 + 4 31 #include <linux/sched.h> 32 + 33 + struct wake_q_head { 34 + struct wake_q_node *first; 35 + struct wake_q_node **lastp; 36 + }; 37 + 38 + #define WAKE_Q_TAIL ((struct wake_q_node *) 0x01) 39 + 40 + #define DEFINE_WAKE_Q(name) \ 41 + struct wake_q_head name = { WAKE_Q_TAIL, &name.first } 42 + 43 + static inline void wake_q_init(struct wake_q_head *head) 44 + { 45 + head->first = WAKE_Q_TAIL; 46 + head->lastp = &head->first; 47 + } 48 + 49 + extern void wake_q_add(struct wake_q_head *head, 50 + struct task_struct *task); 51 + extern void wake_up_q(struct wake_q_head *head); 5 52 6 53 #endif /* _LINUX_SCHED_WAKE_Q_H */
-1
ipc/msg.c
··· 30 30 #include <linux/proc_fs.h> 31 31 #include <linux/list.h> 32 32 #include <linux/security.h> 33 - #include <linux/sched.h> 34 33 #include <linux/sched/wake_q.h> 35 34 #include <linux/syscalls.h> 36 35 #include <linux/audit.h>