2011-05-24 13:27:12

by Hillf Danton

[permalink] [raw]
Subject: [PATCH] sched: fix need_resched() when checking peempt

When checking if current task could be preempted by a newly woken task,
further check could be bypassed if the current thread is different from
the current task of run-queue, and it is corrected accordingly.

Signed-off-by: Hillf Danton <[email protected]>
---

--- tip-git/kernel/sched_rt.c Sun May 22 20:12:01 2011
+++ sched_rt.c Tue May 24 20:31:27 2011
@@ -1074,7 +1074,7 @@ static void check_preempt_curr_rt(struct
* to move current somewhere else, making room for our non-migratable
* task.
*/
- if (p->prio == rq->curr->prio && !need_resched())
+ if (p->prio == rq->curr->prio && !test_tsk_need_resched(rq->curr))
check_preempt_equal_prio(rq, p);
#endif
}


2011-05-24 13:39:46

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] sched: fix need_resched() when checking peempt

On Tue, 2011-05-24 at 21:27 +0800, Hillf Danton wrote:
> When checking if current task could be preempted by a newly woken task,
> further check could be bypassed if the current thread is different from
> the current task of run-queue, and it is corrected accordingly.

Ug, that change log is an obfuscated mess. But looking at the actual
patch, I figured what you wanted to say. How about this:

----
The RT preempt check tests the wrong task if NEED_RESCHED is set. It
currently checks the local CPU task. It is suppose to check the task
that is running on the run queue we are about to wake another task on.
----


>
> Signed-off-by: Hillf Danton <[email protected]>

With a new change log:

Acked-by: Steven Rostedt <[email protected]>

-- Steve

> ---
>
> --- tip-git/kernel/sched_rt.c Sun May 22 20:12:01 2011
> +++ sched_rt.c Tue May 24 20:31:27 2011
> @@ -1074,7 +1074,7 @@ static void check_preempt_curr_rt(struct
> * to move current somewhere else, making room for our non-migratable
> * task.
> */
> - if (p->prio == rq->curr->prio && !need_resched())
> + if (p->prio == rq->curr->prio && !test_tsk_need_resched(rq->curr))
> check_preempt_equal_prio(rq, p);
> #endif
> }

2011-05-24 13:50:58

by Hillf Danton

[permalink] [raw]
Subject: Re: [PATCH] sched: fix need_resched() when checking peempt

On Tue, May 24, 2011 at 9:39 PM, Steven Rostedt <[email protected]> wrote:
> On Tue, 2011-05-24 at 21:27 +0800, Hillf Danton wrote:
>> When checking if current task could be preempted by a newly woken task,
>> further check could be bypassed if the current thread is different from
>> the current task of run-queue, and it is corrected accordingly.
>
> Ug, that change log is an obfuscated mess. But looking at the actual
> patch, I figured what you wanted to say. How about this:
>
> ----
> The RT preempt check tests the wrong task if NEED_RESCHED is set. It
> currently checks the local CPU task. It is suppose to check the task
> that is running on the run queue we are about to wake another task on.
> ----
>
Thanks, it is great changelog:)

Hillf

2011-05-25 03:24:32

by Yong Zhang

[permalink] [raw]
Subject: Re: [PATCH] sched: fix need_resched() when checking peempt

On Tue, May 24, 2011 at 9:50 PM, Hillf Danton <[email protected]> wrote:
> On Tue, May 24, 2011 at 9:39 PM, Steven Rostedt <[email protected]> wrote:
>> On Tue, 2011-05-24 at 21:27 +0800, Hillf Danton wrote:
>>> When checking if current task could be preempted by a newly woken task,
>>> further check could be bypassed if the current thread is different from
>>> the current task of run-queue, and it is corrected accordingly.
>>
>> Ug, that change log is an obfuscated mess. But looking at the actual
>> patch, I figured what you wanted to say. How about this:
>>
>> ----
>> The RT preempt check tests the wrong task if NEED_RESCHED is set. It
>> currently checks the local CPU task. It is suppose to check the task
>> that is running on the run queue we are about to wake another task on.
>> ----
>>
> Thanks, it is great changelog:)

Good catch.

Reviewed-by: Yong Zhang <[email protected]>

BTW, this may be the reason for we could trigger
WARN_ON_ONCE(test_tsk_need_resched(next));
https://lkml.org/lkml/2010/12/20/28

Peter, Mike, how do you think about it?

Thanks,
Yong


--
Only stand for myself

2011-05-25 04:34:25

by Yong Zhang

[permalink] [raw]
Subject: Re: [PATCH] sched: fix need_resched() when checking peempt

