<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to How to tweak the performance of BeagleBone Black (with realtime)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/249af97b9f/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/249af97b9f/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/249af97b9f/</id><updated>2021-04-26T15:39:54.175000Z</updated><subtitle>Recent posts to How to tweak the performance of BeagleBone Black (with realtime)</subtitle><entry><title>How to tweak the performance of BeagleBone Black (with realtime)</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/249af97b9f/?limit=25#794c" rel="alternate"/><published>2021-04-26T15:39:54.175000Z</published><updated>2021-04-26T15:39:54.175000Z</updated><author><name>laruso</name><uri>https://forge.codesys.com/u/laruso/</uri></author><id>https://forge.codesys.com189196460aafc1a2a409b8a50f30a53fcc202202</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;How to tweak real time performance on a BeagleBone Black?&lt;/p&gt;
&lt;p&gt;In the documentation of the Add-on "CODESYS Control for BeableBone SL", under point "Preparing the PLC", there is the hint to deactivate "Real-Time group scheduling". There is a code segment:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;CONFIG_RT_GROUP_SCHED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;but I don't know were to put (very weak doku here). The only place I found it, was in the kernel configuration files, found in /boot/config-&amp;lt;kernel name=""&amp;gt;. But these file must not be edited.&amp;lt;/kernel&amp;gt;&lt;/p&gt;
&lt;p&gt;In the default kernel configuration files (ti, non-rt, e.g. "config-4.19.94-ti-r42") there is an entry like this:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;CONFIG_RT_GROUP_SCHED&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In other kernel configuration files (bone, non-rt, e.g. "config-4.19.165-bone59" there is an entry like this:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="n"&gt;CONFIG_RT_GROUP_SCHED&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;And in the kernel configuration files of the pre-compiled realtime kernels, there is no entry like this at all.&lt;/p&gt;
&lt;p&gt;I followed the next hint to uninstall the package "libpam-systemd" by shell command "sudo apt-get remove libpam-systemd".&lt;/p&gt;
&lt;p&gt;At least this recommendation is only for BeagleBone Black and not for Raspberry Pi. (confused)&lt;/p&gt;
&lt;p&gt;Next point was to install a precompiled realtime kernel (e.g. 4.19.165-bone-rt-r59) like described at &lt;a href="https://elinux.org/EBC_Exercise_36_PREEMPT_RT." rel="nofollow"&gt;https://elinux.org/EBC_Exercise_36_PREEMPT_RT.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I did the main program in a freewheeling task with priority 16 (low linux default priority), and the time relevant program in a separate task with priority 0 (highest realtime priority) and interval 500 µs.&lt;/p&gt;
&lt;p&gt;In spite of definitely sawing a drop in jitter after doing this, &lt;strong&gt;I want to know if there are any other tweaks to enhance the performance&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;On the other side, I found a post which claims (Edwin cited) to have these entries in the CODESYSControl_User.cfg file, when no realtime is needed. But I found these entries in the actual CODESYSControl.cfg file (in directory /etc/):&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[CmpSchedule]&lt;/span&gt;
&lt;span class="na"&gt;ProcessorLoad.Enable&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;
&lt;span class="na"&gt;ProcessorLoad.Maximum&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;95&lt;/span&gt;
&lt;span class="na"&gt;ProcessorLoad.Interval&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;5000&lt;/span&gt;
&lt;span class="na"&gt;DisableOmittedCycleWatchdog&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Source: &lt;a href="https://forge.codesys.com/forge/talk/Runtime/thread/e82256d0d8/#e81e"&gt;https://forge.codesys.com/forge/talk/Runtime/thread/e82256d0d8/#e81e&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This information confuses me and implicates, that other values are necessary when realtime is needed.&lt;br/&gt;
Questions: &lt;br/&gt;
- Why these entries without realtime?&lt;br/&gt;
- Which entries with realtime?&lt;/p&gt;
&lt;p&gt;With the library "CmpSchedule" and the function "SchedGetProcessorLoad" I can get the information about the CPU usage of the (realtime) kernel threads (60 % right now). But the total CPU usage out of "htop" is about 75 % (because of the additional normal threads). Is there a possibility to also get the CPU usage of non kernel/realtime tasks? Or the overall CPU usage? Or the CPU load averages?&lt;/p&gt;
&lt;p&gt;I was a bit confused when it looked like the CPU is clocked with possibly higher frequency, if the value of parameter "_diMaxSpeed" from the SPI_master is set higher (than expected to be):&lt;br/&gt;
I've read that the BeagleBone Black should only have a SPI capability of 500 kHz. A lower values resulted in a CPU usage overload via watchdog. (After all it's a result of CPU seems to get slower.) So I decided to check higher values and saw the cycle time getting faster, till a threshold is reached. Now the SPI master works fine with 2 MHz for "SPI max speed" parameter. (Don't understand that after all)&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>