- The arch is powerpc.
- I changed the ISR from threaded to no-threaded.
- The ISR wake-up another FIFO task with prio==19
- Sometimes at the end of 'ret_from_except' when do 'resume_kernel', the preempt schedule condition is not fulfilled: the 'preempt-able' is yes, the 'need_resched' flag not set, but,
- In C code, the 'try_to_wake_up' has set the 'need_resched' flag to yes.
- I tried cached sync, better but didn't eliminate the problem.
- code snippet related:
The '5555555' and 'eeeeeeee' are printed but the 'ffffffff' isn't.
kernel/sched.c:
184 +static void my_resched_task( struct task_struct *new, struct task_struct *cur ) {
185 + int cpu;
186 +
187 + assert_raw_spin_locked(&task_rq(cur)->lock);
188 +
189 + cpu = task_cpu(cur);
190 +
191 + if (test_tsk_need_resched(cur)) {
192 + if( new->prio <= 20 && in_irq() ) {
193 + set_tsk_need_resched(cur);
194 + __asm__ volatile("sync;isync": : : "memory");
195 + PRMPT_SCHD_IRQ_TS_PRINT(0x55555555);
196 + dcbf(&(task_thread_info(cur)->flags));
197 + in_be32(&(task_thread_info(cur)->flags));
198 + __asm__ volatile ("msync");
199 + }
200 + return;
201 + }
202 +
203 + set_tsk_need_resched(cur);
204 + if( new->prio <= 20 && in_irq() ) {
205 + __asm__ volatile("sync;isync": : : "memory");
206 + PRMPT_SCHD_IRQ_TS_PRINT(0x66666666);
207 + dcbf(&(task_thread_info(cur)->flags));
208 + in_be32(&(task_thread_info(cur)->flags));
209 + __asm__ volatile ("msync");
210 + }
arch/powerpc/kernel/entry_32.S
66 + /*wqc add >>*/
67 + WQC_PRMT_TAG_IMT(0xeeeeeeee)
68 + /*would r0 has been changed in the above flow ? reload it*/
69 + rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
70 + lwz r0,TI_FLAGS(r9)
71 + /*wqc add <<*/
72 +
73 andi. r0,r0,_TIF_NEED_RESCHED
74 beq+ restore
75 + WQC_PRMT_TAG_IMT(0xffffffff)
76 lwz r3,_MSR(r1)
77 andi. r0,r3,MSR_EE /* interrupts off? */
78 beq restore /* don't schedule if so */
79 @@ -938,6 +970,7 @@ resume_kernel:
80 //wqc */
81 //wqc bl trace_hardirqs_off
82 #endif
83 + WQC_PRMT_TAG_IMT(0xa0a0a0a0)
84 1: bl preempt_schedule_irq