On Wed, May 25, 2011 at 11:24 AM, Yong Zhang <[email protected]> wrote:
> On Tue, May 24, 2011 at 9:50 PM, Hillf Danton <[email protected]> wrote:
>> On Tue, May 24, 2011 at 9:39 PM, Steven Rostedt <[email protected]> wrote:
>>> On Tue, 2011-05-24 at 21:27 +0800, Hillf Danton wrote:
>>>> When checking if current task could be preempted by a newly woken task,
>>>> further check could be bypassed if the current thread is different from
>>>> the current task of run-queue, and it is corrected accordingly.
>>>
>>> Ug, that change log is an obfuscated mess. But looking at the actual
>>> patch, I figured what you wanted to say. How about this:
>>>
>>> ----
>>> The RT preempt check tests the wrong task if NEED_RESCHED is set. It
>>> currently checks the local CPU task. It is suppose to check the task
>>> that is running on the run queue we are about to wake another task on.
>>> ----
>>>
>> Thanks, it is great changelog:)
>
> Good catch.
>
> Reviewed-by: Yong Zhang <[email protected]>
>
> BTW, this may be the reason for we could trigger
> WARN_ON_ONCE(test_tsk_need_resched(next));
> https://lkml.org/lkml/2010/12/20/28
>
> Peter, Mike, how do you think about it?

Since rq->lock protects both, that issue needs more digging :)

>
> Thanks,
> Yong
>
>
> --
> Only stand for myself
>



--
Only stand for myself

2011-05-25 04:44:43

by Mike Galbraith

[permalink] [raw]
Subject: Re: [PATCH] sched: fix need_resched() when checking peempt

On Wed, 2011-05-25 at 12:34 +0800, Yong Zhang wrote:
> On Wed, May 25, 2011 at 11:24 AM, Yong Zhang <[email protected]> wrote:
> > On Tue, May 24, 2011 at 9:50 PM, Hillf Danton <[email protected]> wrote:
> >> On Tue, May 24, 2011 at 9:39 PM, Steven Rostedt <[email protected]> wrote:
> >>> On Tue, 2011-05-24 at 21:27 +0800, Hillf Danton wrote:
> >>>> When checking if current task could be preempted by a newly woken task,
> >>>> further check could be bypassed if the current thread is different from
> >>>> the current task of run-queue, and it is corrected accordingly.
> >>>
> >>> Ug, that change log is an obfuscated mess. But looking at the actual
> >>> patch, I figured what you wanted to say. How about this:
> >>>
> >>> ----
> >>> The RT preempt check tests the wrong task if NEED_RESCHED is set. It
> >>> currently checks the local CPU task. It is suppose to check the task
> >>> that is running on the run queue we are about to wake another task on.
> >>> ----
> >>>
> >> Thanks, it is great changelog:)
> >
> > Good catch.
> >
> > Reviewed-by: Yong Zhang <[email protected]>
> >
> > BTW, this may be the reason for we could trigger
> > WARN_ON_ONCE(test_tsk_need_resched(next));
> > https://lkml.org/lkml/2010/12/20/28
> >
> > Peter, Mike, how do you think about it?
>
> Since rq->lock protects both, that issue needs more digging :)

Yeah, good rainy day project.

-Mike

2011-05-31 03:26:31

by Mike Galbraith

[permalink] [raw]
Subject: Re: [PATCH] sched: fix need_resched() when checking peempt

On Tue, 2011-05-24 at 21:50 +0800, Hillf Danton wrote:
> On Tue, May 24, 2011 at 9:39 PM, Steven Rostedt <[email protected]> wrote:
> > On Tue, 2011-05-24 at 21:27 +0800, Hillf Danton wrote:
> >> When checking if current task could be preempted by a newly woken task,
> >> further check could be bypassed if the current thread is different from
> >> the current task of run-queue, and it is corrected accordingly.
> >
> > Ug, that change log is an obfuscated mess. But looking at the actual
> > patch, I figured what you wanted to say. How about this:
> >
> > ----
> > The RT preempt check tests the wrong task if NEED_RESCHED is set. It
> > currently checks the local CPU task. It is suppose to check the task
> > that is running on the run queue we are about to wake another task on.
> > ----
> >
> Thanks, it is great changelog:)

Has this been queued, or is it awaiting re-submission?

-Mike

2011-05-31 13:18:34

by Hillf Danton

[permalink] [raw]
Subject: [PATCH resend] sched: fix need_resched() when checking peempt

The RT preempt check tests the wrong task if NEED_RESCHED is set. It currently
checks the local CPU task. It is suppose to check the task that is running on
the run queue we are about to wake another task on.

Signed-off-by: Hillf Danton <[email protected]>
Acked-by: Steven Rostedt <[email protected]>
Reviewed-by: Yong Zhang <[email protected]>
---
kernel/sched_rt.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index 88725c9..9b8d5dc 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -1096,7 +1096,7 @@ static void check_preempt_curr_rt(struct rq *rq,
struct task_struct *p, int flag
* to move current somewhere else, making room for our non-migratable
* task.
*/
- if (p->prio == rq->curr->prio && !need_resched())
+ if (p->prio == rq->curr->prio && !test_tsk_need_resched(rq->curr))
check_preempt_equal_prio(rq, p);
#endif
}