um: time-travel: fix sched_yield() behaviour

Just incrementing tt_extra_sched_jiffies can make this
drift enough to hit the softlockup detector, e.g. with
ping using sched_yield() in a loop to measure short
intervals. Make the simulation actually pass time, this
requires going to the external scheduler but actually
makes this sort of thing behave much better and avoids
the soft lockup.

Fixes: 887c5c12e8 ("um: work around sched_yield not yielding in time-travel mode")
Link: https://patch.msgid.link/20260924134223.1672004-2-johannes@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2026-09-24 15:42:24 +02:00
parent fa6a0e7a8b
commit 0e70b1de88

View File

@ -35,12 +35,13 @@ void handle_syscall(struct uml_pt_regs *r)
/*
* If no time passes, then sched_yield may not actually yield, causing
* broken spinlock implementations in userspace (ASAN) to hang for long
* periods of time.
* periods of time. Advance the time-travel clock a bit so sched_yield()
* in a loop (like ping does for small intervals) also works correctly.
*/
if ((time_travel_mode == TT_MODE_INFCPU ||
time_travel_mode == TT_MODE_EXTERNAL) &&
syscall == __NR_sched_yield)
tt_extra_sched_jiffies += 1;
time_travel_ndelay(1000);
if (syscall >= 0 && syscall < __NR_syscalls) {
unsigned long ret;