• Home

    • Information
    • Webpage styling
  • Installation

    • Pre-installation
    • Installation
    • Configuration
  • Post-installation

    • General recommendations
    • Performance
      • CPU frequency scaling
        • cpupower
          • Scaling governors
        • x86_energy_perf_policy
        • CPU idle driver
      • Kernel's I/O schedulers
        • Tuning I/O scheduler
      • Zram or zswap
      • CPU exploit mitigations
      • Watchdog
    • Gaming
    • Security

Post-installation Guide


Performance

Changes and improvements can be made after the installation to enhance the performance of the system.

CPU frequency scaling

Tools worth installing:

  • thermald - prevents overheating of Intel CPUs

  • i7z - Intel CPU reporting tool

  • cpupower - provides useful command-line utilites to assist with CPU frequency scaling

  • cpupower-guiAUR - GUI version of cpupower

  • turbostat - displays the frequency, power consumption, idle status and other statistics of the modern Intel and AMD CPUs

  • x86_energy_perf_policy - allows to read or write MSR_IA32_ENERGY_PERF_BIAS

cpupower

Set the maximum clock frequency;


cpupower frequency-set -u (5GHz|5000MHz)

Set the minimum clock frequency:


cpupower frequency-set -d (1GHz|1000MHz)
Scaling governors

Governors (see table below) are power schemes for the CPU. Only one may be active at a time.

Governor Description
performance Run the CPU at the maximum frequency.
powersave Run the CPU at the minimum frequency.
userspace Run the CPU at user specified frequencies.
ondemand Scales the frequency dynamically according to current load. Jumps to the highest frequency and then possibly back off as the idle time increases.
conservative Scales the frequency dynamically according to current load. Scales the frequency more gradually than ondemand.
schedutil Scheduler-driven CPU frequency selection.

Warning

The intel_pstate driver supports only two governors: powersave and performance.

Although they share the name with the generic governors, they do not work in the same way as the generic governors. Both intel_pstate governors provide dynamic scaling similar to the schedutil or ondemand generic governors. The performance governor provided by intel_pstate should give better power saving functionality than the old ondemand governor.

Use CPU monitoring tools (for temperatures, voltage, etc.) when changing the default governor.

Set a governor:


cpupower frequency-set -g (performance|powersave|userspace|ondemand|conservative|schedutil)

Tip

  • To adjust settings for only a single CPU core, append -c core_number.

  • To make the changes permanent, edit /etc/default/cpupower.

x86_energy_perf_policy

Enable Hardware P-States


x86_energy_perf_policy -H 1
x86_energy_perf_policy -U 1

Set a performance policy


x86_energy_perf_policy (default|performance|balance-performance|balance-power|power)

Disable turbo boost


x86_energy_perf_policy --turbo-enable 0

Tip

Alternatively, you can disable turbo boost with a frequency driver:

  • intel_pstate

  • 
    echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
    
  • acpi-cpufreq

  • 
    echo 0 > /sys/devices/system/cpu/cpufreq/boost
    

CPU idle driver

The intel_idle CPU idle driver is used automatically for modern Intel CPUs instead of the acpi_idle driver. This driver is currently automatically used for Sandy Bridge and newer CPUs.

The intel_idle may ignore the BIOS C-State settings.

If you encounter a problem while using this driver, add intel_idle.max_cstate=0 to your kernel line.

Kernel's I/O schedulers

The input/output (I/O) scheduler is the kernel component that decides in which order the block I/O operations are submitted to storage devices.

While some of the early algorithms have now been decommissioned, the official Linux kernel supports a number of I/O schedulers which can be split into two categories:

  • Multi-queue schedulers

    • None, where no queuing algorithm is applied.

    • mq-deadline, the adaptation of the deadline scheduler (see below) to multi-threading.

    • Kyber

    • BFQ

  • Single-queue schedulers

    • NOOP

    • Deadline

    • CFQ

    Warning

    Single-queue schedulers were removed from kernel since Linux 5.0.

To list the available schedulers for all devices:


