Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1332959 > unrolled thread
| Started by | Waiman Long <Waiman.Long@hpe.com> |
|---|---|
| First post | 2016-02-12 18:40 +0100 |
| Last post | 2016-02-13 13:20 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 4/4] sched/fair: Abort wakeup when task is no longer in a sleeping state Waiman Long <Waiman.Long@hpe.com> - 2016-02-12 18:40 +0100
Re: [PATCH v2 4/4] sched/fair: Abort wakeup when task is no longer in a sleeping state Peter Zijlstra <peterz@infradead.org> - 2016-02-12 21:20 +0100
Re: [PATCH v2 4/4] sched/fair: Abort wakeup when task is no longer in a sleeping state Waiman Long <waiman.long@hpe.com> - 2016-02-12 22:40 +0100
Re: [PATCH v2 4/4] sched/fair: Abort wakeup when task is no longer in a sleeping state Peter Zijlstra <peterz@infradead.org> - 2016-02-13 13:20 +0100
| From | Waiman Long <Waiman.Long@hpe.com> |
|---|---|
| Date | 2016-02-12 18:40 +0100 |
| Subject | [PATCH v2 4/4] sched/fair: Abort wakeup when task is no longer in a sleeping state |
| Message-ID | <r1pRg-1EI-15@gated-at.bofh.it> |
When a task prepares to sleep and then aborts it somehow, there is
a small chance that a waker may be spinning on the on_cpu flag of
that task waiting for the flag to turn off before doing the wakeup
operation. It may keep on spinning for a long time until that task
actually sleeps leading to spurious wakeup.
This patch adds code to detect the change in task state and abort
the wakeup operation, when appropriate, to free up the waker's cpu
to do other useful works.
Signed-off-by: Waiman Long <Waiman.Long@hp.com>
---
kernel/sched/core.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7e548bd..e4b6e84 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2075,8 +2075,15 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
*
* This ensures that tasks getting woken will be fully ordered against
* their previous state and preserve Program Order.
+ *
+ * If the owning cpu decides not to sleep after all by changing back
+ * its task state, we can return immediately.
*/
- smp_cond_acquire(!p->on_cpu);
+ smp_cond_acquire(!p->on_cpu || !(p->state & state));
+ if (!(p->state & state)) {
+ success = 0;
+ goto out;
+ }
p->sched_contributes_to_load = !!task_contributes_to_load(p);
p->state = TASK_WAKING;
--
1.7.1
[toc] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2016-02-12 21:20 +0100 |
| Subject | Re: [PATCH v2 4/4] sched/fair: Abort wakeup when task is no longer in a sleeping state |
| Message-ID | <r1sm5-3kI-7@gated-at.bofh.it> |
| In reply to | #1332959 |
On Fri, Feb 12, 2016 at 12:32:15PM -0500, Waiman Long wrote:
> When a task prepares to sleep and then aborts it somehow, there is
> a small chance that a waker may be spinning on the on_cpu flag of
> that task waiting for the flag to turn off before doing the wakeup
> operation. It may keep on spinning for a long time until that task
> actually sleeps leading to spurious wakeup.
>
> This patch adds code to detect the change in task state and abort
> the wakeup operation, when appropriate, to free up the waker's cpu
> to do other useful works.
>
> Signed-off-by: Waiman Long <Waiman.Long@hp.com>
> ---
> kernel/sched/core.c | 9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 7e548bd..e4b6e84 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -2075,8 +2075,15 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
> *
> * This ensures that tasks getting woken will be fully ordered against
> * their previous state and preserve Program Order.
> + *
> + * If the owning cpu decides not to sleep after all by changing back
> + * its task state, we can return immediately.
> */
> - smp_cond_acquire(!p->on_cpu);
> + smp_cond_acquire(!p->on_cpu || !(p->state & state));
> + if (!(p->state & state)) {
> + success = 0;
> + goto out;
> + }
This doesn't make sense, if we managed to get here, p->on_rq must be
false, which means the other side is already in the middle of
schedule().
[toc] | [prev] | [next] | [standalone]
| From | Waiman Long <waiman.long@hpe.com> |
|---|---|
| Date | 2016-02-12 22:40 +0100 |
| Subject | Re: [PATCH v2 4/4] sched/fair: Abort wakeup when task is no longer in a sleeping state |
| Message-ID | <r1tBx-44h-15@gated-at.bofh.it> |
| In reply to | #1333082 |
On 02/12/2016 03:18 PM, Peter Zijlstra wrote:
> On Fri, Feb 12, 2016 at 12:32:15PM -0500, Waiman Long wrote:
>> When a task prepares to sleep and then aborts it somehow, there is
>> a small chance that a waker may be spinning on the on_cpu flag of
>> that task waiting for the flag to turn off before doing the wakeup
>> operation. It may keep on spinning for a long time until that task
>> actually sleeps leading to spurious wakeup.
>>
>> This patch adds code to detect the change in task state and abort
>> the wakeup operation, when appropriate, to free up the waker's cpu
>> to do other useful works.
>>
>> Signed-off-by: Waiman Long<Waiman.Long@hp.com>
>> ---
>> kernel/sched/core.c | 9 ++++++++-
>> 1 files changed, 8 insertions(+), 1 deletions(-)
>>
>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>> index 7e548bd..e4b6e84 100644
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -2075,8 +2075,15 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
>> *
>> * This ensures that tasks getting woken will be fully ordered against
>> * their previous state and preserve Program Order.
>> + *
>> + * If the owning cpu decides not to sleep after all by changing back
>> + * its task state, we can return immediately.
>> */
>> - smp_cond_acquire(!p->on_cpu);
>> + smp_cond_acquire(!p->on_cpu || !(p->state& state));
>> + if (!(p->state& state)) {
>> + success = 0;
>> + goto out;
>> + }
> This doesn't make sense, if we managed to get here, p->on_rq must be
> false, which means the other side is already in the middle of
> schedule().
Yes, you are right. It is my bad that I miss the on_rq check earlier.
Just scrap the last patch.
Sorry for that:-[
Longman
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2016-02-13 13:20 +0100 |
| Subject | Re: [PATCH v2 4/4] sched/fair: Abort wakeup when task is no longer in a sleeping state |
| Message-ID | <r1Hl7-4EJ-1@gated-at.bofh.it> |
| In reply to | #1333145 |
On Fri, Feb 12, 2016 at 04:22:29PM -0500, Waiman Long wrote:
> >>+ smp_cond_acquire(!p->on_cpu || !(p->state& state));
> >>+ if (!(p->state& state)) {
> >>+ success = 0;
> >>+ goto out;
> >>+ }
> >This doesn't make sense, if we managed to get here, p->on_rq must be
> >false, which means the other side is already in the middle of
> >schedule().
> Yes, you are right. It is my bad that I miss the on_rq check earlier. Just
> scrap the last patch.
No worries, that is tricky code :-)
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web