Created attachment 303195 [details] Code to sleep for 10ms, print elapsed time if over 20ms std::this_thread::sleep_for and other types of sleep in non realtime tasks are extremely inaccurate on some RT kernels. A sleep of 10ms may sometimes take over 700ms to complete. The PC is idle, and there are no RT tasks running. This has been tested on modern Intel cpus (1165G7 and 1260p) as well as Ryzen 4800HS. I have tested many combinations of CPU governors and performance settings but the problem is not fixed by those. I have tried 5.10, 5.16, 5.19 and 6.0 and all except 5.10 exhibit the same behavior. With 5.10 kernel, I may run the sample code for 20 minutes and get 3-4 messages about the sleep taking at most 25ms. With the other kernels, multiple times per minute I get sleeps of up to 700ms. I have tried the same kernels without RT patch on the same computers, and the problem does not occur. I have built the kernels myself, and have also tried with the ones from: https://packages.debian.org/search?arch=amd64&keywords=linux-image-rt I have tried using the config from 5.10 on 6.0 kernel, but the problem still appears on the 6.0 rt kernel.
Kernel 6.1-rc5 with v6.1-rc5-rt3 exhibits the same problem too 7-8 messages per minute. 5.16.2 with 5.16.2-rt18works better, 1-2 messages per minute. 5.15.49 with 5.15.49-rt47 works almost flawlessly.