Skip to content

Commit b3212fe

Browse files
KAGA-KOKOPeter Zijlstra
authored andcommitted
sched/swait: Prepare usage in completions
As a preparation to use simple wait queues for completions: - Provide swake_up_all_locked() to support complete_all() - Make __prepare_to_swait() public available This is done to enable the usage of complete() within truly atomic contexts on a PREEMPT_RT enabled kernel. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20200321113242.228481202@linutronix.de
1 parent e5d4d17 commit b3212fe

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

kernel/sched/sched.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,3 +2492,6 @@ static inline bool is_per_cpu_kthread(struct task_struct *p)
24922492
return true;
24932493
}
24942494
#endif
2495+
2496+
void swake_up_all_locked(struct swait_queue_head *q);
2497+
void __prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait);

kernel/sched/swait.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ void swake_up_locked(struct swait_queue_head *q)
3232
}
3333
EXPORT_SYMBOL(swake_up_locked);
3434

35+
/*
36+
* Wake up all waiters. This is an interface which is solely exposed for
37+
* completions and not for general usage.
38+
*
39+
* It is intentionally different from swake_up_all() to allow usage from
40+
* hard interrupt context and interrupt disabled regions.
41+
*/
42+
void swake_up_all_locked(struct swait_queue_head *q)
43+
{
44+
while (!list_empty(&q->task_list))
45+
swake_up_locked(q);
46+
}
47+
3548
void swake_up_one(struct swait_queue_head *q)
3649
{
3750
unsigned long flags;
@@ -69,7 +82,7 @@ void swake_up_all(struct swait_queue_head *q)
6982
}
7083
EXPORT_SYMBOL(swake_up_all);
7184

72-
static void __prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait)
85+
void __prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait)
7386
{
7487
wait->task = current;
7588
if (list_empty(&wait->task_list))

0 commit comments

Comments
 (0)