diff options
Diffstat (limited to 'litmus/preempt.c')
-rw-r--r-- | litmus/preempt.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/litmus/preempt.c b/litmus/preempt.c index 6be2f26728b8..86ad2efb591a 100644 --- a/litmus/preempt.c +++ b/litmus/preempt.c | |||
@@ -27,10 +27,12 @@ void sched_state_will_schedule(struct task_struct* tsk) | |||
27 | set_sched_state(PICKED_WRONG_TASK); | 27 | set_sched_state(PICKED_WRONG_TASK); |
28 | else | 28 | else |
29 | set_sched_state(WILL_SCHEDULE); | 29 | set_sched_state(WILL_SCHEDULE); |
30 | } else | 30 | } else { |
31 | /* Litmus tasks should never be subject to a remote | 31 | /* Litmus tasks should never be subject to a remote |
32 | * set_tsk_need_resched(). */ | 32 | * set_tsk_need_resched(). */ |
33 | BUG_ON(is_realtime(tsk)); | 33 | //BUG_ON(is_realtime(tsk)); |
34 | } | ||
35 | |||
34 | #ifdef CONFIG_PREEMPT_STATE_TRACE | 36 | #ifdef CONFIG_PREEMPT_STATE_TRACE |
35 | TRACE_TASK(tsk, "set_tsk_need_resched() ret:%p\n", | 37 | TRACE_TASK(tsk, "set_tsk_need_resched() ret:%p\n", |
36 | __builtin_return_address(0)); | 38 | __builtin_return_address(0)); |
@@ -46,14 +48,18 @@ void sched_state_ipi(void) | |||
46 | /* Cause scheduler to be invoked. | 48 | /* Cause scheduler to be invoked. |
47 | * This will cause a transition to WILL_SCHEDULE. */ | 49 | * This will cause a transition to WILL_SCHEDULE. */ |
48 | set_tsk_need_resched(current); | 50 | set_tsk_need_resched(current); |
51 | /* | ||
49 | TRACE_STATE("IPI -> set_tsk_need_resched(%s/%d)\n", | 52 | TRACE_STATE("IPI -> set_tsk_need_resched(%s/%d)\n", |
50 | current->comm, current->pid); | 53 | current->comm, current->pid); |
54 | */ | ||
51 | TS_SEND_RESCHED_END; | 55 | TS_SEND_RESCHED_END; |
52 | } else { | 56 | } else { |
53 | /* ignore */ | 57 | /* ignore */ |
58 | /* | ||
54 | TRACE_STATE("ignoring IPI in state %x (%s)\n", | 59 | TRACE_STATE("ignoring IPI in state %x (%s)\n", |
55 | get_sched_state(), | 60 | get_sched_state(), |
56 | sched_state_name(get_sched_state())); | 61 | sched_state_name(get_sched_state())); |
62 | */ | ||
57 | } | 63 | } |
58 | } | 64 | } |
59 | 65 | ||
@@ -70,23 +76,34 @@ void litmus_reschedule(int cpu) | |||
70 | * is not aware of the need to reschedule at this point. */ | 76 | * is not aware of the need to reschedule at this point. */ |
71 | 77 | ||
72 | /* is a context switch in progress? */ | 78 | /* is a context switch in progress? */ |
73 | if (cpu_is_in_sched_state(cpu, TASK_PICKED)) | 79 | if (cpu_is_in_sched_state(cpu, TASK_PICKED)) { |
74 | picked_transition_ok = sched_state_transition_on( | 80 | picked_transition_ok = sched_state_transition_on( |
75 | cpu, TASK_PICKED, PICKED_WRONG_TASK); | 81 | cpu, TASK_PICKED, PICKED_WRONG_TASK); |
76 | 82 | ||
83 | TRACE_CUR("cpu %d: picked_transition_ok = %d\n", cpu, picked_transition_ok); | ||
84 | } | ||
85 | else { | ||
86 | TRACE_CUR("cpu %d: picked_transition_ok = 0 (static)\n", cpu); | ||
87 | } | ||
88 | |||
77 | if (!picked_transition_ok && | 89 | if (!picked_transition_ok && |
78 | cpu_is_in_sched_state(cpu, TASK_SCHEDULED)) { | 90 | cpu_is_in_sched_state(cpu, TASK_SCHEDULED)) { |
79 | /* We either raced with the end of the context switch, or the | 91 | /* We either raced with the end of the context switch, or the |
80 | * CPU was in TASK_SCHEDULED anyway. */ | 92 | * CPU was in TASK_SCHEDULED anyway. */ |
81 | scheduled_transition_ok = sched_state_transition_on( | 93 | scheduled_transition_ok = sched_state_transition_on( |
82 | cpu, TASK_SCHEDULED, SHOULD_SCHEDULE); | 94 | cpu, TASK_SCHEDULED, SHOULD_SCHEDULE); |
95 | TRACE_CUR("cpu %d: scheduled_transition_ok = %d\n", cpu, scheduled_transition_ok); | ||
96 | } | ||
97 | else { | ||
98 | TRACE_CUR("cpu %d: scheduled_transition_ok = 0 (static)\n", cpu); | ||
83 | } | 99 | } |
84 | 100 | ||
85 | /* If the CPU was in state TASK_SCHEDULED, then we need to cause the | 101 | /* If the CPU was in state TASK_SCHEDULED, then we need to cause the |
86 | * scheduler to be invoked. */ | 102 | * scheduler to be invoked. */ |
87 | if (scheduled_transition_ok) { | 103 | if (scheduled_transition_ok) { |
88 | if (smp_processor_id() == cpu) | 104 | if (smp_processor_id() == cpu) { |
89 | set_tsk_need_resched(current); | 105 | set_tsk_need_resched(current); |
106 | } | ||
90 | else { | 107 | else { |
91 | TS_SEND_RESCHED_START(cpu); | 108 | TS_SEND_RESCHED_START(cpu); |
92 | smp_send_reschedule(cpu); | 109 | smp_send_reschedule(cpu); |
@@ -101,11 +118,16 @@ void litmus_reschedule(int cpu) | |||
101 | 118 | ||
102 | void litmus_reschedule_local(void) | 119 | void litmus_reschedule_local(void) |
103 | { | 120 | { |
104 | if (is_in_sched_state(TASK_PICKED)) | 121 | if (is_in_sched_state(TASK_PICKED)) { |
105 | set_sched_state(PICKED_WRONG_TASK); | 122 | set_sched_state(PICKED_WRONG_TASK); |
123 | |||
124 | TRACE_CUR("cpu %d: transitioned to PICKED_WRONG_TASK\n", smp_processor_id()); | ||
125 | } | ||
106 | else if (is_in_sched_state(TASK_SCHEDULED | SHOULD_SCHEDULE)) { | 126 | else if (is_in_sched_state(TASK_SCHEDULED | SHOULD_SCHEDULE)) { |
107 | set_sched_state(WILL_SCHEDULE); | 127 | set_sched_state(WILL_SCHEDULE); |
108 | set_tsk_need_resched(current); | 128 | set_tsk_need_resched(current); |
129 | |||
130 | TRACE_CUR("cpu %d: transitioned to WILL_SCHEDULE\n", smp_processor_id()); | ||
109 | } | 131 | } |
110 | } | 132 | } |
111 | 133 | ||