Re: POSIX timer wakeups not preempting RT threads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2023-06-23 13:15:11 [-0400], Martin Hicks wrote:
> Hi,
Hi,

> 
> I'm looking at using a POSIX timer to cause an action to be run every
> 500us, but I'm seeing that when the hrtimer fires while the CPU is
> busy running another SCHED_RR/SCHED_FIFO process that the hrtimer is
> deferred until the process releases the CPU.  I'm using SIGEV_SIGNAL
> to deliver the timer expiry to a thread that's running at a higher RT
> Priority than the other tasks, but no preemption seems to occur.
> 
> If the "other" tasks are running with SCHED_OTHER then the signal is
> delivered immediately.
> 
> I've tried using 'cset shield -c 1' and without (just pinning use
> taskset -c 1), and modified priorities and scheduler with chrt.
> The test is running on x86_64 with 6.3.9-rt15. PREEMPT_RT is enabled.
> 
> A simple test that illustrates the idea is attached.
> Is this supposed to work?

Well, "work". If you have a SCHED_RR/FIFO task and setup a timer
(clock_nanosleep()) then the wakeup is precise/ direct (hw timer ->
wakeup of the task).
POSIX timer are a bit special due to how they have to be processed. As a
consequence, the wake up path is (hw timer -> ktimers/$CPU thread ->
wakeup of the task via a signal).
That ktimers/$CPU thread runs at SCHED_FIFO 1 priority. If there a task
with higher priority then timer handling get deferred. This sounds like
what you observe.
That ktimers/$CPU is also in charge of waking all non-RT threads.

> mh

Sebastian



[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux