# 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` | <ul class="ul" id="perflockapi__ul_fhn_fmz_q1c"><br>                                        <li class="li">Indicates the maximum timeout period that the perflock<br>                                            must be held, in milliseconds.</li><br><br>                                        <li class="li"><code class="ph codeph">duration</code>is of 2 types: definite and<br>                                                indefinite.<ul class="ul" id="perflockapi__ul_htm_rps_s1c"><br>                                                <li class="li">Definite perflocks require a positive integer<br>                                                  value to specify the maximum timeout period. A<br>                                                  timer is created and the perflock is released when<br>                                                  the timer expires.</li><br><br>                                                <li class="li">Indefinite perflocks are held until the client<br>                                                  calls the release function.</li><br><br>                                            </ul><br></li><br><br>                                    </ul> |
| `list` | An array of resource opcodes and value pairs:<br><ul class="ul" id="perflockapi__ul_vf1_dnz_q1c"><br>                                        <li class="li">Opcodes indicate a system parameter (resource) and the<br>                                            value to set it (level).</li><br><br>                                        <li class="li">Opcodes are defined in the following<br>                                                  file:<p class="p"><span class="ph filepath">sources\vendor\qcom\proprietary\perf-core\extnIntf\PerflocksResources.h</span>.</p><br></li><br><br>                                    </ul> |
| `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` | <ul class="ul" id="perflockapi__ul_vhd_bxz_q1c"><br>                                        <li class="li">Tracks unique requests.</li><br><br>                                        <li class="li">Passes the same handle that<br>                                                <code class="ph codeph">perf_lock_acq</code> returns in order to<br>                                            release the lock.</li><br><br>                                    </ul> |

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<br>                                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<br>                                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
            
            ![](data:image/png;base64,UklGRjILAABXRUJQVlA4TCULAAAvwQE2AJfjtrZt01rPfu9HtsPf949+MbYZ2UYRjiPZVpXzFPeVuztZwJoASImoiMDd3d3BcSTbqjJPvuCs3N3Jg7zIiSIAfhK4r9yd+U/A1//v/Hj4Wx8ObtuzA/s6Px7Ojwf5HhL4xrAAWYC+lPqDPLIoAUV0AApoAwyBgU4LoK1dA+havT9A0nQC6+p10PRY3g/fWwvbMMNMl7qIVNCVNl1pu5+8lqu1C9kSqHB9PT1/P68/bu+Xx+fHFlcPsQEcxEAIlRZ8awxmqAnQB1ewBWjBBa5eJAAaqIAywBbYABeeYUbhJkPlAoHEJH6SIjWF2UT+J1Lh9ZVUadHUikgUgQgSlwwRJECRlG/RR9nL/hcjgpU+OrAtrIggx184KhNM0LLGxxorhOGzxBW3OY+mVkEHJRTZRSHnVSo6YH//P7dtm4PT4W2opEsP0iWQPbqzaGpLNaXsvbpLoqRSsCX7//+Su8/38z0eQIwsRfRfFm1bUcMcWrvi0uQwOIDy+h+1wnTdtLp00/Hii21tf9z3ElzuPjaQUsHIpEInBTKz6LUflthABkDn5PXJPUC0mFE7QnwTsJ784mAA/Pu0b+n+6Y3WRDRa9NDCiqDAyH3MFm+2rUV23o/W530gc983SketibUZyN27eynQeXIv6p72LS1pN/zbOUjdpp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qPu0X0eQx+K6IjedDsAxjNIb1l21LXuMxkyIn6yH9rUKVv6EVd+a7Y0faJx3VRG+qQNRgO79J+K4KlqiKMdXblaGelnVcwfPqiEONrRzeqI7/1eG3yq9S0ffhO3vi+K96zXOxamNDv6hzXIWdQmYTmXts0e71mv4m8iIxvAhK6ERG3C7Xb2czkpttnjOesVIErYNFz4HxpGKtdsGz1+s14RohTPZCQBJWqTYtvoV/vNemV+cvUQkVGbwIRPnm3exGPBfJNZrzFTkpAwI8qike+GsR2gjeTKrFcVouFWYyhLEUaKr04aOiIa3ti1gw1mvUolGS90amjUJhmkidgWxVie/JvYeOy1XYNhgjeY9UqVLH/DcL0kjJTohzLbwri43ZRH1GeHmx+c7R85ACXDnvEhJi1qN1Hy0ZnyoSwRBLxJIwagyMgSH2LSonYTJa7D7uvmIgciCHizeC65BeR8PIoPMWlRu1loNE3n2i7ovDWUOYC+ciNG7Im3bSzsGREQZx66HVFSdJwjH8oSQcCb9EIiOzVyiMkLqeQD70+LIOBNGrrQhpg8FkxpwwUGAW/c4H5EwxunpKGuRjAIeOOGhz0jQ0weMDdFh++WkGBdTRse9owNMXlAlDQd0g+VuL2bKFuWZl/frkvIyzdyPEYcRB6v4JDXdeQbPZXHKo9rE/LyDY7HkAuZxys45DInL3clpVRBwGsR9eUbGEXRB1X0OPLsbZzKW8RxrZLQ+3/WoQMBPY68fG2nbXA09ED+f2WeceTFD7QMAixYGr81lD/QHj6wl28svqsTRFpIm/YAefkGGgPbjbyCo8aRZz/QGiAv38jD2bcfSjqobw3JD7QKkoLGgr5vSBzH34XxgtnS9KXGVVMZ6cs2GA3skkj+/kqJ0ybcuNqI0suheOGLMqe/Ur7i/O6rhpRe9KVdpUv/+S6Nl97/qsWl919yXLna6tKVKAIA)

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 | – | – | <ul class="ul" id="memory__ul_p5v_h2m_41c"><br>                                        <li class="li">Memory is reserved in the form of carveouts by various<br>                                            subsystems other than Linux.</li><br><br>                                        <li class="li">These carveouts are specified in the respective DTSI<br>                                            files.</li><br><br>                                    </ul> |
| Linux (system RAM) | Kernel static | Vmlinux + kernel page structures | <ul class="ul" id="memory__ul_gzq_52m_41c"><br>                                        <li class="li">This memory is reserved by the kernel at boot time for<br>                                            its own use.</li><br><br>                                        <li class="li">Vmlinux is the memory used to store the vmlinux<br>                                            image.</li><br><br>                                        <li class="li">The size and breakdown of the vmlinux image can be<br>                                            obtained from the dmesg logs at bootup:<ul class="ul" id="memory__ul_e2b_bfx_3bc_sshewale_05-10-24-1237-20-424"><br>                                                <li class="li"><br>                                                  <pre class="pre codeblock" id="memory__codeblock_yb4_hjm_qbc_sshewale_06-06-24-1520-13-586"><code>Memory: 3061872K/4134912K available (28800K kernel code, 2090K rwdata, 10688K rodata, 3072K init, 969K bss, 679824K reserved, 393216K cma-reserved)</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre><br>                                                </li><br><br>                                                <li class="li"><br>                                                  <pre class="pre codeblock" id="memory__codeblock_uzy_3jm_qbc_sshewale_06-06-24-1520-38-542"><code>Kernel code + rwdata + rodata+init +bss indicates vmlinux kernel image size (28800k+2090k+10688k+3072k+969k)</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre><br>                                                </li><br><br>                                            </ul><br></li><br><br>                                        <li class="li">The kernel page structure is the memory used by the<br>                                            kernel to maintain page structures for every page of<br>                                            RAM. This is calculated as 16&nbsp;MB per GB of RAM<br>                                            size.</li><br><br>                                    </ul> |
| Linux (system RAM) | Kernel dynamic | Slab | <ul class="ul" id="memory__ul_mlr_t1r_51c_caharris_03-20-24-1456-13-798"><br>                                        <li class="li">The slab is used by the kernel for faster and more<br>                                            efficient memory usage of frequently used data<br>                                            structures.</li><br><br>                                        <li class="li">To check the memory usage of the slab, run the following<br>                                            command:<pre class="pre codeblock" id="memory__codeblock_xng_v1r_51c_caharris_03-20-24-1456-41-577"><code>cat /proc/meminfo | grep -i slab</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></li><br><br>                                        <li class="li">To understand the breakup of various slabs and their<br>                                            usage, enable <code class="ph codeph">CONFIG_SLUB_DEBUG</code> in the<br>                                            kernel configuration, and then run the following<br>                                            command:<br>                                            <pre class="pre codeblock" id="memory__codeblock_jfy_bbr_51c_caharris_03-20-24-1458-38-979"><code>cat /proc/slabinfo</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></li><br><br>                                    </ul> |
| Linux (system RAM) | Kernel dynamic | Kernel stack | <ul class="ul" id="memory__ul_dpy_vbx_t1c_caharris_03-17-24-2104-3-233"><br>                                        <li class="li">The kernel stack stores the call stack of every<br>                                            process.</li><br><br>                                        <li class="li">To check the memory usage of the kernel stack, run the<br>                                            following command:<br>                                            <pre class="pre codeblock" id="memory__codeblock_ypc_hbr_51c_caharris_03-20-24-1500-9-838"><code>cat /proc/meminfo | grep -i kernelstack</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></li><br><br>                                    </ul> |
| Linux (system RAM) | Kernel dynamic | PageTables | <ul class="ul" id="memory__ul_omh_jbr_51c_caharris_03-20-24-1500-48-282"><br>                                        <li class="li">The kernel uses memory to store PageTables that map<br>                                            virtual addresses to physical addresses.</li><br><br>                                        <li class="li">To check the memory usage of PageTables, run the<br>                                            following command:<br>                                            <pre class="pre codeblock" id="memory__codeblock_cjx_4br_51c_caharris_03-20-24-1502-26-888"><code>cat /proc/meminfo | grep -i PageTables</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></li><br><br>                                    </ul> |
| Linux (system RAM) | Kernel dynamic | Modules | <ul class="ul" id="memory__ul_lk4_qbr_51c_caharris_03-20-24-1502-55-991"><br>                                        <li class="li">Represents the kernel entities that are dynamically<br>                                            loaded into the kernel in the form of kernel<br>                                            modules.</li><br><br>                                        <li class="li">To display the list of loaded kernel modules and their<br>                                            memory usage, run the following command:<br>                                            <pre class="pre codeblock" id="memory__codeblock_cch_tbr_51c_caharris_03-20-24-1503-43-770"><code>cat /proc/modules</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></li><br><br>                                    </ul> |
| Linux (system RAM) | Kernel dynamic | Vmalloc | <ul class="ul" id="memory__ul_t4t_vbr_51c_caharris_03-20-24-1504-27-363"><br>                                        <li class="li">Used to allocate virtually contiguous memory.</li><br><br>                                        <li class="li">To check the vmalloc memory breakup, run the following<br>                                            command:<br>                                            <pre class="pre codeblock" id="memory__codeblock_lnx_xbr_51c_caharris_03-20-24-1505-5-185"><code>cat /proc/vmallocinfo</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></li><br><br>                                    </ul> |
| Linux (system RAM) | Kernel dynamic | Cached (kernel + user space) | <ul class="ul" id="memory__ul_gys_zbr_51c_caharris_03-20-24-1505-37-238"><br>                                        <li class="li">The amount of file-backed memory that resides in RAM. </li><br><br>                                        <li class="li">To check the cached memory usage, run the following<br>                                            command:<br>                                            <pre class="pre codeblock" id="memory__codeblock_jd3_dcr_51c_caharris_03-20-24-1506-40-239"><code>cat /proc/meminfo | grep -i cached</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></li><br><br>                                    </ul> |
| Linux (system RAM) | Kernel dynamic | Buffers | <ul class="ul" id="memory__ul_g3t_vv2_4bc_sshewale_05-29-24-1054-24-346"><br>                                        <li class="li">Buffers are of fixed size and contain blocks of<br>                                            information either read from disk or written to<br>                                            disk.</li><br><br>                                        <li class="li">To check the buffer memory usage, run the following<br>                                            command:<br>                                            <pre class="pre codeblock" id="memory__codeblock_p22_3cr_51c_caharris_03-20-24-1508-5-447"><code>cat /proc/meminfo | grep -i Buffers</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></li><br><br>                                    </ul> |
| Linux (system RAM) | Kernel dynamic | Shmem | <ul class="ul" id="memory__ul_lkb_1w2_4bc_sshewale_05-29-24-1055-40-115"><br>                                        <li class="li">Shared memory is a common block of memory that is mapped<br>                                            into the address spaces of two or more processes.</li><br><br>                                        <li class="li">To check the shared memory usage, run the following<br>                                            command:<br>                                            <pre class="pre codeblock" id="memory__codeblock_rtk_ncr_51c_caharris_03-20-24-1509-37-775"><code>cat /proc/meminfo | grep -i shmem</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></li><br><br>                                    </ul> |
| Linux (system RAM) | User space | ZUSED (ZRAM) | An anonymous memory post compression by ZRAM. |
| Linux (system RAM) | User space | CMA | <ul class="ul" id="memory__ul_khp_pcr_51c_caharris_03-20-24-1510-15-988"><br>                                        <li class="li">A physically continuous memory is typically mapped to<br>                                            other IPs such as, video and display, however allocated<br>                                            to the runtime.</li><br><br>                                        <li class="li">Using more CMA reservations reduces the free memory that<br>                                            can be used by the system. The CMA reserved free memory<br>                                            can only be used by movable allocations such as user<br>                                            space process allocations. However, it cannot be used<br>                                            for the kernel allocations.</li><br><br>                                    </ul> |
| Linux (system RAM) | User space | ANON | <ul class="ul" id="memory__ul_mss_bw2_4bc_sshewale_05-29-24-1056-9-392"><br>                                        <li class="li">Memory that user space applications allocate using<br>                                                <span class="keyword apiname">malloc()</span> or<br>                                                <span class="keyword apiname">new()</span> function calls. </li><br><br>                                        <li class="li">To get the ANON memory breakup for a process, run the<br>                                            following<br>                                            command:<pre class="pre codeblock" id="memory__codeblock_jr1_zcr_51c_caharris_03-20-24-1513-1-867"><code>cat /proc/&lt;pid&gt;/smaps</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></li><br><br>                                    </ul> |
| Linux (system RAM) | User space | ION | <ul class="ul" id="memory__ul_km4_1dr_51c_caharris_03-20-24-1513-28-778"><br>                                        <li class="li">ION memory allows sharing buffers between hardware IPs<br>                                            such as video, camera, and Linux software.</li><br><br>                                        <li class="li">ION manages one or more memory pools, which can be set<br>                                            aside at boot time to combat fragmentation.</li><br><br>                                        <li class="li">To check the ION memory usage, run the following<br>                                            commands:<pre class="pre codeblock" id="memory__codeblock_zmc_vlg_v1c_caharris_03-22-24-1750-46-225"><code>mount -t debugfs none /sys/kernel/debug</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre><pre class="pre codeblock" id="memory__codeblock_rcx_ddr_51c_caharris_03-20-24-1514-27-337"><code>cat /sys/kernel/debug/dma_buf/bufinfo | grep bytes</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre><br>                                        </li><br><br>                                    </ul> |
| Linux (system RAM) | User space | KGSL | <ul class="ul" id="memory__ul_onb_3dr_51c_caharris_03-20-24-1515-40-628"><br>                                        <li class="li">Memory allocated by the graphics driver. </li><br><br>                                        <li class="li">To check the overall kernel graphics support layer<br>                                            (KGSL) memory usage, run the following command:<br>                                            <pre class="pre codeblock" id="memory__codeblock_pnf_kdr_51c_caharris_03-20-24-1516-18-485"><code>cat /sys/class/kgsl/kgsl/page_alloc</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre><br>                                        </li><br><br>                                        <li class="li">To check the process level breakup, run the following<br>                                            command:<br>                                            <pre class="pre codeblock" id="memory__codeblock_g4k_mdr_51c_caharris_03-20-24-1516-57-34"><code>cat /sys/class/kgsl/kgsl/proc/&lt;pid&gt;/kernel</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></li><br><br>                                    </ul> |
| Linux (system RAM) | Free memory | – | <ul class="ul" id="memory__ul_vrz_d2s_51c_caharris_03-20-24-1840-7-435"><br>                                        <li class="li">Free memory is the memory that is not yet used and is<br>                                            available for any allocation.</li><br><br>                                        <li class="li">To check the free memory, run the following command:<br>                                            <pre class="pre codeblock" id="memory__codeblock_u1g_qdr_51c_caharris_03-20-24-1518-4-285"><code>cat /proc/meminfo | grep -i MemFree</code><span class="copyclip"><svg xmlns="http://www.w3.org/2000/svg" class="copyclipicon" width="25px" height="25px" viewbox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><title>Copy to clipboard</title><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span></pre></li><br><br>                                    </ul> |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |

## 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)