I have pinpointed the source of the delays to this patch: softirq: Use a dedicated thread for timer wakeups. (https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git/commit/?h=linux-6.1.y-rt-rebase&id=65f32c25b9c87966cbf2ecbbe478273f13e97ceb). At least on the 6.1-rc7 kernel. Additionally, I've found that although the wrong sleep behavior is present with both acpi-cpufreq and intel_paste CPU governors, with acpi-cpufreq the sleep errors are always under 50ms. But with intel_pstate the delays go over 1200ms. I am testing a kernel without that patch, and the patches built on top of that, but I would like to know why. This patch is not on the linux-rt-stable repo. On Thu, 1 Dec 2022 at 15:34, Víctor López <lopez1987@xxxxxxxxx> wrote: > > I reported this on https://bugzilla.kernel.org/show_bug.cgi?id=216702 > two weeks ago, but I believe that the bug tracker has less activity > than this mailing list. > > Here's the bug report I pasted: > 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 initially tried 5.10, 5.16, 5.19, and 6.0, and all except 5.10 > exhibited the same behavior. > > With a 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. > > Later I tried v6.1-rc5-rt3 which exhibits the same problem too 7-8 > messages per minute. > > 5.16.2 with 5.16.2-rt18 works better, with 1-2 messages per minute. > > 5.15.49 with 5.15.49-rt47 works almost flawlessly. > > I have tried the same kernels without the 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 the 6.0 kernel, but the > problem still appears on the 6.0 rt kernel. > > I would really like to use the RT patch on 6.1 or 6.2 when available > since the system we are using has an Intel Hybrid 12th gen CPU, the > support of which is being greatly improved lately. > > I am attaching an example to reproduce the issue: