* [patch 3/8] kernel/sched.c: fix subtle TASK_RUNNING compare
@ 2004-11-20 2:29 janitor
2004-11-20 12:53 ` Ingo Molnar
0 siblings, 1 reply; 4+ messages in thread
From: janitor @ 2004-11-20 2:29 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, janitor, domen
Hi.
This test was depending on TASK_RUNNING being defined as 0.
Signed-off-by: Domen Puncer <domen@coderock.org>
Signed-off-by: Maximilian Attems <janitor@sternwelten.at>
---
linux-2.6.10-rc2-bk4-max/kernel/sched.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletion(-)
diff -puN kernel/sched.c~fix-test-kernel_sched kernel/sched.c
--- linux-2.6.10-rc2-bk4/kernel/sched.c~fix-test-kernel_sched 2004-11-20 03:04:46.000000000 +0100
+++ linux-2.6.10-rc2-bk4-max/kernel/sched.c 2004-11-20 03:04:46.000000000 +0100
@@ -2576,7 +2576,8 @@ need_resched_nonpreemptible:
* to picking the next task.
*/
switch_count = &prev->nivcsw;
- if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
+ if (prev->state != TASK_RUNNING &&
+ !(preempt_count() & PREEMPT_ACTIVE)) {
switch_count = &prev->nvcsw;
if (unlikely((prev->state & TASK_INTERRUPTIBLE) &&
unlikely(signal_pending(prev))))
_
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: kernel/sched.c: fix subtle TASK_RUNNING compare
2004-11-20 12:53 ` Ingo Molnar
@ 2004-11-20 12:07 ` Domen Puncer
2004-11-20 16:40 ` Ingo Molnar
0 siblings, 1 reply; 4+ messages in thread
From: Domen Puncer @ 2004-11-20 12:07 UTC (permalink / raw)
To: Ingo Molnar; +Cc: janitor, akpm, linux-kernel
On 20/11/04 13:53 +0100, Ingo Molnar wrote:
>
> * janitor@sternwelten.at <janitor@sternwelten.at> wrote:
>
> > switch_count = &prev->nivcsw;
> > - if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
> > + if (prev->state != TASK_RUNNING &&
> > + !(preempt_count() & PREEMPT_ACTIVE)) {
> > switch_count = &prev->nvcsw;
>
> nack. We inherently rely on the process state mask being a bitmask and
> TASK_RUNNING thus being zero.
Hmm... but other compares in sched.c are ok? ;-)
1211: BUG_ON(p->state != TASK_RUNNING);
2550: if (unlikely(current == rq->idle) && current->state != TASK_RUNNING) {
3609: if (state == TASK_RUNNING)
3640: if (state != TASK_RUNNING)
Well, it just looks more readable to me. But i don't have too strong
feelings about this. :-)
Domen
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch 3/8] kernel/sched.c: fix subtle TASK_RUNNING compare
2004-11-20 2:29 [patch 3/8] kernel/sched.c: fix subtle TASK_RUNNING compare janitor
@ 2004-11-20 12:53 ` Ingo Molnar
2004-11-20 12:07 ` Domen Puncer
0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2004-11-20 12:53 UTC (permalink / raw)
To: janitor; +Cc: akpm, linux-kernel, domen
* janitor@sternwelten.at <janitor@sternwelten.at> wrote:
> switch_count = &prev->nivcsw;
> - if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
> + if (prev->state != TASK_RUNNING &&
> + !(preempt_count() & PREEMPT_ACTIVE)) {
> switch_count = &prev->nvcsw;
nack. We inherently rely on the process state mask being a bitmask and
TASK_RUNNING thus being zero.
Ingo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: kernel/sched.c: fix subtle TASK_RUNNING compare
2004-11-20 12:07 ` Domen Puncer
@ 2004-11-20 16:40 ` Ingo Molnar
0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2004-11-20 16:40 UTC (permalink / raw)
To: Domen Puncer; +Cc: janitor, akpm, linux-kernel
* Domen Puncer <domen@coderock.org> wrote:
> On 20/11/04 13:53 +0100, Ingo Molnar wrote:
> >
> > * janitor@sternwelten.at <janitor@sternwelten.at> wrote:
> >
> > > switch_count = &prev->nivcsw;
> > > - if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
> > > + if (prev->state != TASK_RUNNING &&
> > > + !(preempt_count() & PREEMPT_ACTIVE)) {
> > > switch_count = &prev->nvcsw;
> >
> > nack. We inherently rely on the process state mask being a bitmask and
> > TASK_RUNNING thus being zero.
>
> Hmm... but other compares in sched.c are ok? ;-)
> 1211: BUG_ON(p->state != TASK_RUNNING);
> 2550: if (unlikely(current == rq->idle) && current->state != TASK_RUNNING) {
> 3609: if (state == TASK_RUNNING)
> 3640: if (state != TASK_RUNNING)
hm ... ok.
Ingo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-11-20 15:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-20 2:29 [patch 3/8] kernel/sched.c: fix subtle TASK_RUNNING compare janitor
2004-11-20 12:53 ` Ingo Molnar
2004-11-20 12:07 ` Domen Puncer
2004-11-20 16:40 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox