View Single Post
Author Message
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 01-01-2020 , 18:13   [CS:GO][LINUX] Build your own kernel = 1 000 Hz + CPU Performance [Debian ~ amd64]
Reply With Quote #1


Introduction
  • Many people don't know how to build their own core. I will try to help you in this tutorial. With this post, I want to start a discussion and find the best kernel build solution for Counter-Strike: Global Offensive. We can do it! It's there are a lot of smart people (it's not ironically).

DISCLAIMER
  • I'm not responsible for destroyed hardware or software caused by this tutorial. You do everything at your own risk. This tutorial is intended for intermediate users of Linux. Incorrect installation can cause system instability and may not boot your linux system. If you are a complete beginner, I recommend using a virtual machine (Virtualbox). I recommend backup your data before proceeding in this tutorial.
  • This tutorial doesn't guarantee performance. We all have probably different hardware.

Let's do it

This tutorial has been tested on hardware (dedicated server):
  • Intel Core i7-3770 (3.40 GHz / 3.90 GHz)
  • HDD2x HDD SATA 3,0 TB
  • RAM2x RAM 8192 MB DDR3
OS:
  • Debian GNU/Linux 9 (stretch)
  • SMP Debian 4.9.189-3+deb9u2 (2019-11-11) x86_64
Open your server console and follow the instructions.
  1. Install important compilation packages.
    PHP Code:
    apt install fakeroot ca-certificates build-essential bison flex gnupg libncurses-dev libelf-dev libssl-dev wget bc rsync 

  2. PHP Code:
    gpg --locate-keys torvalds@kernel.org gregkh@kernel.org 

  3. PHP Code:
    mkdir ~/kernel
    cd 
    ~/kernel 
  4. Download the latest kernel from: https://www.kernel.org/ (yellow button or stable -> tarball)
    PHP Code:
    wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.7.tar.xz
    wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.7.tar.sign 
  5. Unpack the package. If package verification fails, remove (| gpg --verify linux-5.4.7.tar.sign -).
    PHP Code:
    unxz -c linux-5.4.7.tar.xz gpg --verify linux-5.4.7.tar.sign -
    cd linux-5.4.7 
  6. We're going to set up your kernel.
    PHP Code:
    make menuconfig 
  7. Now set according to the settings tree.
    PHP Code:
    Processor type and features
    [*] CPU Frequency scaling
         Timer frequency 
    (xxx Hz) ---> 1 000 Hz

    -------------------------------------------------------------------
    Power management and ACPI options -> CPU Frequency scaling
        
    Default CPUFreq governor (performance) --->
    [*] 
    CPU Frequency scaling
    [*]   'performance' governor
        
    []   'powersave' governor
        
    []   'userspace' governor for userspace frequency scaling
        
    []   'ondemand' cpufreq policy governor
        
    []   'conservative' cpufreq governor
        
    []   'schedutil' cpufreq governor 
  8. Save everything and exit.
  9. Check the following settings in .config and save.
    PHP Code:
    nano .config
    CONFIG_SYSTEM_TRUSTED_KEYS 
    ""
    CONFIG_DEBUG_INFO=
  10. You can use your own name instead of fastkernel.
    PHP Code:
    make clean
    make deb
    -pkg LOCALVERSION=-fastkernel -j[NUMBER_OF_CORES
  11. The kernel is compiling. Hard work. Here you have some bacon as a reward. (Now you have about 2 hours of free time ~ depends on processor performance).
  12. We have a compiled kernel. Install the kernel.
    PHP Code:
    Install
    =====
    dpkg -../linux-image-5.4.7-fastkernel_5.4.7-fastkernel-1_amd64.deb

    Uninstall
    =====
    apt-get purge fastkernel_5.4.7 
  13. Restart the server and enter the command after booting.
    PHP Code:
    uname -r
    --> You will get5.4.7-fastkernel <-- 
  14. We turn on the Intel turbo.
    PHP Code:
    echo > /sys/devices/system/cpu/intel_pstate/no_turbo 
  15. Now let's set the CPU's permanent performance to maximum. Create a cpu.sh file somewhere. Modify the settings according to your processor!
    PHP Code:
    apt install cpufrequtils //Install this tool, otherwise it will not work. 
    PHP Code:
    #!/bin/bash

    cpufreq-set --cpu 0 --governor performance
    cpufreq
    -set --cpu 1 --governor performance
    cpufreq
    -set --cpu 2 --governor performance
    cpufreq
    -set --cpu 3 --governor performance
    cpufreq
    -set --cpu 4 --governor performance
    cpufreq
    -set --cpu 5 --governor performance
    cpufreq
    -set --cpu 6 --governor performance
    cpufreq
    -set --cpu 7 --governor performance

    cpufreq
    -set -u 3.90GHz
    cpufreq
    -set -d 3.90GHz

    cpufreq
    -set --g performance 
  16. Now let's set the script to run every time the server restarts. I put the startup script into etc/rc.local (the file does not normally exist). We'll create it.
    PHP Code:
    nano /etc/systemd/system/rc-local.service 
    PHP Code:
    [Unit]
    Description=/etc/rc.local
    ConditionPathExists
    =/etc/rc.local

    [Service]
    Type=forking
    ExecStart
    =/etc/rc.local start
    TimeoutSec
    =0
    StandardOutput
    =tty
    RemainAfterExit
    =yes
    SysVStartPriority
    =99

    [Install]
    WantedBy=multi-user.target 
    PHP Code:
    nano /etc/rc.local 
    PHP Code:
    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    /cpu.sh || exit 1

    exit 
    PHP Code:
    chmod +/etc/rc.local
    systemctl enable rc
    -local
    systemctl start rc
    -local.service
    systemctl status rc
    -local.service 
  17. Restart the server.
  18. Type the command cpupower frequency-info. You should see something like that.
    PHP Code:
    analyzing CPU 0:
      
    driverintel_pstate
      CPUs which run at the same hardware frequency
    0
      CPUs which need to have their frequency coordinated by software
    0
      maximum transition latency
    :  Cannot determine or is not supported.
      
    hardware limits1.60 GHz 3.90 GHz
      available cpufreq governors
    performance powersave
      current policy
    frequency should be within 3.90 GHz and 3.90 GHz.
                      
    The governor "performance" may decide which speed to use
                      
    within this range.
      
    current CPU frequencyUnable to call hardware
      current CPU frequency
    3.40 GHz (asserted by call to kernel)
      
    boost state support:
        
    Supportedyes
        Active
    yes
        3700 MHz max turbo 4 active cores
        3800 MHz max turbo 3 active cores
        3900 MHz max turbo 2 active cores
        3900 MHz max turbo 1 active cores 

Congratulations, we're done. I'll give you bacon again, you deserve it!
__________________


Main owner of the CMGPORTAL.CZ.
---------------------------------------
My plugins:
[CS:GO] Panorama - Timeleft
[CS:GO] JailBreak - Be quiet, please!

Last edited by Fastmancz; 05-15-2021 at 23:26.
Fastmancz is offline