# Features
Source: [https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html](https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html)
The system performance is influenced by several components, including the CPU
scheduler, CPU frequency governor, performance abstraction layer (PerfHAL), dynamic voltage
frequency scaling (DVFS), and memory management.
The Linux kernel provides standard features such as the CPU scheduler, CPU frequency
governor, DVFS, and memory management. An overview of each feature and related reference
links are provided in this guide for your reference. Additionally, PerfHAL is a feature
added by Qualcomm to enhance performance.
## CPU scheduler
Source: [https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html](https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html)
The CPU scheduler is responsible for managing the distribution of CPU time among the
processes running on Linux systems.
The CPU architecture uses [Arm big.LITTLE technology](https://www.arm.com/technologies/big-little) and consists of the
following cores:
- 4 big cores – 1 Prime core and 3 Gold cores
- 4 LITTLE cores (also known as Silver cores)
The CPU scheduler uses the earliest eligible virtual deadline first (EEVDF) scheduler, a
feature provided by the Linux kernel. The EEVDF CPU scheduler uses per entity load
tracking (PELT) to monitor the task load.
- For more information on the EEVDF scheduler, see [An EEVDF
CPU scheduler for Linux](https://lwn.net/Articles/925371/).
- For more information on PELT, see [Per-entity load tracking \[LWN.net\]](https://lwn.net/Articles/531853/).
Utilization clamping (UCLAMP or util clamp) is a scheduler feature that enables the
management of performance requirements for tasks. For more information, see [https://docs.kernel.org/scheduler/sched-util-clamp.html](https://docs.kernel.org/scheduler/sched-util-clamp.html).
For related information, see [Customize CPU scheduler](https://docs.qualcomm.com/doc/80-70014-10/topic/18-customize.html#customize-scheduler).
## CPU frequency governor
Source: [https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html](https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html)
A CPU frequency governor is responsible for adjusting the CPU frequency in response
to the system load, which is determined by the tasks being executed. The CPU scheduler
provides the necessary inputs for this process.
Qualcomm Linux uses the `schedutil` governor, a feature provided by the
Linux kernel.
This governor increases the frequency when the system is heavily loaded and reduces it
when the load is low, ensuring an optimal balance between power consumption and
performance.
For more information on the CPU frequency governor, see [https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt](https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt) and [https://www.kernel.org/doc/html/v5.0/admin-guide/pm/cpufreq.html](https://www.kernel.org/doc/html/v5.0/admin-guide/pm/cpufreq.html).
For more information on the CPU frequency governor configuration and customization, see
[Configure CPU](https://docs.qualcomm.com/doc/80-70014-10/topic/14-configure.html#cpu) and [Customize CPU frequency governor](https://docs.qualcomm.com/doc/80-70014-10/topic/18-customize.html#cpu-frequency-governer).
## DVFS governors
Source: [https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html](https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html)
DVFS governors control the frequencies of CPU caches (L3), last level cache
controller (LLCC), and DDR based on the system workload.
These governors increase the frequency when the workload is high and decrease it when the
workload is low, ensuring an optimal balance between power consumption and
performance.
Qualcomm Linux supports two types of DVFS governors for L3 cache, LLCC, and DDR.
### Static map DVFS governor
This governor aligns the frequencies of the CPU L3 cache and DDR with the current
operating CPU frequency to balance power and performance requirements.
For instance, if the CPU frequency is at its maximum, the L3 cache and DDR
frequencies must also be at their maximum levels for optimal performance and power
efficiency.
The static mapping for QCS6490 and QCS5430 can be found in the source code at
kernel/arch/arm64/boot/dts/qcom/sc7280.dtsi.
For customization options, see [Customize static map DVFS governor](https://docs.qualcomm.com/doc/80-70014-10/topic/18-customize.html#dvfs_0__section_u1x_jps_51c_caharris_03-20-24-2005-37-832).
### BWMON governor
The bandwidth monitoring (BWMON) governor dynamically adjusts the frequencies of LLCC
and DDR based on the measured traffic flow from the CPU to LLCC and then to DDR.
The BWMON hardware block measures this traffic. It monitors the data throughput
between memory and other subsystems within a specified sampling window and uses this
information to scale the LLCC and DDR frequencies to meet the required
bandwidth.
The BWMON governor driver can be found in the source code at
drivers/soc/qcom/icc-bwmon.c.
For more information on BWMOM, see [\[PATCH v3 0/4\] soc/arm64: qcom: Add initial
version of bwmon](https://lwn.net/ml/linux-kernel/20220531105137.110050-1-krzysztof.kozlowski@linaro.org/).
For customization options, see [Customize BWMON governor](https://docs.qualcomm.com/doc/80-70014-10/topic/18-customize.html#dvfs_0__section_qxs_4ps_51c_caharris_03-20-24-2007-2-926).
## PerfHAL
Source: [https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html](https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html)
PerfHAL is a Qualcomm proprietary service that offers added functionality by making
perflock APIs accessible. It proves beneficial when you need short-term performance
enhancements or power savings.
Perflocks help in modifying system behavior to manage intermittent workloads. For
example, if a specific code segment must run at a higher CPU frequency for a certain
duration, perflocks can be used within that code to boost the CPU frequency.
PerfHAL efficiently handles concurrent perflock requests from multiple clients. When
several requests are aimed at the same resource, PerfHAL aggregates them to achieve the
optimal performance level needed by the device.
When a client’s perflock is no longer active, PerfHAL releases all the perflocks
associated with that client.
### Perflock APIs
Source: [https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html](https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html)
Perflock APIs are designed to allow applications to adjust system parameters for
specific use cases, helping them meet their performance and power objectives.
User space applications utilize the perf\_lock\_acq() and
perf\_lock\_rel() APIs to request specific values of system tunable
parameters for a set or indefinite time period.
### Acquire perflock
The perf\_lock\_acq() function is used to acquire a perflock along
with a list of necessary optimizations.
The syntax for this function is: `int perf_lock_acq(int handle, int duration,
int list[], int numArgs)`.
- The duration parameter can be set for a specific time or indefinitely
`(0)`.
- For a timed or definite duration, the perflock is automatically released
once the duration has expired.
- To manually release a perflock that has been set for an indefinite duration,
you can use the perf\_lock\_rel() function.
Table : perf_lock_acq API parameters
| Parameters | Description |
| --- | --- |
| `handle` | Identifies the client request. |
| `duration` |
Indicates the maximum timeout period that the perflock must be held, in milliseconds.
durationis of 2 types: definite and indefinite.
Definite perflocks require a positive integer value to specify the maximum timeout period. A timer is created and the perflock is released when the timer expires.
Indefinite perflocks are held until the client calls the release function.
|
| `list` | An array of resource opcodes and value pairs:
Opcodes indicate a system parameter (resource) and the value to set it (level).
|
| `numArgs` | Number of elements in the list array. |
Table : perf_lock_acq API returns and result
| Returns | Result |
| --- | --- |
| A non-zero integer | Success |
| -1 | Failure |
### Perflock release
The perf\_lock\_rel() function is used to release a held
perflock.
If the perflock has a definite duration, it is not necessary to call
perf\_lock\_rel(), as the perflock will be automatically
released when the duration expires. To use the perf\_lock\_rel()
API, you can run the following command:
int perf_lock_rel(int handle)Copy to clipboard
Table : perf_lock_rel API parameters
| Parameter | Description |
| --- | --- |
| `handle` |
Tracks unique requests.
Passes the same handle that perf_lock_acq returns in order to release the lock.
|
Table : perf_lock_rel API returns and result
| Returns | Result |
| --- | --- |
| A non-zero integer | Success |
| -1 | Failure |
### Resource opcodes
Source: [https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html](https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html)
Perflock uses a combination of opcodes and their corresponding values to perform
specific operations on a perflock resource.
A perflock can accept multiple opcodes, which are defined in the source code at
sources\vendor\qcom\proprietary\perf-core\extnIntf\PerflocksResources.h.
The following table lists the supported opcodes:
Table : Supported opcodes
| Opcodes | Perflock resource | Purpose | Sysnode |
| --- | --- | --- | --- |
| 0x44000000 | `MPCTLV3_UPSTREAM_SCHED_UTIL_CLAMP_MIN` | Sets the minimum acceptable performance level for individual tasks and task groups. | /proc/sys/kernel/sched\_util\_clamp\_min |
| 0x44004000 | `MPCTLV3_UPSTREAM_SCHED_UTIL_CLAMP_MAX` | Sets the maximum acceptable performance level for individual tasks and task groups. | /proc/sys/kernel/sched\_util\_clamp\_max |
| 0x44008100 | `MPCTLV3_UPSTREAM_SCALING_MIN_FREQ_LITTLE` | Sets the minimum frequency of the Silver cluster. | /sys/devices/system/cpu/cpufreq/policy0/scaling\_min\_freq |
| 0x44008000 | `MPCTLV3_UPSTREAM_SCALING_MIN_FREQ_BIG` | Sets the minimum frequency of the Gold cluster. | /sys/devices/system/cpu/cpufreq/policy4/scaling\_min\_freq |
| 0x44008200 | `MPCTLV3_UPSTREAM_SCALING_MIN_FREQ_PRIME` | Sets the minimum frequency of the Prime cluster. | /sys/devices/system/cpu/cpufreq/policy7/scaling\_min\_freq |
| 0x4400C100 | `MPCTLV3_UPSTREAM_SCALING_MAX_FREQ_LITTLE` | Sets the maximum frequency of the Silver cluster. | /sys/devices/system/cpu/cpufreq/policy0/scaling\_max\_freq |
| 0x4400C000 | `MPCTLV3_UPSTREAM_SCALING_MAX_FREQ_BIG ` | Sets the maximum frequency of the Gold cluster. | /sys/devices/system/cpu/cpufreq/policy4/scaling\_max\_freq |
| 0x4400C200 | `MPCTLV3_UPSTREAM_SCALING_MAX_FREQ_PRIME` | Sets the maximum frequency of the Prime cluster. | /sys/devices/system/cpu/cpufreq/policy7/scaling\_max\_freq |
The following are some examples of the resource opcodes:
- 0x44004100, 1958400: This pair of opcode and value indicates that the minimum
frequency of the Silver cluster must be set to 1958400 KHz.
- 0x44004100, 1958400, 0x44008100, 2100000: This set of opcode-value pair indicates
that the minimum frequency of the Silver cluster must be set to 1958400 KHz. The
maximum frequency of the Silver cluster must be set to 2100000 KHz.
For more information on how to use and debug perflock, see [Customize perflock](https://docs.qualcomm.com/doc/80-70014-10/topic/18-customize.html#customize-perlocks).
## Memory
Source: [https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html](https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html)
RAM is used for all memory allocations made by the software. Effective management of
RAM is crucial to meet performance requirements and ensure the smooth functioning of
applications.
Figure : Memory partitioning

Certain sections of RAM are managed independently of the Linux system. For example,
firmware such as modem, video, and audio run from these specific RAM partitions. The
Linux kernel manages all other RAM partitions.
The Linux kernel features its own memory management subsystem, which includes the
following components:
- Implementation of virtual memory and demand paging
- Memory allocation for both kernel internal structures and user space
programs
- Mapping of files into the address space of the processes
- Other memory management operations
### RAM memory partitioning
The following table describes various types of memory allocations.
| RAM classification | Memory segment | Allocation types | Description |
| --- | --- | --- | --- |
| Non-Linux | – | – |
Memory is reserved in the form of carveouts by various subsystems other than Linux.
These carveouts are specified in the respective DTSI files.
The kernel page structure is the memory used by the kernel to maintain page structures for every page of RAM. This is calculated as 16 MB per GB of RAM size.
|
| Linux (system RAM) | Kernel dynamic | Slab |
The slab is used by the kernel for faster and more efficient memory usage of frequently used data structures.
To check the memory usage of the slab, run the following command:
cat /proc/meminfo | grep -i slab
To understand the breakup of various slabs and their usage, enable CONFIG_SLUB_DEBUG in the kernel configuration, and then run the following command:
Buffers are of fixed size and contain blocks of information either read from disk or written to disk.
To check the buffer memory usage, run the following command:
cat /proc/meminfo | grep -i Buffers
|
| Linux (system RAM) | Kernel dynamic | Shmem |
Shared memory is a common block of memory that is mapped into the address spaces of two or more processes.
To check the shared memory usage, run the following command:
cat /proc/meminfo | grep -i shmem
|
| Linux (system RAM) | User space | ZUSED (ZRAM) | An anonymous memory post compression by ZRAM. |
| Linux (system RAM) | User space | CMA |
A physically continuous memory is typically mapped to other IPs such as, video and display, however allocated to the runtime.
Using more CMA reservations reduces the free memory that can be used by the system. The CMA reserved free memory can only be used by movable allocations such as user space process allocations. However, it cannot be used for the kernel allocations.
|
| Linux (system RAM) | User space | ANON |
Memory that user space applications allocate using malloc() or new() function calls.
To get the ANON memory breakup for a process, run the following command:
cat /proc/<pid>/smaps
|
| Linux (system RAM) | User space | ION |
ION memory allows sharing buffers between hardware IPs such as video, camera, and Linux software.
ION manages one or more memory pools, which can be set aside at boot time to combat fragmentation.
To check the ION memory usage, run the following commands:
To check the overall kernel graphics support layer (KGSL) memory usage, run the following command:
cat /sys/class/kgsl/kgsl/page_alloc
To check the process level breakup, run the following command:
cat /sys/class/kgsl/kgsl/proc/<pid>/kernel
|
| Linux (system RAM) | Free memory | – |
Free memory is the memory that is not yet used and is available for any allocation.
To check the free memory, run the following command:
cat /proc/meminfo | grep -i MemFree
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
## Real-Time kernel
Source: [https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html](https://docs.qualcomm.com/doc/80-70014-10/topic/2-performance-features.html)
Real-Time (RT) Linux is an optional feature that is not enabled by default on the
Qualcomm Linux platform. It can be enabled based on the product requirements.
RT Linux is designed to offer deterministic and predictable behavior for applications
that are time-sensitive.
### Set up workspace
In Qualcomm Linux, the RT Linux kernel recipe is referred to as
`linux-kernel-qcom-rt`.
The Qualcomm Linux kernel supports v6.6 LTS RT kernel, which is maintained through
the Yocto recipe in the `meta-qcom-realtime` layer at
recipes-kernel/linux/linux-kernel-qcom-rt\_6.6.bb.
For more information on how to clone the workspace and acquire all the meta layers to
use Qualcomm RT Linux, see [How to sync and build with real-time
Linux](https://docs.qualcomm.com/bundle/publicresource/topics/80-70014-254/how_to.html#how-to-sync-and-build-with-real-time-linux-).
### Enable RT kernel
The RT kernel is enabled using a Linux RT kernel recipe. This recipe fetches the
kernel, downloads pre-empt RT patches, and applies them to the kernel. It also
enables a fully pre-emptible kernel with:
`CONFIG_PREEMPT_RT=y`.
For more information on the RT kernel, see [https://wiki.linuxfoundation.org/realtime/start](https://wiki.linuxfoundation.org/realtime/start).
Finally, add the following recipe to the source code at
recipes-kernel/linux/linux-kernel-qcom\_6.6.bb.
SECTION = "RT kernel"
SUMMARY = "Linux Real time kernel for QCOM devices"
DESCRIPTION = "Recipe to build real time Linux kernel"
SRC_URI:append = "https://cdn.kernel.org/pub/linux/kernel/projects/rt/6.6/older/patch-6.6.14-rt21.patch.gz;md5sum=91969a704a73aa918c89d3027bdd3634 \
file://qcom_rt.cfg \
file://0001-arch-Kconfig-Add-RT-kernel-support.patch \
file://0001-printk-nbcon-move-locked-port-flag-to-struct-uart-port.patch \
"
S = "${WORKDIR}/kernel"
KERNEL_CONFIG_FRAGMENTS:append = " ${WORKDIR}/qcom_rt.cfg"
Copy to clipboard
### Optimize RT kernel
The following are some additional configurations to optimize the performance of the
RT kernel:
# CONFIG_NO_HZ
$ zcat proc/config.gz | grep NO_HZ
CONFIG_NO_HZ_COMMON=y
# CONFIG_NO_HZ_IDLE is not set
CONFIG_NO_HZ_FULL=y
# CONFIG_NO_HZ is not set
#CONFIG_CPUSETS
$ zcat proc/config.gz | grep CPUSETS
CONFIG_CPUSETS=y
Copy to clipboard
When `CONFIG_NO_HZ_FULL` is enabled, the configuration prevents
sending scheduling-clock interrupts to CPUs that are running a single task.
The `CONFIG_CPUSETS` configuration option enables the use of CPUSETS,
where CPUs are grouped into a specific set to run a specific group of tasks.
For information on CPUSET, see [https://docs.kernel.org/admin-guide/cgroup-v1/cpusets.html](https://docs.kernel.org/admin-guide/cgroup-v1/cpusets.html).
### Verify kernel type
After boot up, you can verify the kernel type by running the following command:
uname -v
SMP PREMPT_RT
Copy to clipboard
Last Published: Jul 12, 2024
[Previous Topic
Getting started](https://docs.qualcomm.com/bundle/publicresource/80-70014-10/topics/get-started.md) [Next Topic
Analysis tools](https://docs.qualcomm.com/bundle/publicresource/80-70014-10/topics/13-performance_tools.md)