How to Enhance Real-Time Performance of Linux 6.1 Kernel on OK-MX9352-C by Applying Real-Time Patche

Posted by Andy L.
6
Jan 3, 2025
73 Views

As we all know, the Linux system is a non-real-time system based on time-slice scheduling, and its real-time performance is difficult to meet the timing requirements of industrial applications. Therefore, in many scenarios, the Linux operating system cannot be used. Of course, this limitation has been improved. Currently, the Linux community has added many versions of real-time patches. By applying these real-time patches to the Linux kernel, its real-time performance can be significantly enhanced.

1. Download the patch

Download the real-time patch corresponding to the Linux version. We need to download the real-time patch for Linux 4.1.15.

Index of /pub/linux/kernel/projects/rt/6.1/

The kernel version we are using is Linux 6.1.36. Find a similar patch in the “older” section: patches-6.1.33-rt11.tar.gz.

2. Type into the kernel

unpack patches-6.1.33-rt11.tar.gz to the sdk path, which is the upper layer of the kernel source code.

$ ls
OKMX93-linux-fs 
                        OKMX93-linux-kernel  appsrc  build.sh
environment-setup-aarch64-toolchain extra  images  patches  patches-6.1.33-rt11.tar.gz  tools

Since more than 200 patches are in the extracted patch, use a script in the kernel directory to merge the patches.

$ cd OKMX93-linux-kernel 

The script reads as follows:

#!/bin/sh
cat ../patches/series | while read line
do
    patch -p1 < ../patches/$line done

After executing this script, compile the kernel

make Image -j16 

3. Test real-time

3.1 cross-compiling cyctest

git clone git://git.kernel.org/pub/scm/utils/rt-tests/rt-tests.git
cd rt-tests/
git checkout -b v1.0 origin/stable/v1.0

Modify Makefile

#CC?=$(CROSS_COMPILE)gcc
#AR?=$(CROSS_COMPILE)ar

Compile

make 

3.2 cyclictest test method

Load the compiled cyclictest onto the board and increase its executable permissions, you can use the cyclictest command to carry out real-time performance testing of the Linux kernel, the test command is:

root@fl-imx6ull:~#  ./cyclictest -t8 -p 80 -n -i 10000 -l 10000

Specific parameters can be used as a reference:

-p

--prio = thread with PRIO ordinal 0

The priority usage method for the highest priority thread is: -p 90 / --prio=90

-m

--mlockall thread priority is 0

Lock current and future memory allocation

-c

--clock=CLOCK Counter. Every time interval of the thread is reached, the counter is increased by 1.

Select clock cyclictest -C 1 0 = CLOCK _ MONOTONIC (default) 1 = CLOCK _ REALTIME

-i

--interval=INTV

Basic thread interval, default is 1000 (unit is us)

-l

--loops=LOOPS

The number of cycles, which is 0 (infinite) by default, can be combined with the number of -I intervals to roughly calculate the time of the entire test, for example, -I 1000-l 1000000, the total cycle time is 1000 * 1000000 = 1000000000 us = 1000s, so it is roughly more than 16 minutes

-n

--nanosleep

Use clock_nanosleep

-h

--histogram=US

Draw a histogram of the delay on a standard output device after execution (many threads have the same permissions) US is the maximum trace time limit.

-q

--quiet

The -q parameter prints no information at runtime, only a summary on exit, which in combination with the -h HISTNUM parameter prints HISTNUM line statistics and a general summary on exit.

-f

--ftrace

The ftrace function traces (usually used with -b, in fact -b is usually used without -f)

-b

--breaktrace=USEC

Sends a stop trace when the delay exceeds the value specified by the USEC. USEC, in milliseconds (us)

Run Result Meaning:

T:0

Serial number is 0

P:0

Thread priority is 0

C:1000

Counter. Every time interval of the thread is reached, the counter is increased by 1.

I: 1000

Time interval is 1000 microseconds (us)

Min:

Minimum Delay (us)

Act:

Last Delay (us)

1 people like it
avatar
Comments
avatar
Please sign in to add comment.
Join APSense Today
APSense - All-in-One Business Hub

Join Our Business Community

Unlock access to powerful business tools and connect with professionals in your industry!

As a member, you'll get:

  • Professional Business Profile
  • Article Publishing & Networking
  • Access to NicheHub with AI Tools
  • APSense Challenges & Rewards

"APSense 2025 sounds like a game-changer for businesses, emphasizing innovation and growth."

— Satisfied APSense Member

©2025 APSense LTD. All Rights Reserved.