wait-simple stuff
Peter Zijlstra
maintainerHi guys,
Would something like the below break something?
Quoted 1 line
From a quick read things seems fine for both the simple-waitqueue as the
completions.
Without that lockbreak in I can't see how the kernel would still be deterministic as you can pile as many tasks as you want on these waitqueues.
--- kernel/sched/core.c | 4 ++-- kernel/wait-simple.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-)
kernel/sched/core.c +2 -2
@@ -3496,7 +3496,7 @@ void complete(struct completion *x)raw_spin_lock_irqsave (&x->wait.lock, flags); x->done++; -__swait_wake_locked (&x->wait,TASK_NORMAL ,1 ); +__swait_wake_locked (&x->wait,TASK_NORMAL ,1 , &flags);raw_spin_unlock_irqrestore (&x->wait.lock, flags); }EXPORT_SYMBOL (complete);
@@ -3516,7 +3516,7 @@ void complete_all(struct completion *x)raw_spin_lock_irqsave (&x->wait.lock, flags); x->done +=UINT_MAX /2 ; -__swait_wake_locked (&x->wait,TASK_NORMAL ,0 ); +__swait_wake_locked (&x->wait,TASK_NORMAL ,0 , &flags);raw_spin_unlock_irqrestore (&x->wait.lock, flags); }EXPORT_SYMBOL (complete_all);
kernel/wait-simple.c +9 -3
@@ -73,12 +73,13 @@ void swait_finish(struct swait_head *head, struct swaiter *w)EXPORT_SYMBOL (swait_finish);unsigned int -__swait_wake_locked (struct swait_head *head,unsigned int state,unsigned int num) +__swait_wake_locked (struct swait_head *head,unsigned int state, +unsigned int num,unsigned long *flags) { -struct swaiter *curr, *next; +struct swaiter *curr;int woken =0 ; -list_for_each_entry_safe (curr, next, &head->list, node) { + while ((curr = list_first_entry_or_null(&head->list, struct swaiter, node))) {if (wake_up_state (curr->task, state)) {__swait_dequeue (curr);/*
@@ -94,6 +95,11 @@ __swait_wake_locked(struct swait_head *head, unsigned int state, unsigned int nuif (++woken == num)break ; } + +if (need_resched ()) { +raw_spin_unlock_irqrestore (&head->lock, *flags); +raw_spin_lock_irqsave (&head->lock, *flags); + } }return woken; }