grep "" /sys/block/*/queue/scheduler

/sys/block/nvme0n1/queue/scheduler:[none] mq-deadline kyber bfq
/sys/block/sda/queue/scheduler:mq-deadline kyber [bfq] none

The currently used scheduler will be wrapped in brackets.

To change the active I/O scheduler to bfq for device sda, use:


echo bfq > /sys/block/sda/queue/scheduler

The process to change I/O scheduler, depending on whether the disk is rotating or not can be automated and persist across reboots.

For example this udev rule below sets the scheduler to none for NVMe, mq-deadline for SSD/eMMC, and bfq for rotational drives:




# set scheduler for NVMe
ACTION=="add|change", KERNEL=="nvme[0-9]n[0-9]", ATTR{queue/scheduler}="none"
# set scheduler for SSD and eMMC
ACTION=="add|change", KERNEL=="sd[a-z]|mmcblk[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="mq-deadline"
# set scheduler for rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq"

Tuning I/O scheduler

Each of the kernel's I/O scheduler has its own tunables, such as the latency time, the expiry time or the FIFO parameters. They are helpful in adjusting the algorithm to a particular combination of device and workload. This is typically to achieve a higher throughput or a lower latency for a given utilization. The tunables and their description can be found within the kernel documentation.

To list the available tunables for a device, in the example below sdb which is using deadline, use:


ls /sys/block/sdb/queue/iosched

fifo_batch  front_merges  read_expire  write_expire  writes_starved

To improve deadline's throughput at the cost of latency, one can increase fifo_batch with the command:


echo 32 > /sys/block/sdb/queue/iosched/fifo_batch

zram or zswap

The zram kernel module (previously called compcache) provides a compressed block device in RAM. If you use it as swap device, the RAM can hold much more information but uses more CPU. Still, it is much quicker than swapping to a hard drive. If a system often falls back to swap, this could improve responsiveness. Using zram is also a good way to reduce disk read/write cycles due to swap on SSDs.

Similar benefits (at similar costs) can be achieved using zswap rather than zram. The two are generally similar in intent although not operation: zswap operates as a compressed RAM cache and neither requires (nor permits) extensive userspace configuration.

The example below describes how to set up swap on zram automatically at boot with a single udev rule. No extra package should be needed to make this work.

First, enable the module:




zram

Configure the number of /dev/zram nodes you need.




options zram num_devices=2

Create the udev rule as shown in the example.




KERNEL=="zram0", ATTR{disksize}="512M" RUN="/usr/bin/mkswap /dev/zram0", TAG+="systemd"
KERNEL=="zram1", ATTR{disksize}="512M" RUN="/usr/bin/mkswap /dev/zram1", TAG+="systemd"

Add /dev/zram to your fstab.




/dev/zram0 none swap defaults 0 0
/dev/zram1 none swap defaults 0 0

Turn off CPU exploit mitigations

Turning off CPU exploit mitigations improves performance (sometimes up to 50%). Use below kernel parameter to disable them all:


mitigations=off

DANGER

DO NOT apply this setting without considering the vulnerabilities it opens up.

More information:

  • linuxreviews.org

  • phoronix.com

The effect is measurable but usually not hugely impressive.

The explanations of all switches it toggles are given at kernel.org.

You can use spectre-meltdown-checkerAUR for vulnerability check.

Watchdog

Many users need this feature due to their system's mission-critical role (i.e. servers), or because of the lack of power reset (i.e. embedded devices). Thus, this feature is required for a good operation in some situations. On the other hand, normal users (i.e. desktop and laptop) do not need this feature and can disable it.

To disable watchdog timers (both software and hardware), append nowatchdog to your boot parameters and blacklist the iTCO_wdt module.

To check the new configuration do:


cat /proc/sys/kernel/watchdog



# Disable watchdog.
blacklist iTCO_wdt

Note

Some users have reported that the nowatchdog parameter didn't work for them, but they have successfully disabled watchdog by disabling the iTCO_wdt module.

If for some reason watchdog still won't disable, you can use this workaround:




# Disable watchdog.
blacklist iTCO_wdt
install iTCO_wdt /bin/true

The install command instructs modprobe to run a custom command instead of inserting the module in the kernel as normal, so you can force the module to always fail loading.

Either action will speed up your boot and shutdown, because one less module is loaded. Additionally disabling watchdog timers increases performance and lowers power consumption.


Axis Linux Documentation is distributed under GNU Free Documentation License 1.3 or later unless otherwise noted.

Copyright © 2021 - Axis Linux