Skip to content

RiverOnVenus/linux-ek

Repository files navigation

Linux-ek

PKGBUILD CI

The Linux-ek kernel and modules with ECHO CPU scheduler by Hamad Al Marri and Con Kolivas' hrtimer patches and with some other stuff. Based on Linux-ck maintained by graysky.

  • ck-hrtimer - Con Kolivas' hrtimer from -ck.
  • ECHO CPU Scheduler - Enhanced CPU Handling Orchestrator, implemented on top of Baby scheduler.
  • kernel_compiler_patch enables compiler optimizations for additional CPUs.
  • BBR v3 is a congestion control algorithm proposed by Google.
  • clearlinux from Intel's Clear Linux project. Provides performance and security optimizations.
  • uksmd - Userspace KSM helper daemon.
  • le9uo protects the working set under memory pressure to prevent thrashing, avoid high latency and prevent livelock in near-OOM conditions.
  • CJKTTY supports displaying CJK Unified Ideographs on Linux tty.

Build and install

Open /etc/pacman.conf and comment out the original Architecture, then add the new Architecture.

#Architecture = auto
Architecture = x86_64 x86_64_v3

Selecting the correct CPU optimized package.

/lib/ld-linux-x86-64.so.2 --help | grep supported

If x86-64-v3 (supported, searched) is in the output, use the Generic-x86-64-v3 (GENERIC_CPU3).

You should compile it yourself and choose the optimization option that suits you. (NOTE: The package on the releases page is a very small kernel (module list) compiled from the configuration generated by modprobed-db on my intel device, and may only be applicable to intel devices(Coffee Lake), not universal.)

git clone https://github.com/RiverOnVenus/linux-ek.git

cd linux-ek/linux-ek

updpkgsums && makepkg -srci

Clang and DKMS

When you use a kernel compiled by CLANG/LLVM/LTO, some modules that use DKMS need to be recompiled with CLANG/LLVM. Otherwise DKMS will fail.

You need to modify the /etc/dkms/framework.conf file, add two lines to the end of the file: export LLVM=1, export CC=clang.

If you have done that, just reinstall or install the kernel compiled with CLANG/LLVM/LTO and DKMS will not fail again.

Dkms(v3.0.2) support for Clang, use the latest version of dkms and you'll be fine.

Check if ECHO CPU Scheduler is enabled

This start-up message should appear in the kernel ring buffer when TT in enabled, use:

# dmesg | grep -i 'ECHO CPU'

You can see: ECHO CPU scheduler v6.8 by Hamad Al Marri.

Defaults and Sysctls in ECHO

  • The default HZ for ECHO is 625HZ - ticks every 1.6ms. No need to increase it since the HighRes clock handles the task preemption in 35us max.
  • kernel.sched_bs_shared_quota by default is 35000 (35us) can be tuned with sysctl ex. sysctl kernel.sched_bs_shared_quota=4800000 larger values saves CPU caches but reduces interactivity and multitasking.
  • There are kernel configurations that must be disabled:
    • CONFIG_FAIR_GROUP_SCHED
    • CONFIG_SCHED_AUTOGROUP
    • CONFIG_SCHED_CORE

See more.

Userspace KSM helper daemon

The special version of uksmd for CachyOS also includes uksmdstats .

➜ uksmdstats
======================================================
uksmd with uksmdstats support. Powered by CachyOS Team
======================================================
Full scans               466      
Interval                 20 ms    
                                  
Max page sharing ratio   256      
Pages to scan            100      
Pages over ratio         3        
Duplicated pages         115      
Use zero pages           0        
Sharing/shared ratio     15.4498  
Unshared/sharing ratio   2.58549  
                                  
Pages sharing            139.953  MiB
Pages shared             9.05859  MiB
Pages unshared           361.957  MiB
                                  
General profit           124.181  MiB

Sysctl configuration improving performance

# See https://wiki.archlinux.org/title/Sysctl for more information.

# Networking
# Increasing this value for high speed cards may help prevent losing packets:
net.core.netdev_max_backlog = 16384

# The upper limit on how many connections the kernel will accept (default 128):
net.core.somaxconn = 8192

# The default the Linux network stack is not configured for high speed large file 	  transfer across WAN links (i.e. handle more network packets) and setting the correct values may save memory resources:
net.core.rmem_default = 1048576
net.core.rmem_max = 16777216
net.core.wmem_default = 1048576
net.core.wmem_max = 16777216
net.core.optmem_max = 65536
net.ipv4.tcp_rmem = 4096 1048576 2097152
net.ipv4.tcp_wmem = 4096 65536 16777216

# It is also possible increase the default 4096 UDP limits:
net.ipv4.udp_rmem_min = 8192
net.ipv4.udp_wmem_min = 8192

# Enable TCP Fast Open
net.ipv4.tcp_fastopen = 3

# Tweak the pending connection handling
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 2000000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_slow_start_after_idle = 0

# Enable MTU probing
net.ipv4.tcp_mtu_probing = 1

# Change TCP keepalive parameters
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_keepalive_intvl = 10
net.ipv4.tcp_keepalive_probes = 6

# Enable CAKE
net.core.default_qdisc = cake

# Virtual memory
# vm.dirty_background_ratio default 10
# vm.dirty_ratio default 20
# For 16GB RAM
vm.dirty_background_ratio = 2
vm.dirty_ratio = 4
# And
# For 8GB RAM
# vm.dirty_background_ratio = 4
# vm.dirty_ratio = 8

# VFS cache
# Decreasing the virtual file system (VFS) cache parameter value 
# may improve system responsiveness (default 100)
# vm.vfs_cache_pressure = 50

# Swappiness (default 60)
# For Solid State Drives
vm.swappiness = 100
# See https://chrisdown.name/2018/01/02/in-defence-of-swap.html
#
# Or
#
# Since zram behaves differently than disk swap,
# we can configure the system's swap to take full potential of the zram advantages:
# vm.swappiness = 180
# vm.watermark_boost_factor = 0
# vm.watermark_scale_factor = 125
# vm.page-cluster = 0
# See https://wiki.archlinux.org/title/Zram#Optimizing_swap_on_zram

Changing I/O scheduler if you want

# cat /sys/block/sda/queue/scheduler

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

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

Or create file /etc/udev/rules.d/60-ioschedulers.rules:

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

Reboot or force udev#Loading new rules:

If rules fail to reload automatically, use:

# udevadm control --reload

To manually force udev to trigger your rules, use:

# udevadm trigger

About

The Linux kernel and modules with ECHO CPU scheduler by Hamad Al Marri and Con Kolivas' hrtimer patches

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages