kernel/sched.c: fix subtle TASK_RUNNING compare
PATCH 3/8 kernel/sched.c: fix subtle TASK_RUNNING compare
Hi.
This test was depending on TASK_RUNNING being defined as 0.
---
linux-2.6.10-rc2-bk4-max/kernel/sched.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-)
kernel/sched.c renamed from kernel/sched.c~fix-test-kernel_sched +2 -1
@@ -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))))
_
kernel/sched.c need_resched_nonpreemptible: · line 2581
Quoted 5 lines · * [email protected] <[email protected]> wrote:
kernel/sched.c renamed from kernel/sched.c~fix-test-kernel_sched +2
-1switch_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
Quoted 11 lines · Ingo Molnar
kernel/sched.c need_resched_nonpreemptible: · line 2581
Quoted 5 lines · * [email protected] <[email protected]> wrote:
kernel/sched.c renamed from kernel/sched.c~fix-test-kernel_sched +2
-1switch_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_RUNNINGthus 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
Quoted 13 lines · Domen Puncer
Quoted 11 lines · Ingo Molnar
kernel/sched.c need_resched_nonpreemptible: · line 2581
Quoted 5 lines · * [email protected] <[email protected]> wrote:
kernel/sched.c renamed from kernel/sched.c~fix-test-kernel_sched +2
-1switch_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_RUNNINGthus being zero.
Quoted 5 lines
Hmm... but other compares in
sched.care 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