lkml.org 
[lkml]   [1999]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: scheduling problem?
William Montgomery wrote:
> In the ktrace below the ret_with_reschedule is not executed since
> the idle task is in user mode. I thought the idle task was always
> checking need_resched so schedule should be called immediately?

I see a race in cpu_idle() and it is consistent with your trace:

while (!current->need_resched) {
if (!current_cpu_data.hlt_works_ok)
continue;
if (hlt_counter)
continue;
asm volatile("sti ; hlt" : : : "memory");
}
shedule();

The interrupt can set need_resched after it is checked but before the
hlt. Then the processor will wait until it receives another interrupt
before checking need_resched again. Everything works, but you lose a
tick of scheduling latency. Doesn't Mingo's low-latency patch fix this?

This patch should remove the race; please test.

-- Jamie

diff -u linux-2.3/arch/i386/kernel/process.c.idle linux-2.3/arch/i386/kernel/process.c
--- linux-2.3/arch/i386/kernel/process.c.idle Wed Nov 3 16:35:37 1999
+++ linux-2.3/arch/i386/kernel/process.c Thu Dec 16 19:10:59 1999
@@ -87,6 +87,11 @@
continue;
if (hlt_counter)
continue;
+ asm volatile("cli" : : : "memory");
+ if (current->need_resched) {
+ asm volatile("sti" : : : "memory");
+ break;
+ }
asm volatile("sti ; hlt" : : : "memory");
}
schedule();


> c0113297 schedule +<13/284> ( 1.22 ) ( 295924.62 elapsed) pid(289->0)
> c0107a77 __switch_to +<f/d8> ( 2.07 ) ( 295925.84 elapsed) pid(0)
> c011d21d check_pgt_cache +<d/24> ( 0.30 ) ( 295927.91 elapsed) pid(0)
> c011056f do_check_pgt_cache +<f/84> ( 1.36 ) ( 295928.21 elapsed) pid(0)
> c010a65d do_IRQ +<d/54> ( 0.36 ) ( 295929.57 elapsed) pid(0)
> c010a1df do_8259A_IRQ +<13/b4> ( 2.65 ) ( 295929.93 elapsed) pid(0)
> c010a504 handle_IRQ_event +<10/78> ( 0.65 ) ( 295932.57 elapsed) pid(0)
> c01baf71 rtc_interrupt +<11/9c> ( 3.98 ) ( 295933.23 elapsed) pid(0)
> c0113518 __wake_up +<10/58> ( 0.33 ) ( 295937.21 elapsed) pid(0)
> c013205a kill_fasync +<e/54> ( 0.30 ) ( 295937.54 elapsed) pid(0)
> c0131f6e send_sigio +<16/f4> ( 6.18 ) ( 295937.84 elapsed) pid(0)
> ^^^--- send sigio to SCHED_FIFO pid(159)
>
> c0111d79 send_sig +<d/2c> ( 0.27 ) ( 295944.02 elapsed) pid(0)
> c011181f send_sig_info +<13/28c> ( 0.68 ) ( 295944.29 elapsed) pid(0)
> c01117a6 ignored_signal +<e/74> ( 0.53 ) ( 295944.97 elapsed) pid(0)
> c0112e19 wake_up_process +<d/54> ( 0.28 ) ( 295945.50 elapsed) pid(0)
> c0112d92 reschedule_idle +<e/88> ( 5.63 ) ( 295945.78 elapsed) pid(0)
> c011301a mod_timer +<e/188> ( 0.86 ) ( 295951.41 elapsed) pid(0)
> c010a119 enable_8259A_irq +<d/3c> ( 0.74 ) ( 295952.27 elapsed) pid(0)
> c010a682 do_IRQ +<32/54> ( 0.15 ) ( 295953.01 elapsed) pid(0)
> c010a69d do_IRQ +<4d/54> ( 0.21 ) ( 295953.16 elapsed) pid(0)
> c0108f27 ret_from_intr +<7/30> ( 7217.82 ) ( 295953.37 elapsed) pid(0)
> ^^^--- idle task never sees need_resched?
>
> c010a65d do_IRQ +<d/54> ( 0.19 ) ( 303171.19 elapsed) pid(0)
> c010a1df do_8259A_IRQ +<13/b4> ( 2.05 ) ( 303171.39 elapsed) pid(0)
> c010a504 handle_IRQ_event +<10/78> ( 0.34 ) ( 303173.44 elapsed) pid(0)
> c010e1de timer_interrupt +<12/12c> ( 6.21 ) ( 303173.78 elapsed) pid(0)
> c011419d do_timer +<d/5c> ( 0.53 ) ( 303179.99 elapsed) pid(0)
> c010a119 enable_8259A_irq +<d/3c> ( 0.83 ) ( 303180.52 elapsed) pid(0)
> c010a682 do_IRQ +<32/54> ( 0.16 ) ( 303181.35 elapsed) pid(0)
> c011b640 do_bottom_half +<10/78> ( 0.33 ) ( 303181.51 elapsed) pid(0)
> c0113e64 timer_bh +<10/33c> ( 0.45 ) ( 303181.84 elapsed) pid(0)
> c0113cbe update_wall_time +<e/58> ( 0.24 ) ( 303182.30 elapsed) pid(0)
> c0113bfa update_wall_time_one_tick +<e/c4> ( 0.35 ) ( 303182.54 elapsed) pid(0)
> c0113df7 update_process_times +<f/6c> ( 0.19 ) ( 303182.89 elapsed) pid(0)
> c0113d18 update_one_process +<10/e0> ( 1.29 ) ( 303183.08 elapsed) pid(0)
> c010a69d do_IRQ +<4d/54> ( 0.13 ) ( 303184.37 elapsed) pid(0)
> c0108f27 ret_from_intr +<7/30> ( 0.39 ) ( 303184.50 elapsed) pid(0)
> c0113297 schedule +<13/284> ( 0.62 ) ( 303184.89 elapsed) pid(0->159)
> ^^^--- how does need_resched reappear?
>
> Is the above analysis correct? I must be missing something obvious.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.060 / U:0.620 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site