# Configure

Source: [https://docs.qualcomm.com/doc/80-70015-10/topic/14-configure.html](https://docs.qualcomm.com/doc/80-70015-10/topic/14-configure.html)

It is essential to tune the basic configuration settings of your device before
        starting the performance analysis. The settings play a significant role in the performance
        of the device.

Caution:

If you modify the CPU, GPU, and memory settings,
            the power and performance of the device can be impacted. Ensure that you verify the
            impact across all relevant use cases before any modifications.

## Configure CPU

Source: [https://docs.qualcomm.com/doc/80-70015-10/topic/14-configure.html](https://docs.qualcomm.com/doc/80-70015-10/topic/14-configure.html)

You can check and modify the CPU configurations using the commands specified in the
        following table:

Note: The commands containing `policy7` are not
            supported on QCS9075.

Note: The commands specified in the
            following table should be run on the device. The unit of the output value for these
            commands is in KHz.

Table : Commands to configure the CPU

| Command | Purpose |
| --- | --- |
| cat /sys/devices/system/cpu/onlineCopy to clipboard | Checks the online CPU cores. |
| echo 1 > /sys/devices/system/cpu/cpuX/onlineCopy to clipboard | Turns on a CPU core.<br><br><br>                            <br>In cpuX, X represents the number of cores, which ranges from 0 to<br>                                7. |
| echo 0 > /sys/devices/system/cpu/cpuX/onlineCopy to clipboard | Turns off a CPU core.<br>In cpuX, X represents the number of cores,<br>                                which ranges from 0 to 7. |
| cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freqCopy to clipboard<br><br><br>                            <br><br>    cat /sys/devices/system/cpu/cpufreq/policy4/scaling_cur_freqCopy to clipboard<br><br><br>                            <br><br>    cat /sys/devices/system/cpu/cpufreq/policy7/scaling_cur_freqCopy to clipboard | Reads the current frequency of the CPU. |
| cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequenciesCopy to clipboard<br><br><br>                            <br><br>    cat /sys/devices/system/cpu/cpufreq/policy4/scaling_available_frequenciesCopy to clipboard<br><br><br>                            <br><br>    cat /sys/devices/system/cpu/cpufreq/policy7/scaling_available_frequenciesCopy to clipboard | Reads the supported frequencies of the CPU. |
| cat /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freqCopy to clipboard<br><br><br>                            <br><br>    cat /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freqCopy to clipboard<br><br><br>                            <br><br>    cat /sys/devices/system/cpu/cpufreq/policy7/scaling_min_freqCopy to clipboard | Reads the minimum frequency of the CPU. |
| echo <cpu freq in KHz> > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freqCopy to clipboard<br><br><br>                            <br><br>    echo <cpu freq in KHz> > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freqCopy to clipboard<br><br><br>                            <br><br>    echo <cpu freq in KHz> > /sys/devices/system/cpu/cpufreq/policy7/scaling_min_freqCopy to clipboard | Sets the minimum frequency of the CPU. Replace `<cpu freq<br>                                in KHz>` with the required frequency and run the<br>                            commands. |
| cat /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freqCopy to clipboard<br><br><br>                            <br><br>    cat /sys/devices/system/cpu/cpufreq/policy4/scaling_max_freqCopy to clipboard<br><br><br>                            <br><br>    cat /sys/devices/system/cpu/cpufreq/policy7/scaling_max_freqCopy to clipboard | Reads the maximum frequency of the CPU. |
| echo <cpu freq in KHz> > /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freqCopy to clipboard<br><br><br>                            <br><br>    echo <cpu freq in KHz> > /sys/devices/system/cpu/cpufreq/policy4/scaling_max_freqCopy to clipboard<br><br><br>                            <br><br>    echo <cpu freq in KHz> > /sys/devices/system/cpu/cpufreq/policy7/scaling_max_freqCopy to clipboard | To set the maximum frequency of the CPU, replace `<cpu freq<br>                                in KHz>` with the required frequency and run the<br>                            commands. |
| cat /sys/devices/system/cpu/cpufreq/policy0/stats/trans_tableCopy to clipboard<br><br><br>                            <br><br>    cat /sys/devices/system/cpu/cpufreq/policy4/stats/trans_tableCopy to clipboard<br><br><br>                            <br><br>    cat /sys/devices/system/cpu/cpufreq/policy7/stats/trans_tableCopy to clipboard | Checks the CPU residency. |
| For example, to set the CPU frequency of the Silver core at 1.5 GHz,<br>                                run the following commands:<br>                                <br><br>    echo 1516800 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freqCopy to clipboard<br><br><br><br>    echo 1516800 > /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freqCopy to clipboard | To set the CPU frequency at a required level, both<br>                                    `scaling_min_freq` and<br>                                    `scaling_max_freq` should be set to the same<br>                                frequency. |

## Configure GPU

Source: [https://docs.qualcomm.com/doc/80-70015-10/topic/14-configure.html](https://docs.qualcomm.com/doc/80-70015-10/topic/14-configure.html)

You can check and modify the GPU configurations on the device using the commands
        specified in the following table:

Note: The commands specified in the
            following table should be run on the device. The unit of the output value for these
            commands is in Hz.

Table : Commands to configure the GPU

| Command | Purpose |
| --- | --- |
| cat /sys/class/kgsl/kgsl-3d0/gpuclkCopy to clipboard | Reads the current frequency of the GPU. |
| cat /sys/class/kgsl/kgsl-3d0/gpu_available_frequenciesCopy to clipboard | Reads the supported GPU frequencies. |
| cat /sys/class/kgsl/kgsl-3d0/devfreq/min_freqCopy to clipboard | Reads the minimum frequency of the GPU. |
| echo <GPU freq in Hz> > /sys/class/kgsl/kgsl-3d0/devfreq/min_freqCopy to clipboard | Sets the minimum frequency of the GPU. Replace `<GPU freq<br>                                in Hz>` with the required frequency in Hz and run the<br>                            command. |
| cat /sys/class/kgsl/kgsl-3d0/devfreq/max_freqCopy to clipboard | Reads the maximum frequency of the GPU. |
| echo <GPU freq in Hz> /sys/class/kgsl/kgsl-3d0/devfreq/max_freqCopy to clipboard | Sets the maximum frequency of the GPU. Replace `<GPU freq<br>                                in Hz>` with the required frequency in Hz and run the<br>                            command. |
| cat /sys/class/kgsl/kgsl-3d0/gpu_busy_percentageCopy to clipboard | Reads the GPU percentage usage. |
| For example, to set the GPU frequency at 600000000 Hz, run the<br>                            following<br>                            commands:<br><br>    echo 600000000 > /sys/class/kgsl/kgsl-3d0/devfreq/min_freqCopy to clipboard<br><br><br><br>    echo 600000000 > /sys/class/kgsl/kgsl-3d0/devfreq/max_freqCopy to clipboard | Sets the GPU frequency at a required level, both<br>                                `min_freq` and `max_freq` should be<br>                            set to the same frequency level. |
| cat /sys/class/kgsl/kgsl-3d0/max_pwrlevelCopy to clipboard<br><br><br>                            <br><br>    cat /sys/class/kgsl/kgsl-3d0/min_pwrlevelCopy to clipboard | Reads the power levels of the GPU.<br><br><br>                            <br>Level 0 is mapped to the maximum GPU clock. The higher the level, the<br>                                lower is the GPU clock. |
| echo 0 > /sys/class/kgsl/kgsl-3d0/min_pwrlevelCopy to clipboard | Sets the GPU frequency to maximum frequency. |

## Configure memory

Source: [https://docs.qualcomm.com/doc/80-70015-10/topic/14-configure.html](https://docs.qualcomm.com/doc/80-70015-10/topic/14-configure.html)

Memory configuration is a crucial to conserve memory, make space available for
        processes, and balance the existing data in RAM when the physical memory reaches its
        limits.

### Set ZRAM disk size

ZRAM is a RAM partition used for swapping memory space. It stores the inactive
                anonymous pages in a compressed form in RAM to conserve memory.

The ZRAM disk size indicates the maximum amount of memory that can be swapped from
                RAM to ZRAM.

It is recommended to set the ZRAM disk size to half the size of RAM.

For example, to configure the ZRAM disk size to 1 GB for a RAM size of 2 GB, run the
                following commands:
Note: The following commands should be run
                    on the device.

swapoff /dev/zram0Copy to clipboard

    echo 1 > /sys/block/zram0/resetCopy to clipboard

    echo 1073741824 > /sys/block/zram0/disksizeCopy to clipboard

    mkswap /dev/zram0Copy to clipboard

    swapon /dev/zram0Copy to clipboard

    cat /proc/meminfo | grep -i "swap" Copy to clipboard

The following is the command output:

- SwapCached: 0 kB
- SwapTotal: 1048572 kB
- SwapFree: 1048572 kB

You can configure the ZRAM disk size at compile time by modifying the
                    `-s` argument value in the
                    `“zram-swap-init-update”` bash script in the source code at the
                following path:

layers/meta-qcom-hwe/dynamic-layers/openembedded-layer/recipes-extended/zram/zram

To change the size in the script, update the `<size>`
                parameter:

    zramctl -a ${ZRAM_ALGORITHM} -s <size> $deviceCopy to clipboard

The following example shows the ZRAM size set to 1 GB:

`zramctl -a ${ZRAM_ALGORITHM} -s 1048576KB $device`

### Enable/disable proactive compaction

Compaction is a process that collects all the free memory spaces in the form of
                fragments into a large memory block. Proactive compaction determines how
                aggressively compaction is done in the background. It takes a value between 0 and
                100, with the default value set to 20.

When the fragmentation score of the node exceeds a high threshold, the corresponding
                kcompactd thread initiates the proactive compaction process.

The compaction process remains active until the score of the node falls below the low
                threshold.

The thresholds for proactive compaction are as follows:

- Low = 100 - proactiveness
- High = low + 10%

For instance, if the low threshold is 80, the high threshold would be 90.

To enable proactive compaction, run the following command on the device:

    echo 20 > /proc/sys/vm/compaction_proactivenessCopy to clipboard

To disable proactive compaction, which also turns off the periodic kcompactd
                wake-ups, run the following command on the device:

    echo 0 > /proc/sys/vm/compaction_proactivenessCopy to clipboard

For more information, see [Proactive Compaction for the Kernel](https://lwn.net/Articles/817905/).

### Swappiness

Swap space is a secondary storage that functions similar to the main memory or RAM.
                The primary parameter of swap space is swappiness.

- This parameter determines how aggressively the kernel swap daemon (kswapd) swaps
                    out [anonymous memory](https://www.kernel.org/doc/html/latest/admin-guide/mm/concepts.html#anonymous-memory) relative to the
                    system page cache.
- This parameter can take a value between 0 and 200. Increasing the value augments
                    the amount of anonymous swapping. The configured value is set to 100, indicating
                    that both anonymous and cache memories are reclaimed equally.

To adjust the swappiness value, run the following command on the
                device:

    echo 100 > /proc/sys/vm/swappinessCopy to clipboard

For more information on memory parameters, see [https://www.kernel.org/doc/Documentation/admin-guide/sysctl/vm.rst](https://www.kernel.org/doc/Documentation/admin-guide/sysctl/vm.rst).

Last Published: Oct 14, 2024

[Previous Topic
Analysis tools](https://docs.qualcomm.com/bundle/publicresource/80-70015-10/topics/13-performance_tools.md) [Next Topic
Customize](https://docs.qualcomm.com/bundle/publicresource/80-70015-10/topics/18-customize.md)