Re: Problem with rt_sleep() in kernel space

Paolo Mantegazza <[email protected]> Sat, 8 Oct 2016 20:05:24 +0000
Newsgroups gmane.linux.real-time.rtai
Message-ID <VI1PR06MB1471E719E3179A9A8DFA1D3290D90@VI1PR06MB1471.eurprd06.prod.outlook.com>
In my experience an unstable clocksource, in this case likely a TSC shared by RTAI and Linux, can be cause by not allowing Linux to satisfy its timing. A fact that is possibly by RTAI using too much resources..
Paolo
________________________________________
From: Rtai [[email protected]] on behalf of Marco Pantaleoni [[email protected]]
Sent: Friday, October 7, 2016 2:57 PM
To: rtai
Subject: [Rtai] Problem with rt_sleep() in kernel space

Dear RTAI'ers,

I'm porting a large codebase from RTAI-in-userspace to kernel space.
What I'm observing is that after an initial setup phase in which everything seems to work correctly, from a certain point in time onward, rt_sleep() called inside a thread seems to ignore the passed parameter: in fact, looking at console times of a printk done both before and after the sleep, the time spent inside rt_sleep() seems to be in every case around ~7ms, while I've passed 100us, 100ms and even larger values. To be more precise, I've called rt_sleep() in this way:

  rt_sleep(nano2count(100000)); /* 100us */

and

  rt_sleep(nano2count(100000000LL)); /* 100ms */

among other values.
It is called inside a cycle and the speed of the cycle remains the same, confirming that the parameter seems to be ignored in these cases.

What I'm observing is that (a) before this point other threads (and this one too) call rt_sleep() many times (and it seems to work correctly), (b) just before the problem manifests itself the kernel emits the message:

[   66.634015] Clocksource tsc unstable (delta = 121203613 ns)

I suspect this could be in some way related to the problem. Maybe the kernel performs some recalibrations of the timers / TSC / something and this breaks RTAI timing?

I've tried both one shot and periodic timer modes.
I'm using RTAI 3.8 with kernel 2.6.32.2 on an 800MHz Vortex86DX, everything compiled with gcc 4.4.1.

I'll appreciate any help or suggestion. Thanks in advance!

Cheers,
Marco

--
Marco Pantaleoni
_______________________________________________
Rtai mailing list
[email protected]
https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai