Skip to content

Commit 08f97b2

Browse files
Revise documentation for profiling Linux kernel modules with Arm Streamline, enhancing clarity and structure across multiple sections, including overviews, setup instructions, and profiling steps for both out-of-tree and in-tree modules.
1 parent 4234a33 commit 08f97b2

7 files changed

Lines changed: 86 additions & 61 deletions

File tree

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
---
2-
title: Overview
2+
title: Profile Linux kernel modules with Arm Streamline
33
weight: 2
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Linux kernel profiling with Arm Streamline
9+
## Overview
1010

11-
Performance tuning is not limited to user-space applications—kernel modules can also benefit from careful analysis. [Arm Streamline](https://developer.arm.com/Tools%20and%20Software/Streamline%20Performance%20Analyzer) is a powerful software profiling tool that helps developers understand performance bottlenecks, hotspots, and memory usage, even inside the Linux kernel. This learning path explains how to use Arm Streamline to profile a simple kernel module.
11+
Performance tuning is not limited to user-space applications as kernel modules can also benefit from careful analysis. [Arm Streamline](https://developer.arm.com/Tools%20and%20Software/Streamline%20Performance%20Analyzer) is a powerful software profiling tool that helps developers understand performance bottlenecks, hotspots, and memory usage, even inside the Linux kernel. This Learning Path explains how to use Arm Streamline to profile a simple kernel module.
12+
## Benefits of profiling Linux kernel modules with Arm Streamline
1213

13-
### Why profile a kernel module?
14+
Kernel modules often operate in performance-critical paths, such as device drivers or networking subsystems. Even a small inefficiency in a module can affect the overall system performance.
1415

15-
Kernel modules often operate in performance-critical paths, such as device drivers or networking subsystems. Even a small inefficiency in a module can affect the overall system performance. Profiling enables you to:
16+
Profiling enables you to:
1617

17-
- Identify hotspots (functions consuming most CPU cycles)
18-
- Measure cache and memory behavior
19-
- Understand call stacks for debugging performance issues
18+
- Identify hotspots (functions consuming most CPU cycles)
19+
- Measure cache and memory behavior
20+
- Understand call stacks for debugging performance issues
21+
- Detect synchronization bottlenecks and race conditions
22+
- Quantify the impact of code changes on system latency and throughput
23+
- Validate that optimizations improve performance on Arm-based systems
24+
25+
By using Arm Streamline, you gain visibility into how your kernel module interacts with the rest of the system. This insight helps you make data-driven decisions to optimize code paths, reduce resource contention, and ensure your module performs efficiently on Arm platforms. Profiling is especially valuable when porting modules from x86 to Arm, as architectural differences can reveal new optimization opportunities or highlight previously hidden issues.
Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,51 @@
11
---
2-
title: Build Linux image
2+
title: Set up your environment
33
weight: 3
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
77
---
88

9-
## Install packages
9+
## Prepare your development environment for Buildroot on Arm
1010

11-
```
11+
Before you build a Linux image with Buildroot, make sure your development environment includes all required packages. These tools and libraries are essential for compiling, configuring, and assembling embedded Linux images on Arm platforms. Installing them now helps you avoid build errors and ensures a smooth workflow.
12+
13+
## Install required packages for Buildroot on Arm
14+
15+
Run the following commands on your aarch64-based Linux system to update your package list and install the necessary dependencies:
16+
17+
```bash
1218
sudo apt update
13-
sudo apt install -y which sed make binutils build-essential diffutils gcc g++ bash patch gzip \
19+
sudo apt install -y which sed make binutils build-essential diffutils gcc g++ bash patch gzip \
1420
bzip2 perl tar cpio unzip rsync file bc findutils gawk libncurses-dev python-is-python3 \
1521
gcc-arm-none-eabi
1622
```
1723

24+
These packages ensure that Buildroot can configure, compile, and assemble all the components needed for your custom Linux image. If you encounter missing package errors during the build process, check your distribution's documentation for any additional dependencies specific to your environment.
25+
26+
1827
## Build a debuggable kernel image
1928

20-
For this learning path you will be using [Buildroot](https://github.com/buildroot/buildroot) to build a Linux image for Raspberry Pi 3B+ with a debuggable Linux kernel. You will profile Linux kernel modules built out-of-tree and Linux device drivers built in the Linux source code tree.
29+
For this Learning Path you'll be using [Buildroot](https://github.com/buildroot/buildroot) to build a Linux image for Raspberry Pi 3B+ with a debuggable Linux kernel. You'll profile Linux kernel modules built out-of-tree and Linux device drivers built in the Linux source code tree.
2130

22-
1. Clone the Buildroot Repository and initialize the build system with the default configurations.
31+
Start by cloning the Buildroot Repository and initialize the build system with the default configurations:
2332

2433
```bash
2534
git clone https://github.com/buildroot/buildroot.git
2635
cd buildroot
2736
export BUILDROOT_HOME=$(pwd)
2837
make raspberrypi3_64_defconfig
2938
```
30-
{{% notice Using a different board %}}
31-
If you're not using a Raspberry Pi 3 for this Learning Path, change the `raspberrypi3_64_defconfig` to the option that matches your hardware in `$(BUILDROOT_HOME)/configs`
32-
{{% /notice %}}
33-
34-
2. You will use `menuconfig` to configure the setup. Invoke it with the following command:
39+
{{% notice Note on using a different board%}}
40+
If you're not using a Raspberry Pi 3B+ for this Learning Path, select the default configuration that matches your hardware. Replace `raspberrypi3_64_defconfig` with the appropriate file from the `$(BUILDROOT_HOME)/configs` directory. This ensures Buildroot generates an image compatible with your target board.{{% /notice %}}
3541

3642
```
3743
make menuconfig
3844
```
3945

40-
![Menuconfig UI for Buildroot configuration](./images/menuconfig.png)
46+
![Buildroot menuconfig interface showing configuration options. The screen displays a blue dialog box with white text and a highlighted menu. The main menu lists Build options, System configuration, Kernel, and Target packages. The Build options section is selected, and sub-options include build packages with debugging symbols, gcc debug level set to debug level 3, and build packages with runtime debugging info. The environment is a text-based terminal interface, typical for embedded Linux development. The tone is technical and instructional, guiding users through enabling debugging features in Buildroot. alt-text#center](./images/menuconfig.png)
4147

42-
Change Buildroot configurations to enable debugging symbols and SSH access.
48+
Change Buildroot configurations to enable debugging symbols and SSH access:
4349

4450
```plaintext
4551
Build options --->
@@ -62,37 +68,51 @@ Target packages --->
6268
[*] server
6369
[*] key utilities
6470
```
71+
You might need to update your default `sshd_config` file to match your network requirements. To do this, set the **Root filesystem overlay directories** option in the **System configuration** menu. Add a directory containing your customized `sshd_config` file. This ensures your SSH server uses the correct settings when the image boots.
6572

66-
You might also need to change your default `sshd_config` file according to your network settings. To do that, you need to modify System configuration→ Root filesystem overlay directories to add a directory that contains your modified `sshd_config` file.
73+
By default, Linux kernel images are stripped of debugging information. To make the image debuggable for profiling, you need to adjust the kernel build settings.
6774

68-
3. By default the Linux kernel images are stripped. You will need to make the image debuggable as you'll be using it later.
69-
70-
Invoke `linux-menuconfig` and uncheck the option as shown.
75+
Open the kernel configuration menu with:
7176

7277
```bash
7378
make linux-menuconfig
7479
```
7580

81+
In the menu, navigate to **Kernel hacking** and ensure that debugging options are enabled. Uncheck any option that reduces debugging information. This step preserves the symbols needed for effective kernel debugging and profiling.
82+
7683
```plaintext
7784
Kernel hacking --->
7885
-*- Kernel debugging
7986
Compile-time checks and compiler options --->
8087
Debug information (Rely on the toolchain's implicit default DWARF version)
8188
[ ] Reduce debugging information # un-check
8289
```
90+
Now you're ready to build the Linux image and flash it to your SD card for use with the Raspberry Pi.
8391

84-
4. Now you can build the Linux image and flash it to the the SD card to run it on the Raspberry Pi.
92+
Run the following command to start the build process:
8593

8694
```bash
8795
make -j$(nproc)
8896
```
8997

90-
It will take some time to build the Linux image. When it completes, the output will be in `$BUILDROOT_HOME/output/images/sdcard.img`:
98+
This step can take a while, depending on your system's performance. When the build finishes, you'll find the generated image at `$BUILDROOT_HOME/output/images/sdcard.img`.
99+
100+
To confirm that Buildroot created the SD card image, list the contents of the output directory:
91101

92102
```bash
93103
ls $BUILDROOT_HOME/output/images/ | grep sdcard.img
94104
```
95105

106+
The expected output is:
107+
108+
```output
109+
sdcard.img
110+
```
111+
112+
If you see `sdcard.img` listed, your image is ready to be flashed to your SD card. You can now flash this image to your SD card and boot your Raspberry Pi with a debuggable Linux kernel.
113+
96114
For details on flashing the SD card image, see [this helpful article](https://www.ev3dev.org/docs/tutorials/writing-sd-card-image-ubuntu-disk-image-writer/).
97115

98-
Now that you have a target running Linux with a debuggable kernel image, you can start writing your kernel module that you want to profile.
116+
## What you've accomplished and what's next
117+
118+
You've successfully built a custom Linux image with debugging features enabled and flashed it to your Raspberry Pi. This milestone means your development board is now running a kernel that's ready for profiling and advanced debugging. Great job reaching this point! Setting up a debuggable environment is a significant step in embedded Linux development. Next, you'll write and profile your own kernel module, building on the solid foundation you've established.

content/learning-paths/embedded-and-microcontrollers/streamline-kernel-module/3_oot_module.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ weight: 4
66
layout: learningpathall
77
---
88

9-
## Creating the Linux Kernel Module
9+
## Create an out-of-tree Linux kernel module
1010

1111
You will now create an example Linux kernel module (Character device) that demonstrates a cache miss issue caused by traversing a 2D array in column-major order. This access pattern is not cache-friendly, as it skips over most of the neighboring elements in memory during each iteration.
1212

@@ -254,4 +254,4 @@ The module above receives the size of a 2D array as a string through the `char_d
254254
255255
The command above passes 10000 to the module, which specifies the size of the 2D array to be created and traversed. The **echo** command takes a long time to complete (around 38 seconds) due to the cache-unfriendly traversal implemented in the `char_dev_cache_traverse()` function.
256256
257-
With the kernel module built, the next step is to profile it using Arm Streamline. You will use it to capture runtime behavior, highlight performance bottlenecks, and help identifying issues such as the cache-unfriendly traversal in your module.
257+
Great job building and running your kernel module! Now that you have a working example, you're ready to take the next step: profiling it with Arm Streamline. In the following section, you'll use Streamline to capture runtime behavior, identify performance bottlenecks, and see firsthand how cache-unfriendly access patterns impact your module. Get ready to gain valuable insights and optimize your code!

0 commit comments

Comments
 (0)