On Mon, 10 Feb 2025 at 13:58, Peter Maydell <peter.mayd...@linaro.org> wrote: > > Currently we call icount_start_warp_timer() from timerlist_rearm(). > This produces incorrect behaviour, because timerlist_rearm() is > called, for instance, when a timer callback modifies its timer. We > cannot decide here to warp the timer forwards to the next timer > deadline merely because all_cpu_threads_idle() is true, because the > timer callback we were called from (or some other callback later in > the list of callbacks being invoked) may be about to raise a CPU > interrupt and move a CPU from idle to ready.5A
(oops, stray editor damage "5A" at end of line) > > The only valid place to choose to warp the timer forward is from the > main loop, when we know we have no outstanding IO or timer callbacks > that might be about to wake up a CPU. This raises actually another question: should the call to icount_start_warp_timer() in main_loop_wait() maybe go after qemu_clock_run_all_timers() rather than before? (Haven't tested whether that breaks anything ;-)) -- PMM