How does machinekit test to see if it is running on a rt-preempt kernel?

60 views
Skip to first unread message

mugginsac

unread,
Feb 18, 2019, 11:44:38 PM2/18/19
to Machinekit
Robert just furnished a new test image. It definitely has an rt-preempt kernel, when I exported FLAVOR=rt-preempt, it ran machinekit.
However, before I exported FLAVOR=rt-preempt, machinekit tried to run the posix realtime stuff (term of art).

So, the question is how does machinekit try to determine the nature of the kernel that it is running on?

Robert asked if we should just set FLAVOR=rt-preempt in the environment when we create the uSD. Is that acceptable?


schoo...@gmail.com

unread,
Feb 19, 2019, 4:42:17 AM2/19/19
to machi...@googlegroups.com
That is one way to deal with it.
rtapi_compat.c first checks the env var FLAVOR, before trying to determine other ways

Run these tests from a terminal and let us know what result you get

cat /sys/kernel/realtime     (should return 1)
cat /boot/config-<kernel-version>  | grep CONFIG_PREEMPT_RT_FULL=yes  ( should return CONFIG_PREEMPT_RT_FULL=yes)
uname -a | grep 'PREEMPT RT'  ( should  return PREEMPT RT - but we already know it won't)

There is something screwy about the 4.19 kernel and rt.  I stopped using the Debian rt-amd64 version and reverted to 4.18 because of problems
--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups "Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to machinekit+...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.

Condit Alan

unread,
Feb 19, 2019, 11:26:50 AM2/19/19
to schoo...@gmail.com, Machinekit, Robert Nelson
Schooner and Robert,

OK, here is what I see when I run those tests. Rather than grep the results of uname -r, I just printed out uname -r. 

machinekit@beaglebone:~$ cat /sys/kernel/realtime
cat: /sys/kernel/realtime: No such file or directory
machinekit@beaglebone:~$ cat /boot/config-4.19.23-bone-rt-r22 | grep CONFIG_PREEMPT_RT_FULL=yes
machinekit@beaglebone:~$
machinekit@beaglebone:~$ uname -a
Linux beaglebone 4.19.23-bone-rt-r22 #1stretch Sat Feb 16 22:07:49 UTC 2019 armv7l GNU/Linux


Actually looking at /boot/config-4.19.23-bone-rt-r22 here is what I found with respect to CONFIG_PREEMPT_*
CONFIG_HAVE_PREEMPT_LAZY=y
CONFIG_PREEMPT_NONE=y
# CONFIG_PREEMPT_VOLUNTARY is not set
# CONFIG_PREEMPT__LL is not set
# CONFIG_PREEMPT_RTB is not set
# CONFIG_PREEMPT_RT_FULL is not set

Even though machinekit “runs” i.e., starts up, it is clear that rt-preempt is not configured correctly to run machinekit in realtime. I can’t run my linux pc at the moment to look at how that config should be set, but I believe that at the very least these changes should be made

# CONFIG_HAVE_PREEMPT_LAZY
# CONFIG_PREEMPT_NONE
# CONFIG_PREEMPT_VOLUNTARY is not set
# CONFIG_PREEMPT__LL is not set
# CONFIG_PREEMPT_RTB is not set
CONFIG_PREEMPT_RT_FULL=y 

Thanks,
Alan

You received this message because you are subscribed to a topic in the Google Groups "Machinekit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/machinekit/J9A7m9c8k74/unsubscribe.
To unsubscribe from this group and all its topics, send an email to machinekit+...@googlegroups.com.

schoo...@gmail.com

unread,
Feb 19, 2019, 11:38:46 AM2/19/19
to Condit Alan, Machinekit, Robert Nelson
Thanks, that is what I suspected.

The main test for rt-preempt in rtapi_compat.c , is getting the value in /sys/kernel/realtime, which should exist and be '1'
If that does not exist, it is going to default to POSIX, which is the base fallback.

That is what has been happening.

I would expect a rt-preempt kernel to have a config with the following set:

CONFIG_PREEMPT=y
CONFIG_PREEMPT_RT_BASE=y
CONFIG_HAVE_PREEMPT_LAZY=y
CONFIG_PREEMPT_LAZY=y
CONFIG_PREEMPT_RT_FULL=y
CONFIG_PREEMPT_COUNT=y
# CONFIG_PREEMPT_NONE is not set

# CONFIG_PREEMPT_VOLUNTARY is not set
# CONFIG_PREEMPT__LL is not set
# CONFIG_PREEMPT_RTB is not set

You can see the differences.

If that kernel works, you can force the flavor detection by setting the env var,
but without those options set when built, not clear how realtime it can be.

Robert Nelson

unread,
Feb 19, 2019, 12:06:49 PM2/19/19
to Condit Alan, Arc Eye, Machinekit
On Tue, Feb 19, 2019 at 10:26 AM Condit Alan <mugg...@gmail.com> wrote:
>
> Schooner and Robert,
>
> OK, here is what I see when I run those tests. Rather than grep the results of uname -r, I just printed out uname -r.
>
> machinekit@beaglebone:~$ cat /sys/kernel/realtime
> cat: /sys/kernel/realtime: No such file or directory
> machinekit@beaglebone:~$ cat /boot/config-4.19.23-bone-rt-r22 | grep CONFIG_PREEMPT_RT_FULL=yes
> machinekit@beaglebone:~$
> machinekit@beaglebone:~$ uname -a
> Linux beaglebone 4.19.23-bone-rt-r22 #1stretch Sat Feb 16 22:07:49 UTC 2019 armv7l GNU/Linux
>
>
> Actually looking at /boot/config-4.19.23-bone-rt-r22 here is what I found with respect to CONFIG_PREEMPT_*
> CONFIG_HAVE_PREEMPT_LAZY=y
> CONFIG_PREEMPT_NONE=y
> # CONFIG_PREEMPT_VOLUNTARY is not set
> # CONFIG_PREEMPT__LL is not set
> # CONFIG_PREEMPT_RTB is not set
> # CONFIG_PREEMPT_RT_FULL is not set

Ah Crap, 22 builds into the v4.19.x branch and we missed that...

https://github.com/RobertCNelson/bb-kernel/commit/b84cdf5a972d5e9f4347a37d6fa486ce92ab0c6b

pushing to build farm right now.

Regards,

--
Robert Nelson
https://rcn-ee.com/

Robert Nelson

unread,
Feb 19, 2019, 3:44:13 PM2/19/19
to Condit Alan, Arc Eye, Machinekit
and now available:

sudo /opt/scripts/tools/update_kernel.sh

Condit Alan

unread,
Feb 19, 2019, 7:09:31 PM2/19/19
to Robert Nelson, Arc Eye, Machinekit
OK here are the test results:

machinekit@beaglebone:~$ cat /sys/kernel/realtime
1
machinekit@beaglebone:~$ cat /boot/config-4.19.23-bone-rt-r23  | grep CONFIG_PREEMPT_RT_FULL=y
CONFIG_PREEMPT_RT_FULL=y
machinekit@beaglebone:~$ uname -a
Linux beaglebone 4.19.23-bone-rt-r23 #1stretch PREEMPT RT Tue Feb 19 17:12:46 UTC 2019 armv7l GNU/Linux
machinekit@beaglebone:~

I am getting some errors on the Axis screen but I am running inside without a controller attached.
However, that said, it boots with no problem and starts machinekit. So I guess the next step is to take the
BBB back out to the shop and try running the machine!

Schooner, you said rtapi.c tests for cat /boot/config-4.19.23-bone-rt-r23 | grep CONFIG_PREEMPT_RT_FULL=yes but that test failed, I looked at the config and saw that CONFIG_PREEMPT_RT_FULL was set to “y” not “yes”. Did you really mean “yes” or is “y” OK?

Thanks,
Robert and Schooner

schoo...@gmail.com

unread,
Feb 20, 2019, 2:13:54 AM2/20/19
to Condit Alan, Robert Nelson, Machinekit


On 2/20/2019 12:09 AM, Condit Alan wrote:
OK here are the test results:

machinekit@beaglebone:~$ cat /sys/kernel/realtime
1
machinekit@beaglebone:~$ cat /boot/config-4.19.23-bone-rt-r23  | grep CONFIG_PREEMPT_RT_FULL=y
CONFIG_PREEMPT_RT_FULL=y
machinekit@beaglebone:~$ uname -a
Linux beaglebone 4.19.23-bone-rt-r23 #1stretch PREEMPT RT Tue Feb 19 17:12:46 UTC 2019 armv7l GNU/Linux
machinekit@beaglebone:~

I am getting some errors on the Axis screen but I am running inside without a controller attached.
However, that said, it boots with no problem and starts machinekit. So I guess the next step is to take the
BBB back out to the shop and try running the machine!

Schooner, you said rtapi.c tests for cat /boot/config-4.19.23-bone-rt-r23 | grep CONFIG_PREEMPT_RT_FULL=yes but that test failed, I looked at the config and saw that CONFIG_PREEMPT_RT_FULL was set to “y” not “yes”. Did you really mean “yes” or is “y” OK?

I didn't say that, I just asked you to do it because I suspected the config was not properly set.

The test in rtapi_compat.c is just for /sys/kernel/realtime which is always 1 for a rt-preempt kernel

I copied what was in my current kernel config, but I think I have seen both, =y and =yes,  =y especially regards modules in a kernel.

Anyway looks like it is sorted now, thanks Robert

Reply all
Reply to author
Forward
0 new messages