2020-06-23 09:00:15 -05:00
#!/bin/bash
2020-08-17 07:14:17 -05:00
_basever=58
_basekernel=5.8
2020-08-19 05:21:01 -05:00
_sub=2
2020-08-17 07:14:17 -05:00
_tkg_initscript() {
cp "$_where"/linux"$_basever"-tkg-patches/* "$_where" # copy patches inside the PKGBUILD's dir to preserve makepkg sourcing and md5sum checking
cp "$_where"/linux"$_basever"-tkg-config/* "$_where" # copy config files and hooks inside the PKGBUILD's dir to preserve makepkg sourcing and md5sum checking
# Load external configuration file if present. Available variable values will overwrite customization.cfg ones.
if [ -e "$_EXT_CONFIG_PATH" ]; then
source "$_EXT_CONFIG_PATH" && msg2 "External configuration file $_EXT_CONFIG_PATH will be used to override customization.cfg values." && msg2 ""
fi
if [ -z "$_OPTIPROFILE" ] && [ ! -e "$_where"/cpuschedset ]; then
# Prompt about optimized configurations. Available variable values will overwrite customization.cfg/external config ones.
plain "Do you want to use a predefined optimized profile?"
read -rp "`echo $' > 1.Custom\n 2.Ryzen Desktop (Performance)\n 3.Other Desktop (Performance)\nchoice[1-3?]: '`" _OPTIPROFILE;
fi
2020-08-17 09:43:41 -05:00
if [ "$_OPTIPROFILE" = "2" ]; then
2020-08-17 07:14:17 -05:00
source "$_where"/ryzen-desktop-profile.cfg && msg2 "Ryzen Desktop (Performance) profile will be used." && msg2 ""
2020-08-17 09:43:41 -05:00
elif [ "$_OPTIPROFILE" = "3" ]; then
2020-08-17 07:14:17 -05:00
source "$_where"/generic-desktop-profile.cfg && msg2 "Generic Desktop (Performance) profile will be used." && msg2 ""
fi
# source cpuschedset early if present
if [ -e "$_where"/cpuschedset ]; then
source "$_where"/cpuschedset
fi
# CPU SCHED selector
if [ -z "$_cpusched" ] && [ ! -e "$_where"/cpuschedset ]; then
plain "What CPU sched variant do you want to build/install?"
read -rp "`echo $' > 1.PDS\n 2.Project C / BMQ\n 3.CFS\nchoice[1-3?]: '`" CONDITION;
2020-08-17 09:43:41 -05:00
if [ "$CONDITION" = "2" ]; then
2020-08-17 07:14:17 -05:00
echo "_cpusched=\"bmq\"" > "$_where"/cpuschedset
2020-08-17 09:43:41 -05:00
elif [ "$CONDITION" = "3" ]; then
2020-08-17 07:14:17 -05:00
echo "_cpusched=\"cfs\"" > "$_where"/cpuschedset
else
echo "_cpusched=\"pds\"" > "$_where"/cpuschedset
fi
if [ -n "$_custom_pkgbase" ]; then
echo "_custom_pkgbase=\"${_custom_pkgbase}\"" >> "$_where"/cpuschedset
fi
2020-08-17 09:43:41 -05:00
elif [ "$_cpusched" = "pds" ]; then
2020-08-17 07:14:17 -05:00
echo "_cpusched=\"pds\"" > "$_where"/cpuschedset
2020-08-17 09:43:41 -05:00
elif [ "$_cpusched" = "cfs" ]; then
2020-08-17 07:14:17 -05:00
echo "_cpusched=\"cfs\"" > "$_where"/cpuschedset
2020-08-17 09:43:41 -05:00
elif [ "$_cpusched" = "bmq" ]; then
2020-08-17 07:14:17 -05:00
echo "_cpusched=\"bmq\"" > "$_where"/cpuschedset
2020-06-23 09:00:15 -05:00
else
2020-08-17 07:14:17 -05:00
if [ "$_nofallback" != "true" ]; then
warning "Something is wrong with your cpusched selection. Do you want to fallback to CFS (default)?"
read -rp "`echo $' > N/y : '`" _fallback;
fi
2020-08-17 09:43:41 -05:00
if [[ "$_fallback" =~ [yY] ]] || [ "$_nofallback" = "true" ]; then
2020-08-17 07:14:17 -05:00
echo "_cpusched=\"cfs\"" > "$_where"/cpuschedset
else
error "Exiting..."
exit 1
fi
fi
source "$_where"/cpuschedset
}
user_patcher() {
# To patch the user because all your base are belong to us
local _patches=("$_where"/*."${_userpatch_ext}revert")
if [ ${#_patches[@]} -ge 2 ] || [ -e "${_patches}" ]; then
if [ "$_user_patches_no_confirm" != "true" ]; then
msg2 "Found ${#_patches[@]} 'to revert' userpatches for ${_userpatch_target}:"
printf '%s\n' "${_patches[@]}"
read -rp "Do you want to install it/them? - Be careful with that ;)"$'\n> N/y : ' _CONDITION;
fi
2020-08-17 09:43:41 -05:00
if [[ "$_CONDITION" =~ [yY] ]] || [ "$_user_patches_no_confirm" = "true" ]; then
2020-08-17 07:14:17 -05:00
for _f in "${_patches[@]}"; do
if [ -e "${_f}" ]; then
msg2 "######################################################"
msg2 ""
msg2 "Reverting your own ${_userpatch_target} patch ${_f}"
msg2 ""
msg2 "######################################################"
patch -Np1 -R < "${_f}"
echo "Reverted your own patch ${_f}" >> "$_where"/last_build_config.log
fi
done
fi
fi
_patches=("$_where"/*."${_userpatch_ext}patch")
if [ ${#_patches[@]} -ge 2 ] || [ -e "${_patches}" ]; then
if [ "$_user_patches_no_confirm" != "true" ]; then
msg2 "Found ${#_patches[@]} userpatches for ${_userpatch_target}:"
printf '%s\n' "${_patches[@]}"
read -rp "Do you want to install it/them? - Be careful with that ;)"$'\n> N/y : ' _CONDITION;
fi
2020-08-17 09:43:41 -05:00
if [[ "$_CONDITION" =~ [yY] ]] || [ "$_user_patches_no_confirm" = "true" ]; then
2020-08-17 07:14:17 -05:00
for _f in "${_patches[@]}"; do
if [ -e "${_f}" ]; then
msg2 "######################################################"
msg2 ""
msg2 "Applying your own ${_userpatch_target} patch ${_f}"
msg2 ""
msg2 "######################################################"
patch -Np1 < "${_f}"
echo "Applied your own patch ${_f}" >> "$_where"/last_build_config.log
fi
done
fi
fi
}
_tkg_srcprep() {
2020-08-17 09:43:41 -05:00
if [ "${_distro}" = "Arch" ]; then
2020-08-17 07:14:17 -05:00
msg2 "Setting version..."
scripts/setlocalversion --save-scmversion
echo "-$pkgrel-tkg-${_cpusched}" > localversion.10-pkgrel
echo "" > localversion.20-pkgname
# add upstream patch
msg2 "Patching from $_basekernel to $pkgver"
patch -p1 -i "$srcdir"/patch-"${pkgver}"
# ARCH Patches
2020-08-17 09:43:41 -05:00
if [ "${_configfile}" = "config_hardened.x86_64" ] && [ "${_cpusched}" = "cfs" ]; then
2020-08-17 07:14:17 -05:00
msg2 "Using linux hardened patchset"
patch -Np1 -i "$srcdir"/0012-linux-hardened.patch
else
patch -Np1 -i "$srcdir"/0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch
fi
2020-06-23 09:00:15 -05:00
fi
# graysky's cpu opts - https://github.com/graysky2/kernel_gcc_patch
msg2 "Applying graysky's cpu opts patch"
2020-08-17 09:43:41 -05:00
if [ "${_distro}" = "Arch" ]; then
2020-08-17 07:14:17 -05:00
patch -Np1 -i "$srcdir"/enable_additional_cpu_optimizations_for_gcc_v10.1%2B_kernel_v5.8%2B.patch
else
patch -Np1 -i "$srcdir"/enable_additional_cpu_optimizations_for_gcc_v10.1+_kernel_v5.8+.patch
fi
2020-06-23 09:00:15 -05:00
# TkG
msg2 "Applying clear linux patches"
2020-08-17 07:14:17 -05:00
patch -Np1 -i "$srcdir"/0002-clear-patches.patch
2020-06-23 09:00:15 -05:00
msg2 "Applying glitched base patch"
2020-08-17 07:14:17 -05:00
patch -Np1 -i "$srcdir"/0003-glitched-base.patch
2020-06-23 09:00:15 -05:00
2020-08-17 07:14:17 -05:00
if [ -z $_misc_adds ]; then
plain "Enable misc additions ? May contain temporary fixes pending upstream or changes that can break on non-Arch. "
read -rp "`echo $' > [Y]/n : '`" _interactive_misc_adds;
if [ "$_interactive_misc_adds" != "n" ] && [ "$_interactive_misc_adds" != "N" ]; then
_misc_adds="true"
fi
fi
2020-08-17 09:43:41 -05:00
if [ "$_misc_adds" = "true" ]; then
2020-07-15 20:39:58 -05:00
msg2 "Applying misc additions patch"
2020-08-17 07:14:17 -05:00
patch -Np1 -i "$srcdir"/0012-misc-additions.patch
2020-07-15 20:39:58 -05:00
fi
2020-08-17 09:43:41 -05:00
if [ "${_cpusched}" = "MuQSS" ]; then
2020-06-23 09:00:15 -05:00
# MuQSS
2020-08-17 07:14:17 -05:00
msg2 "Applying MuQSS base patch"
patch -Np1 -i "$srcdir"/0004-5.8-ck1.patch
2020-08-17 09:43:41 -05:00
if [ "${_aggressive_ondemand}" = "true" ]; then
2020-08-17 07:14:17 -05:00
msg2 "Applying MuQSS agressive ondemand governor patch"
patch -Np1 -i "$srcdir"/0004-glitched-ondemand-muqss.patch
2020-06-23 09:00:15 -05:00
fi
2020-08-17 07:14:17 -05:00
msg2 "Applying Glitched MuQSS patch"
patch -Np1 -i "$srcdir"/0004-glitched-muqss.patch
2020-08-17 09:43:41 -05:00
elif [ "${_cpusched}" = "pds" ]; then
2020-06-23 09:00:15 -05:00
# PDS-mq
2020-08-17 07:14:17 -05:00
msg2 "Applying PDS base patch"
patch -Np1 -i "$srcdir"/0005-v5.8_undead-pds099o.patch
2020-08-17 09:43:41 -05:00
if [ "${_aggressive_ondemand}" = "true" ]; then
2020-08-17 07:14:17 -05:00
msg2 "Applying PDS agressive ondemand governor patch"
patch -Np1 -i "$srcdir"/0005-glitched-ondemand-pds.patch
2020-06-23 09:00:15 -05:00
fi
2020-08-17 07:14:17 -05:00
msg2 "Applying Glitched PDS patch"
patch -Np1 -i "$srcdir"/0005-glitched-pds.patch
2020-08-17 09:43:41 -05:00
elif [ "${_cpusched}" = "bmq" ]; then
2020-08-11 08:46:27 -05:00
# Project C / BMQ
2020-08-17 07:14:17 -05:00
msg2 "Applying Project C / BMQ base patch"
2020-08-17 12:59:15 -05:00
patch -Np1 -i "$srcdir"/0009-prjc_v5.8-r1.patch
2020-08-17 07:14:17 -05:00
2020-08-17 09:43:41 -05:00
if [ "${_aggressive_ondemand}" = "true" ]; then
2020-08-17 07:14:17 -05:00
msg2 "Applying BMQ agressive ondemand governor patch"
patch -Np1 -i "$srcdir"/0009-glitched-ondemand-bmq.patch
2020-06-23 09:00:15 -05:00
fi
2020-08-17 07:14:17 -05:00
msg2 "Applying Glitched BMQ patch"
patch -Np1 -i "$srcdir"/0009-glitched-bmq.patch
2020-08-17 09:43:41 -05:00
elif [ "${_cpusched}" = "cfs" ]; then
2020-08-17 07:14:17 -05:00
msg2 "Applying Glitched CFS patch"
patch -Np1 -i "$srcdir"/0003-glitched-cfs.patch
2020-06-23 09:00:15 -05:00
fi
2020-08-17 09:43:41 -05:00
if [ "${_distro}" = "Arch" ]; then
2020-08-17 07:14:17 -05:00
if [ -z "${_configfile}" ]; then
2020-06-23 09:00:15 -05:00
_configfile="config.x86_64"
2020-08-17 07:14:17 -05:00
fi
cat "${srcdir}/${_configfile}" > ./.config
2020-06-23 09:00:15 -05:00
fi
# Set some -tkg defaults
echo "# CONFIG_DYNAMIC_FAULT is not set" >> ./.config
sed -i -e 's/CONFIG_DEFAULT_FQ_CODEL=y/# CONFIG_DEFAULT_FQ_CODEL is not set/' ./.config
echo "CONFIG_DEFAULT_CAKE=y" >> ./.config
echo "CONFIG_NR_TTY_DEVICES=63" >> ./.config
echo "# CONFIG_NTP_PPS is not set" >> ./.config
sed -i -e 's/CONFIG_CRYPTO_LZ4=m/CONFIG_CRYPTO_LZ4=y/' ./.config
sed -i -e 's/CONFIG_CRYPTO_LZ4HC=m/CONFIG_CRYPTO_LZ4HC=y/' ./.config
sed -i -e 's/CONFIG_LZ4_COMPRESS=m/CONFIG_LZ4_COMPRESS=y/' ./.config
sed -i -e 's/CONFIG_LZ4HC_COMPRESS=m/CONFIG_LZ4HC_COMPRESS=y/' ./.config
sed -i -e 's/CONFIG_ZSWAP_COMPRESSOR_DEFAULT_LZO=y/# CONFIG_ZSWAP_COMPRESSOR_DEFAULT_LZO is not set/' ./.config
sed -i -e 's/# CONFIG_ZSWAP_COMPRESSOR_DEFAULT_LZ4 is not set/CONFIG_ZSWAP_COMPRESSOR_DEFAULT_LZ4=y/' ./.config
sed -i -e 's/CONFIG_ZSWAP_COMPRESSOR_DEFAULT="lzo"/CONFIG_ZSWAP_COMPRESSOR_DEFAULT="lz4"/' ./.config
#sed -i -e 's/CONFIG_RCU_BOOST_DELAY=500/CONFIG_RCU_BOOST_DELAY=0/' ./.config
sed -i -e 's/# CONFIG_CMDLINE_BOOL is not set/CONFIG_CMDLINE_BOOL=y/' ./.config
echo "CONFIG_CMDLINE=\"${_custom_commandline}\"" >> ./.config
echo "# CONFIG_CMDLINE_OVERRIDE is not set" >> ./.config
2020-08-17 13:45:06 -05:00
echo "# CONFIG_X86_P6_NOP is not set" >> ./.config
2020-08-17 07:14:17 -05:00
if [ "$_noccache" != "true" ]; then
2020-08-17 09:43:41 -05:00
if { [ "$_distro" = "Arch" ] && pacman -Qq ccache &> /dev/null; } || { [ "$_distro" = "Ubuntu" ] && dpkg -l ccache > /dev/null; }; then
2020-08-17 07:14:17 -05:00
sed -i -e 's/CONFIG_GCC_PLUGINS=y/# CONFIG_GCC_PLUGINS is not set/' ./.config
fi
2020-06-23 09:00:15 -05:00
fi
2020-08-21 03:09:10 -05:00
# Skip dbg package creation on non-Arch
if [ "$_distro" != "Arch" ]; then
sed -i -e 's/CONFIG_DEBUG_INFO.*/CONFIG_DEBUG_INFO=n/' ./.config
fi
2020-06-23 09:00:15 -05:00
if [ "$_font_autoselect" != "false" ]; then
sed -i -e 's/CONFIG_FONT_TER16x32=y/# CONFIG_FONT_TER16x32 is not set\nCONFIG_FONT_AUTOSELECT=y/' ./.config
fi
# Inject cpuopts options
echo "# CONFIG_MK8SSE3 is not set" >> ./.config
echo "# CONFIG_MK10 is not set" >> ./.config
echo "# CONFIG_MBARCELONA is not set" >> ./.config
echo "# CONFIG_MBOBCAT is not set" >> ./.config
echo "# CONFIG_MJAGUAR is not set" >> ./.config
echo "# CONFIG_MBULLDOZER is not set" >> ./.config
echo "# CONFIG_MPILEDRIVER is not set" >> ./.config
echo "# CONFIG_MSTEAMROLLER is not set" >> ./.config
echo "# CONFIG_MEXCAVATOR is not set" >> ./.config
echo "# CONFIG_MZEN is not set" >> ./.config
echo "# CONFIG_MZEN2 is not set" >> ./.config
echo "# CONFIG_MATOM is not set" >> ./.config
echo "# CONFIG_MNEHALEM is not set" >> ./.config
echo "# CONFIG_MWESTMERE is not set" >> ./.config
echo "# CONFIG_MSILVERMONT is not set" >> ./.config
echo "# CONFIG_MSANDYBRIDGE is not set" >> ./.config
echo "# CONFIG_MIVYBRIDGE is not set" >> ./.config
echo "# CONFIG_MHASWELL is not set" >> ./.config
echo "# CONFIG_MBROADWELL is not set" >> ./.config
echo "# CONFIG_MSKYLAKE is not set" >> ./.config
echo "# CONFIG_MSKYLAKEX is not set" >> ./.config
echo "# CONFIG_MCANNONLAKE is not set" >> ./.config
echo "# CONFIG_MICELAKE is not set" >> ./.config
echo "# CONFIG_MGOLDMONT is not set" >> ./.config
echo "# CONFIG_MGOLDMONTPLUS is not set" >> ./.config
echo "# CONFIG_MCASCADELAKE is not set" >> ./.config
echo "# CONFIG_MCOOPERLAKE is not set" >> ./.config
echo "# CONFIG_MTIGERLAKE is not set" >> ./.config
# Disable some debugging
2020-08-17 09:43:41 -05:00
if [ "${_debugdisable}" = "true" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/CONFIG_SLUB_DEBUG=y/# CONFIG_SLUB_DEBUG is not set/' ./.config
sed -i -e 's/CONFIG_PM_DEBUG=y/# CONFIG_PM_DEBUG is not set/' ./.config
sed -i -e 's/CONFIG_PM_ADVANCED_DEBUG=y/# CONFIG_PM_ADVANCED_DEBUG is not set/' ./.config
sed -i -e 's/CONFIG_PM_SLEEP_DEBUG=y/# CONFIG_PM_SLEEP_DEBUG is not set/' ./.config
sed -i -e 's/CONFIG_ACPI_DEBUG=y/# CONFIG_ACPI_DEBUG is not set/' ./.config
sed -i -e 's/CONFIG_SCHED_DEBUG=y/# CONFIG_SCHED_DEBUG is not set/' ./.config
sed -i -e 's/CONFIG_LATENCYTOP=y/# CONFIG_LATENCYTOP is not set/' ./.config
sed -i -e 's/CONFIG_DEBUG_PREEMPT=y/# CONFIG_DEBUG_PREEMPT is not set/' ./.config
fi
2020-08-17 09:43:41 -05:00
if [ "${_cpusched}" = "MuQSS" ]; then
2020-06-23 09:00:15 -05:00
# MuQSS default config
echo "CONFIG_SCHED_MUQSS=y" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "${_cpusched}" = "pds" ]; then
2020-06-23 09:00:15 -05:00
# PDS default config
echo "CONFIG_SCHED_PDS=y" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "${_cpusched}" = "bmq" ]; then
2020-06-23 09:00:15 -05:00
# BMQ default config
2020-08-11 08:46:27 -05:00
echo "CONFIG_SCHED_ALT=y" >> ./.config
2020-06-23 09:00:15 -05:00
fi
2020-08-17 09:43:41 -05:00
if [ "${_cpusched}" = "MuQSS" ] || [ "${_cpusched}" = "pds" ] || [ "${_cpusched}" = "bmq" ]; then
2020-06-23 09:00:15 -05:00
# Disable CFS
sed -i -e 's/CONFIG_FAIR_GROUP_SCHED=y/# CONFIG_FAIR_GROUP_SCHED is not set/' ./.config
sed -i -e 's/CONFIG_CFS_BANDWIDTH=y/# CONFIG_CFS_BANDWIDTH is not set/' ./.config
# sched yield type
if [ -n "$_sched_yield_type" ]; then
CONDITION0="$_sched_yield_type"
else
plain ""
plain "CPU sched_yield_type - Choose what sort of yield sched_yield will perform."
plain ""
plain "For PDS and MuQSS:"
plain "0: No yield."
plain "1: Yield only to better priority/deadline tasks."
plain "2: Expire timeslice and recalculate deadline."
plain ""
plain "For BMQ (experimental) - No recommended value yet, so try for yourself x) :"
plain "0: No yield."
plain "1: Deboost and requeue task. (default)"
plain "2: Set rq skip task."
2020-08-17 09:43:41 -05:00
if [ "${_cpusched}" = "MuQSS" ]; then
2020-08-11 08:46:27 -05:00
read -rp "`echo $'\n 0. Supposedly best option for gaming performance - could lead to stability issues on some (AMD) platforms when combined with MuQSS\n > 1. Default and recommended option for MuQSS - could lead to stability issues on some (Intel) platforms\n 2. Can be a good option with low rr_interval on MuQSS\n [0-2?]: '`" CONDITION0;
else
read -rp "`echo $'\n > 0. Recommended option for gaming on PDS - "tkg" default\n 1. Default, but can lead to stability issues on some platforms\n 2. Can be a good option with low rr_interval on MuQSS\n [0-2?]: '`" CONDITION0;
fi
2020-06-23 09:00:15 -05:00
fi
2020-08-17 09:43:41 -05:00
if [ "$CONDITION0" = "0" ]; then
if [ "${_cpusched}" = "bmq" ]; then
2020-08-11 08:46:27 -05:00
sed -i -e 's/int sched_yield_type __read_mostly = 1;/int sched_yield_type __read_mostly = 0;/' ./kernel/sched/alt_core.c
else
sed -i -e 's/int sched_yield_type __read_mostly = 1;/int sched_yield_type __read_mostly = 0;/' ./kernel/sched/"${_cpusched}".c
fi
2020-08-17 09:43:41 -05:00
elif [ "$CONDITION0" = "1" ]; then
2020-06-23 09:00:15 -05:00
msg2 "Using default CPU sched yield type (1)"
2020-08-17 09:43:41 -05:00
elif [ "$CONDITION0" = "2" ]; then
if [ "${_cpusched}" = "bmq" ]; then
2020-08-11 08:46:27 -05:00
sed -i -e 's/int sched_yield_type __read_mostly = 1;/int sched_yield_type __read_mostly = 2;/' ./kernel/sched/alt_core.c
else
sed -i -e 's/int sched_yield_type __read_mostly = 1;/int sched_yield_type __read_mostly = 2;/' ./kernel/sched/"${_cpusched}".c
fi
2020-06-23 09:00:15 -05:00
else
2020-08-17 09:43:41 -05:00
if [ "${_cpusched}" = "MuQSS" ]; then
2020-08-11 08:46:27 -05:00
msg2 "Using default CPU sched yield type (1)"
2020-08-17 09:43:41 -05:00
elif [ "${_cpusched}" = "bmq" ]; then
2020-08-11 08:46:27 -05:00
sed -i -e 's/int sched_yield_type __read_mostly = 1;/int sched_yield_type __read_mostly = 0;/' ./kernel/sched/alt_core.c
else
sed -i -e 's/int sched_yield_type __read_mostly = 1;/int sched_yield_type __read_mostly = 0;/' ./kernel/sched/"${_cpusched}".c
fi
2020-06-23 09:00:15 -05:00
fi
fi
# Round Robin interval
2020-08-17 09:43:41 -05:00
if [ "${_cpusched}" = "MuQSS" ] || [ "${_cpusched}" = "pds" ] || [ "${_cpusched}" = "bmq" ]; then
2020-06-23 09:00:15 -05:00
if [ -n "$_rr_interval" ]; then
CONDITION1="$_rr_interval"
else
plain ""
plain "Round Robin interval is the longest duration two tasks with the same nice level will"
plain "be delayed for. When CPU time is requested by a task, it receives a time slice equal"
plain "to the rr_interval in addition to a virtual deadline. When using yield_type 2, a low"
plain "value can help offset the disadvantages of rescheduling a process that has yielded."
plain ""
plain "MuQSS default: 6ms"
plain "PDS default: 4ms"
plain "BMQ default: 2ms"
read -rp "`echo $'\n > 0.Keep defaults\n 1.2ms\n 2.4ms\n 3.6ms\n 4.8ms\n [0-4?]: '`" CONDITION1;
fi
2020-08-17 09:43:41 -05:00
if [ "$CONDITION1" = "1" ]; then
2020-06-23 09:00:15 -05:00
msg2 "Using 2ms rr_interval"
_rrvalue="2"
2020-08-17 09:43:41 -05:00
elif [ "$CONDITION1" = "2" ]; then
2020-06-23 09:00:15 -05:00
msg2 "Using 4ms rr_interval"
_rrvalue="4"
2020-08-17 09:43:41 -05:00
elif [ "$CONDITION1" = "3" ]; then
2020-06-23 09:00:15 -05:00
msg2 "Using 6ms rr_interval"
_rrvalue="6"
2020-08-17 09:43:41 -05:00
elif [ "$CONDITION1" = "4" ]; then
2020-06-23 09:00:15 -05:00
msg2 "Using 8ms rr_interval"
_rrvalue="8"
else
msg2 "Using default rr_interval"
_rrvalue="default"
fi
if [ "$_rrvalue" != "default" ]; then
2020-08-17 09:43:41 -05:00
if [ "${_cpusched}" = "MuQSS" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e "s/int rr_interval __read_mostly = 6;/int rr_interval __read_mostly = ${_rrvalue};/" ./kernel/sched/"${_cpusched}".c
2020-08-17 09:43:41 -05:00
elif [ "${_cpusched}" = "pds" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e "s/#define SCHED_DEFAULT_RR (4)/#define SCHED_DEFAULT_RR (${_rrvalue})/" ./kernel/sched/"${_cpusched}".c
2020-08-17 09:43:41 -05:00
elif [ "${_cpusched}" = "bmq" ]; then
2020-08-11 08:20:35 -05:00
sed -i -e "s/u64 sched_timeslice_ns __read_mostly = (4 * 1000 * 1000);/u64 sched_timeslice_ns __read_mostly = (${_rrvalue} * 1000 * 1000);/" ./kernel/sched/alt_core.c
2020-06-23 09:00:15 -05:00
fi
else
2020-08-17 09:43:41 -05:00
if [ "${_cpusched}" = "bmq" ]; then
2020-08-11 08:20:35 -05:00
sed -i -e "s/u64 sched_timeslice_ns __read_mostly = (4 * 1000 * 1000);/u64 sched_timeslice_ns __read_mostly = (2 * 1000 * 1000);/" ./kernel/sched/alt_core.c
2020-06-23 09:00:15 -05:00
fi
fi
fi
# zenify
2020-08-17 09:43:41 -05:00
if [ "$_zenify" = "true" ]; then
2020-06-23 09:00:15 -05:00
echo "CONFIG_ZENIFY=y" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_zenify" = "false" ]; then
2020-06-23 09:00:15 -05:00
echo "# CONFIG_ZENIFY is not set" >> ./.config
fi
# compiler optimization level
2020-08-17 09:43:41 -05:00
if [ "$_compileroptlevel" = "1" ]; then
2020-06-23 09:00:15 -05:00
echo "# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 is not set" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_compileroptlevel" = "2" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y/# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set/' ./.config
echo "CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3=y" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_compileroptlevel" = "3" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y/# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set/' ./.config
sed -i -e 's/# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set/CONFIG_CC_OPTIMIZE_FOR_SIZE=y/' ./.config
echo "# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 is not set" >> ./.config
fi
# cpu opt
if [ -n "$_processor_opt" ] && [ "$_processor_opt" != "native" ]; then
echo "# CONFIG_MNATIVE is not set" >> ./.config
fi
if [ -n "$_processor_opt" ] && [ "$_processor_opt" != "generic" ]; then
sed -i -e 's/CONFIG_GENERIC_CPU=y/# CONFIG_GENERIC_CPU is not set/' ./.config
fi
2020-08-17 09:43:41 -05:00
if [ "$_processor_opt" = "native" ]; then
2020-06-23 09:00:15 -05:00
echo "CONFIG_MNATIVE=y" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "k8" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MK8 is not set/CONFIG_MK8=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "k8sse3" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MK8SSE3 is not set/CONFIG_MK8SSE3=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "k10" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MK10 is not set/CONFIG_MK10=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "barcelona" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MBARCELONA is not set/CONFIG_MBARCELONA=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "bobcat" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MBOBCAT is not set/CONFIG_MBOBCAT=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "jaguar" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MJAGUAR is not set/CONFIG_MJAGUAR=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "bulldozer" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MBULLDOZER is not set/CONFIG_MBULLDOZER=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "piledriver" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MPILEDRIVER is not set/CONFIG_MPILEDRIVER=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "steamroller" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MSTEAMROLLER is not set/CONFIG_MSTEAMROLLER=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "excavator" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MEXCAVATOR is not set/CONFIG_MEXCAVATOR=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "zen" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MZEN is not set/CONFIG_MZEN=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "zen2" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MZEN2 is not set/CONFIG_MZEN2=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "mpsc" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MPSC is not set/CONFIG_MPSC=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "atom" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MATOM is not set/CONFIG_MATOM=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "core2" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MCORE2 is not set/CONFIG_MCORE2=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "nehalem" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MNEHALEM is not set/CONFIG_MNEHALEM=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "westmere" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MWESTMERE is not set/CONFIG_MWESTMERE=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "silvermont" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MSILVERMONT is not set/CONFIG_MSILVERMONT=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "sandybridge" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MSANDYBRIDGE is not set/CONFIG_MSANDYBRIDGE=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "ivybridge" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MIVYBRIDGE is not set/CONFIG_MIVYBRIDGE=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "haswell" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MHASWELL is not set/CONFIG_MHASWELL=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "broadwell" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MBROADWELL is not set/CONFIG_MBROADWELL=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "skylake" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MSKYLAKE is not set/CONFIG_MSKYLAKE=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "skylakex" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MSKYLAKEX is not set/CONFIG_MSKYLAKEX=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "cannonlake" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MCANNONLAKE is not set/CONFIG_MCANNONLAKE=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "icelake" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MICELAKE is not set/CONFIG_MICELAKE=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "goldmont" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MGOLDMONT is not set/CONFIG_MGOLDMONT=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "goldmontplus" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MGOLDMONTPLUS is not set/CONFIG_MGOLDMONTPLUS=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "cascadelake" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MCASCADELAKE is not set/CONFIG_MCASCADELAKE=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "cooperlake" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MCOOPERLAKE is not set/CONFIG_MCOOPERLAKE=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_processor_opt" = "tigerlake" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_MTIGERLAKE is not set/CONFIG_MTIGERLAKE=y/' ./.config
fi
# irq threading
2020-08-17 09:43:41 -05:00
if [ "$_irq_threading" = "true" ]; then
2020-06-23 09:00:15 -05:00
echo "CONFIG_FORCE_IRQ_THREADING=y" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_irq_threading" = "false" ]; then
2020-06-23 09:00:15 -05:00
echo "# CONFIG_FORCE_IRQ_THREADING is not set" >> ./.config
fi
# smt nice
2020-08-17 09:43:41 -05:00
if [ "$_smt_nice" = "true" ]; then
2020-06-23 09:00:15 -05:00
echo "CONFIG_SMT_NICE=y" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_smt_nice" = "false" ]; then
2020-06-23 09:00:15 -05:00
echo "# CONFIG_SMT_NICE is not set" >> ./.config
fi
# random trust cpu
2020-08-17 09:43:41 -05:00
if [ "$_random_trust_cpu" = "true" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_RANDOM_TRUST_CPU is not set/CONFIG_RANDOM_TRUST_CPU=y/' ./.config
fi
# rq sharing
2020-08-17 09:43:41 -05:00
if [ "$_runqueue_sharing" = "none" ]; then
2020-06-23 09:00:15 -05:00
echo -e "CONFIG_RQ_NONE=y\n# CONFIG_RQ_SMT is not set\n# CONFIG_RQ_MC is not set\n# CONFIG_RQ_MC_LLC is not set\n# CONFIG_RQ_SMP is not set\n# CONFIG_RQ_ALL is not set" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ -z "$_runqueue_sharing" ] || [ "$_runqueue_sharing" = "smt" ]; then
2020-06-23 09:00:15 -05:00
echo -e "# CONFIG_RQ_NONE is not set\nCONFIG_RQ_SMT=y\n# CONFIG_RQ_MC is not set\n# CONFIG_RQ_MC_LLC is not set\n# CONFIG_RQ_SMP is not set\n# CONFIG_RQ_ALL is not set" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_runqueue_sharing" = "mc" ]; then
2020-06-23 09:00:15 -05:00
echo -e "# CONFIG_RQ_NONE is not set\n# CONFIG_RQ_SMT is not set\nCONFIG_RQ_MC=y\n# CONFIG_RQ_MC_LLC is not set\n# CONFIG_RQ_SMP is not set\n# CONFIG_RQ_ALL is not set" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_runqueue_sharing" = "smp" ]; then
2020-06-23 09:00:15 -05:00
echo -e "# CONFIG_RQ_NONE is not set\n# CONFIG_RQ_SMT is not set\n# CONFIG_RQ_MC is not set\n# CONFIG_RQ_MC_LLC is not set\nCONFIG_RQ_SMP=y\n# CONFIG_RQ_ALL is not set" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_runqueue_sharing" = "all" ]; then
2020-06-23 09:00:15 -05:00
echo -e "# CONFIG_RQ_NONE is not set\n# CONFIG_RQ_SMT is not set\n# CONFIG_RQ_MC is not set\n# CONFIG_RQ_MC_LLC is not set\n# CONFIG_RQ_SMP is not set\nCONFIG_RQ_ALL=y" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_runqueue_sharing" = "mc-llc" ]; then
2020-06-23 09:00:15 -05:00
echo -e "# CONFIG_RQ_NONE is not set\n# CONFIG_RQ_SMT is not set\n# CONFIG_RQ_MC is not set\nCONFIG_RQ_MC_LLC=y\n# CONFIG_RQ_SMP is not set\n# CONFIG_RQ_ALL is not set" >> ./.config
fi
# timer freq
if [ -n "$_timer_freq" ] && [ "$_timer_freq" != "300" ]; then
sed -i -e 's/CONFIG_HZ_300=y/# CONFIG_HZ_300 is not set/' ./.config
sed -i -e 's/CONFIG_HZ_300_NODEF=y/# CONFIG_HZ_300_NODEF is not set/' ./.config
2020-08-17 09:43:41 -05:00
if [ "$_timer_freq" = "1000" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_HZ_1000 is not set/CONFIG_HZ_1000=y/' ./.config
sed -i -e 's/CONFIG_HZ=300/CONFIG_HZ=1000/' ./.config
echo "# CONFIG_HZ_500 is not set" >> ./.config
echo "# CONFIG_HZ_500_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_750 is not set" >> ./.config
echo "# CONFIG_HZ_750_NODEF is not set" >> ./.config
echo "CONFIG_HZ_1000_NODEF=y" >> ./.config
echo "# CONFIG_HZ_250_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_300_NODEF is not set" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_timer_freq" = "750" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/CONFIG_HZ=300/CONFIG_HZ=750/' ./.config
echo "# CONFIG_HZ_500 is not set" >> ./.config
echo "# CONFIG_HZ_500_NODEF is not set" >> ./.config
echo "CONFIG_HZ_750=y" >> ./.config
echo "CONFIG_HZ_750_NODEF=y" >> ./.config
echo "# CONFIG_HZ_1000_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_250_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_300_NODEF is not set" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_timer_freq" = "500" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/CONFIG_HZ=300/CONFIG_HZ=500/' ./.config
echo "CONFIG_HZ_500=y" >> ./.config
echo "CONFIG_HZ_500_NODEF=y" >> ./.config
echo "# CONFIG_HZ_750 is not set" >> ./.config
echo "# CONFIG_HZ_750_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_1000_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_250_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_300_NODEF is not set" >> ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_timer_freq" = "100" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/CONFIG_HZ=300/CONFIG_HZ=100/' ./.config
echo "# CONFIG_HZ_500 is not set" >> ./.config
echo "# CONFIG_HZ_750 is not set" >> ./.config
echo "# CONFIG_HZ_1000_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_750_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_500_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_250_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_300_NODEF is not set" >> ./.config
echo "CONFIG_HZ_100=y" >> ./.config
echo "CONFIG_HZ_100_NODEF=y" >> ./.config
fi
2020-08-17 09:43:41 -05:00
elif [ "${_cpusched}" = "MuQSS" ] && [ -z "$_timer_freq" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/CONFIG_HZ=300/CONFIG_HZ=100/' ./.config
echo "# CONFIG_HZ_500 is not set" >> ./.config
echo "# CONFIG_HZ_750 is not set" >> ./.config
echo "# CONFIG_HZ_1000_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_750_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_500_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_250_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_300_NODEF is not set" >> ./.config
echo "CONFIG_HZ_100=y" >> ./.config
echo "CONFIG_HZ_100_NODEF=y" >> ./.config
else
sed -i -e 's/CONFIG_HZ_300=y/# CONFIG_HZ_300 is not set/' ./.config
sed -i -e 's/CONFIG_HZ_300_NODEF=y/# CONFIG_HZ_300_NODEF is not set/' ./.config
sed -i -e 's/CONFIG_HZ=300/CONFIG_HZ=500/' ./.config
echo "CONFIG_HZ_500=y" >> ./.config
echo "CONFIG_HZ_500_NODEF=y" >> ./.config
echo "# CONFIG_HZ_250_NODEF is not set" >> ./.config
echo "# CONFIG_HZ_300_NODEF is not set" >> ./.config
fi
# default cpu gov
2020-08-17 09:43:41 -05:00
if [ "$_default_cpu_gov" = "performance" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL=y/# CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL is not set/' ./.config
sed -i -e 's/# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set/CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$_default_cpu_gov" = "ondemand" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL=y/# CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL is not set/' ./.config
sed -i -e 's/# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set/CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y/' ./.config
fi
# ACPI_CPUFREQ disablement
2020-08-17 09:43:41 -05:00
if [ "$_disable_acpi_cpufreq" = "true" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/CONFIG_X86_ACPI_CPUFREQ=m/# CONFIG_X86_ACPI_CPUFREQ is not set/' ./.config
fi
# ftrace
if [ -z "$_ftracedisable" ]; then
plain ""
plain "Disable FUNCTION_TRACER/GRAPH_TRACER? Lowers overhead but limits debugging"
plain "and analyzing of kernel functions."
read -rp "`echo $' > N/y : '`" CONDITION2;
fi
2020-08-17 09:43:41 -05:00
if [[ "$CONDITION2" =~ [yY] ]] || [ "$_ftracedisable" = "true" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/CONFIG_FUNCTION_TRACER=y/# CONFIG_FUNCTION_TRACER is not set/' ./.config
sed -i -e 's/CONFIG_FUNCTION_GRAPH_TRACER=y/# CONFIG_FUNCTION_GRAPH_TRACER is not set/' ./.config
fi
# disable numa
if [ -z "$_numadisable" ]; then
plain ""
plain "Disable NUMA? Lowers overhead, but breaks CUDA/NvEnc on Nvidia if disabled."
plain "https://bbs.archlinux.org/viewtopic.php?id=239174"
read -rp "`echo $' > N/y : '`" CONDITION3;
fi
2020-08-17 09:43:41 -05:00
if [[ "$CONDITION3" =~ [yY] ]] || [ "$_numadisable" = "true" ]; then
2020-06-23 09:00:15 -05:00
# disable NUMA since 99.9% of users do not have multiple CPUs but do have multiple cores in one CPU
sed -i -e 's/CONFIG_NUMA=y/# CONFIG_NUMA is not set/' \
-i -e '/CONFIG_AMD_NUMA=y/d' \
-i -e '/CONFIG_X86_64_ACPI_NUMA=y/d' \
-i -e '/CONFIG_NODES_SPAN_OTHER_NODES=y/d' \
-i -e '/# CONFIG_NUMA_EMU is not set/d' \
-i -e '/CONFIG_NODES_SHIFT=6/d' \
-i -e '/CONFIG_NEED_MULTIPLE_NODES=y/d' \
-i -e '/CONFIG_USE_PERCPU_NUMA_NODE_ID=y/d' \
-i -e '/CONFIG_ACPI_NUMA=y/d' ./.config
fi
# tickless
if [ -z "$_tickless" ]; then
plain ""
plain "Use CattaRappa mode (Tickless/Dynticks) ?"
plain "Can give higher performances in many cases but lower consistency on some hardware."
plain "Just tickless idle can perform better with some platforms (mostly AMD) or CPU schedulers (mostly MuQSS)."
2020-08-17 09:43:41 -05:00
if [ "${_cpusched}" = "MuQSS" ]; then
2020-06-23 09:00:15 -05:00
read -rp "`echo $'\n 0.No, use periodic ticks\n 1.Yes, full tickless baby!\n > 2.Just tickless idle plz\n [0-2?]: '`" CONDITION4;
else
read -rp "`echo $'\n 0.No, use periodic ticks\n > 1.Yes, full tickless baby!\n 2.Just tickless idle plz\n [0-2?]: '`" CONDITION4;
fi
fi
2020-08-17 09:43:41 -05:00
if [ "$CONDITION4" = "0" ] || [ "$_tickless" = "0" ]; then
2020-06-23 09:00:15 -05:00
echo "# CONFIG_NO_HZ_FULL_NODEF is not set" >> ./.config
sed -i -e 's/# CONFIG_HZ_PERIODIC is not set/CONFIG_HZ_PERIODIC=y/' ./.config
sed -i -e 's/CONFIG_NO_HZ_IDLE=y/# CONFIG_NO_HZ_IDLE is not set/' ./.config
sed -i -e 's/CONFIG_NO_HZ_FULL=y/# CONFIG_NO_HZ_FULL is not set/' ./.config
sed -i -e 's/CONFIG_NO_HZ=y/# CONFIG_NO_HZ is not set/' ./.config
sed -i -e 's/CONFIG_NO_HZ_COMMON=y/# CONFIG_NO_HZ_COMMON is not set/' ./.config
2020-08-17 09:43:41 -05:00
elif [ "$CONDITION4" = "2" ] || [ "$_tickless" = "2" ]; then
2020-06-23 09:00:15 -05:00
echo "# CONFIG_NO_HZ_FULL_NODEF is not set" >> ./.config
sed -i -e 's/CONFIG_HZ_PERIODIC=y/# CONFIG_HZ_PERIODIC is not set/' ./.config
sed -i -e 's/# CONFIG_NO_HZ_IDLE is not set/CONFIG_NO_HZ_IDLE=y/' ./.config
sed -i -e 's/CONFIG_NO_HZ_FULL=y/# CONFIG_NO_HZ_FULL is not set/' ./.config
sed -i -e 's/# CONFIG_NO_HZ is not set/CONFIG_NO_HZ=y/' ./.config
sed -i -e 's/# CONFIG_NO_HZ_COMMON is not set/CONFIG_NO_HZ_COMMON=y/' ./.config
else
2020-08-17 09:43:41 -05:00
if [ "${_cpusched}" = "MuQSS" ]; then
2020-06-23 09:00:15 -05:00
echo "# CONFIG_NO_HZ_FULL_NODEF is not set" >> ./.config
sed -i -e 's/CONFIG_HZ_PERIODIC=y/# CONFIG_HZ_PERIODIC is not set/' ./.config
sed -i -e 's/# CONFIG_NO_HZ_IDLE is not set/CONFIG_NO_HZ_IDLE=y/' ./.config
sed -i -e 's/CONFIG_NO_HZ_FULL=y/# CONFIG_NO_HZ_FULL is not set/' ./.config
sed -i -e 's/# CONFIG_NO_HZ is not set/CONFIG_NO_HZ=y/' ./.config
sed -i -e 's/# CONFIG_NO_HZ_COMMON is not set/CONFIG_NO_HZ_COMMON=y/' ./.config
else
echo "CONFIG_NO_HZ_FULL_NODEF=y" >> ./.config
sed -i -e 's/CONFIG_HZ_PERIODIC=y/# CONFIG_HZ_PERIODIC is not set/' ./.config
sed -i -e 's/CONFIG_NO_HZ_IDLE=y/# CONFIG_NO_HZ_IDLE is not set/' ./.config
sed -i -e 's/# CONFIG_NO_HZ_FULL is not set/CONFIG_NO_HZ_FULL=y/' ./.config
sed -i -e 's/# CONFIG_NO_HZ is not set/CONFIG_NO_HZ=y/' ./.config
sed -i -e 's/# CONFIG_NO_HZ_COMMON is not set/CONFIG_NO_HZ_COMMON=y/' ./.config
echo "CONFIG_CONTEXT_TRACKING=y" >> ./.config
echo "# CONFIG_CONTEXT_TRACKING_FORCE is not set" >> ./.config
fi
fi
# voluntary preempt
if [ -z "$_voluntary_preempt" ]; then
plain ""
plain "Use explicit preemption points?"
plain "It can improve latency on PDS (at the cost of throughput)"
plain "and improve throughput on other schedulers (at the cost of latency)"
read -rp "`echo $' > N/y : '`" CONDITION5;
fi
2020-08-17 09:43:41 -05:00
if [[ "$CONDITION5" =~ [yY] ]] || [ "$_voluntary_preempt" = "true" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/CONFIG_PREEMPT=y/# CONFIG_PREEMPT is not set/' ./.config
sed -i -e 's/CONFIG_PREEMPT_LL=y/# CONFIG_PREEMPT_LL is not set/' ./.config
sed -i -e 's/# CONFIG_PREEMPT_VOLUNTARY is not set/CONFIG_PREEMPT_VOLUNTARY=y/' ./.config
fi
# Open Firmware support
if [ -z "$_OFenable" ]; then
plain ""
plain "Enable Device Tree and Open Firmware support?"
read -rp "`echo $' > N/y : '`" CONDITION6;
fi
2020-08-17 09:43:41 -05:00
if [[ "$CONDITION6" =~ [yY] ]] || [ "$_OFenable" = "true" ]; then
2020-06-23 09:00:15 -05:00
sed -i -e 's/# CONFIG_OF is not set/CONFIG_OF=y/' ./.config
fi
# acs override
if [ -z "$_acs_override" ]; then
plain ""
plain "Use ACS override patch?"
plain "https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF#Bypassing_the_IOMMU_groups_.28ACS_override_patch.29"
read -rp "`echo $' > N/y : '`" CONDITION7;
fi
2020-08-17 09:43:41 -05:00
if [[ "$CONDITION7" =~ [yY] ]] || [ "$_acs_override" = "true" ]; then
2020-08-17 07:14:17 -05:00
msg2 "Patching ACS override"
patch -Np1 -i "$srcdir"/0006-add-acs-overrides_iommu.patch
2020-06-23 09:00:15 -05:00
fi
# bcachefs
2020-08-17 07:14:17 -05:00
#if [ -z "$_bcachefs" ]; then
# plain ""
# plain "Add Bcache filesystem support? You'll have to install bcachefs-tools-git from AUR for utilities."
# plain "https://bcachefs.org/"
# read -rp "`echo $' > N/y : '`" CONDITION8;
#fi
2020-08-17 09:43:41 -05:00
#if [[ "$CONDITION8" =~ [yY] ]] || [ "$_bcachefs" = "true" ]; then
2020-08-17 07:14:17 -05:00
# msg2 "Patching Bcache filesystem support override"
# patch -Np1 -i "$srcdir"/0008-5.8-bcachefs.patch
# echo "CONFIG_BCACHEFS_FS=m" >> ./.config
# echo "CONFIG_BCACHEFS_QUOTA=y" >> ./.config
# echo "CONFIG_BCACHEFS_POSIX_ACL=y" >> ./.config
# echo "# CONFIG_BCACHEFS_DEBUG is not set" >> ./.config
# echo "# CONFIG_BCACHEFS_TESTS is not set" >> ./.config
# echo "# CONFIG_DEBUG_CLOSURES is not set" >> ./.config
#fi
2020-06-23 09:00:15 -05:00
# fsync support
if [ -z "$_fsync" ]; then
plain ""
plain "Enable support for fsync, an experimental replacement for esync in Valve Proton 4.11+"
plain "https://steamcommunity.com/games/221410/announcements/detail/2957094910196249305"
read -rp "`echo $' > N/y : '`" CONDITION9;
fi
2020-08-17 09:43:41 -05:00
if [[ "$CONDITION9" =~ [yY] ]] || [ "$_fsync" = "true" ]; then
2020-08-17 07:14:17 -05:00
msg2 "Patching Fsync support"
patch -Np1 -i "$srcdir"/0007-v5.8-fsync.patch
2020-06-23 09:00:15 -05:00
fi
# ZFS fix
if [ -z "$_zfsfix" ]; then
plain ""
plain "Add back missing symbol for AES-NI/AVX support on ZFS"
plain "https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/kernel/export_kernel_fpu_functions_5_3.patch"
read -rp "`echo $' > N/y : '`" CONDITION11;
fi
2020-08-17 09:43:41 -05:00
if [[ "$CONDITION11" =~ [yY] ]] || [ "$_zfsfix" = "true" ]; then
2020-08-17 07:14:17 -05:00
msg2 "Patching missing symbol for AES-NI/AVX support on ZFS"
patch -Np1 -i "$srcdir"/0011-ZFS-fix.patch
2020-06-23 09:00:15 -05:00
fi
# Community patches
if [ -n "$_community_patches" ]; then
if [ ! -d "$_where/../../community-patches" ]; then
2020-08-17 07:14:17 -05:00
cd "$_where/../.." && git clone https://github.com/Frogging-Family/community-patches.git && cd "${srcdir}/${_srcpath}"
2020-06-23 09:00:15 -05:00
fi
_community_patches=($_community_patches)
for _p in ${_community_patches[@]}; do
2020-08-17 07:14:17 -05:00
ln -s "$_where"/../../community-patches/linux"$_basever"-tkg/$_p "$_where"/
2020-06-23 09:00:15 -05:00
done
fi
# userpatches
2020-08-17 09:43:41 -05:00
if [ "$_user_patches" = "true" ]; then
2020-06-23 09:00:15 -05:00
_userpatch_target="linux-${_basekernel}"
_userpatch_ext="my"
user_patcher
fi
# Community patches removal
for _p in ${_community_patches[@]}; do
rm -f "$_where"/$_p
done
2020-08-17 09:43:41 -05:00
if [ "$_distro" = "Arch" ]; then
2020-08-17 07:14:17 -05:00
# don't run depmod on 'make install'. We'll do this ourselves in packaging
sed -i '2iexit 0' scripts/depmod.sh
2020-06-23 09:00:15 -05:00
2020-08-17 07:14:17 -05:00
# get kernel version
make prepare
fi
2020-06-23 09:00:15 -05:00
# modprobed-db
if [ -z "$_modprobeddb" ]; then
plain ""
plain "Use modprobed db to clean config from unneeded modules?"
plain "Speeds up compilation considerably. Requires root."
plain "https://wiki.archlinux.org/index.php/Modprobed-db"
plain "!!!! Make sure to have a well populated db !!!!"
read -rp "`echo $' > N/y : '`" CONDITIONMPDB;
fi
2020-08-17 09:43:41 -05:00
if [[ "$CONDITIONMPDB" =~ [yY] ]] || [ "$_modprobeddb" = "true" ]; then
2020-06-23 09:00:15 -05:00
sudo modprobed-db recall
2020-08-20 07:24:35 -05:00
yes "" | make localmodconfig
2020-06-23 09:00:15 -05:00
fi
if [ true = "$_config_fragments" ]; then
local fragments=()
mapfile -d '' -t fragments < <(find "$_where"/ -type f -name "*.myfrag" -print0)
if [ true = "$_config_fragments_no_confirm" ]; then
printf 'Using config fragment %s\n' "${fragments[@]#$_where/}"
else
for i in "${!fragments[@]}"; do
while true; do
read -r -p 'Found config fragment '"${fragments[$i]#$_where/}"', apply it? [y/N] ' CONDITIONMPDB
CONDITIONMPDB="$(printf '%s' "$CONDITIONMPDB" | tr '[:upper:]' '[:lower:]')"
case "$CONDITIONMPDB" in
y|yes)
break;;
n|no|'')
unset fragments[$i]
break;;
*)
echo 'Please answer with yes or no'
esac
done
done
fi
if [ 0 -lt "${#fragments[@]}" ]; then
scripts/kconfig/merge_config.sh -m .config "${fragments[@]}"
fi
fi
# menuconfig / nconfig
if [ -z "$_menunconfig" ]; then
plain ""
plain "*Optional* For advanced users - Do you want to use make menuconfig or nconfig"
plain "to configure the kernel before building it?"
plain "If you do, make sure your terminal is currently"
plain "at least 19 lines by 80 columns large or you'll get an error :D"
2020-08-17 07:14:17 -05:00
read -rp "`echo $' > 0. nope\n 1. menuconfig\n 2. nconfig\n 3. xconfig\n choice[0-3?]: '`" CONDITIONMNC;
2020-06-23 09:00:15 -05:00
_menunconfig="$CONDITIONMNC"
fi
if [ 1 = "$_menunconfig" ]; then
cp .config .config.orig
make menuconfig
elif [ 2 = "$_menunconfig" ]; then
cp .config .config.orig
make nconfig
2020-08-17 07:14:17 -05:00
elif [ 3 = "$_menunconfig" ]; then
cp .config .config.orig
make xconfig
2020-06-23 09:00:15 -05:00
else
# rewrite configuration
yes "" | make config >/dev/null
fi
2020-08-17 07:14:17 -05:00
if [ 1 = "$_menunconfig" ] || [ 2 = "$_menunconfig" ] || [ 3 = "$_menunconfig" ]; then
2020-06-23 09:00:15 -05:00
if [ -z "${_diffconfig}" ]; then
while true; do
read -r -p 'Generate a config fragment from your changes? [y/N] ' CONDITIONF
CONDITIONF="$(printf '%s' "$CONDITIONF" | tr '[:upper:]' '[:lower:]')"
case "$CONDITIONF" in
y|yes)
_diffconfig=true
break;;
n|no|'')
_diffconfig=false
break;;
*)
echo 'Please answer with yes or no'
esac
done
fi
if [ true = "$_diffconfig" ]; then
if [ -z "$_diffconfig_name" ]; then
IFS= read -r -p 'Filename for the config fragment [leave empty to not generate fragment]: ' _diffconfig_name
fi
if [ -z "$_diffconfig_name" ]; then
echo 'No file name given, not generating config fragment.'
else (
prev_pwd="${PWD:-$(pwd)}"
cd "$_where"
"${prev_pwd}/scripts/diffconfig" -m "${prev_pwd}/.config.orig" "${prev_pwd}/.config" > "$_diffconfig_name"
) fi
fi
rm .config.orig
fi
2020-08-17 09:43:41 -05:00
if [ "$_distro" = "Arch" ]; then
2020-08-17 07:14:17 -05:00
make -s kernelrelease > version
msg2 "Prepared %s version %s" "$pkgbase" "$(<version)"
fi
}
exit_cleanup() {
# Remove state tracker
rm -f "$_where"/cpuschedset
# Remove temporarily copied files
rm -rf "$_where"/*.patch
rm -rf "$_where"/*-profile.cfg
rm -f "$_where"/config*
rm -f "$_where"/*.hook
rm -f "$_where"/cleanup
rm -f "$_where"/prepare
# Community patches removal in case of failure
for _p in ${_community_patches[@]}; do
rm -f "$_where"/"$_p"
done
if [ "$_NUKR" = "true" ] && [ "$_where" != "$srcdir" ]; then
rm -rf "$_where"/src/*
# Double tap
rm -rf "$srcdir"/linux-*
rm -rf "$srcdir"/*.xz
rm -rf "$srcdir"/*.patch
rm -rf "$srcdir"/*-profile.cfg
rm -f "$srcdir"/config.x86_64
rm -f "$srcdir"/customization.cfg
else
# Meh
rm -rf "$srcdir"/linux-${_basekernel}/Documentation/filesystems/aufs/*
rm -f "$srcdir"/linux-${_basekernel}/Documentation/ABI/testing/*-aufs
rm -rf "$srcdir"/linux-${_basekernel}/fs/aufs/*
rm -f "$srcdir"/linux-${_basekernel}/include/uapi/linux/aufs*
rm -f "$srcdir"/linux-${_basekernel}/mm/prfile.c
rm -f "$srcdir"/linux-${_basekernel}/block/bfq*
rm -rf "$srcdir"/linux-${_basekernel}/drivers/scsi/vhba/*
rm -rf "$srcdir"/linux-${_basekernel}/fs/exfat/*
rm -f "$srcdir"/linux-${_basekernel}/include/trace/events/fs.h
rm -f "$srcdir"/linux-${_basekernel}/Documentation/scheduler/sched-PDS-mq.txt
rm -f "$srcdir"/linux-${_basekernel}/include/linux/skip_list.h
rm -f "$srcdir"/linux-${_basekernel}/kernel/sched/pds.c
rm -f "$srcdir"/linux-${_basekernel}/kernel/sched/pds_sched.h
rm -f "$srcdir"/linux-${_basekernel}/Documentation/scheduler/sched-BMQ.txt
rm -f "$srcdir"/linux-${_basekernel}/kernel/sched/alt_core.c
rm -f "$srcdir"/linux-${_basekernel}/kernel/sched/sched/alt_debug.c
rm -f "$srcdir"/linux-${_basekernel}/kernel/sched/alt_sched.h
rm -f "$srcdir"/linux-${_basekernel}/Documentation/scheduler/sched-BFS.txt
rm -f "$srcdir"/linux-${_basekernel}/Documentation/scheduler/sched-MuQSS.txt
rm -rf "$srcdir"/linux-${_basekernel}/arch/blackfin/*
rm -f "$srcdir"/linux-${_basekernel}/arch/powerpc/configs/c2k_defconfig
rm -f "$srcdir"/linux-${_basekernel}/arch/score/configs/spct6600_defconfig
rm -f "$srcdir"/linux-${_basekernel}/arch/tile/configs/tilegx_defconfig
rm -f "$srcdir"/linux-${_basekernel}/arch/tile/configs/tilepro_defconfig
rm -f "$srcdir"/linux-${_basekernel}/drivers/staging/lustre/lnet/lnet/lib-eq.c
rm -f "$srcdir"/linux-${_basekernel}/kernel/sched/MuQSS*
rm -f "$srcdir"/linux-${_basekernel}/kernel/skip_list.c
rm -f "$srcdir"/linux-${_basekernel}/Documentation/vm/uksm.txt
rm -f "$srcdir"/linux-${_basekernel}/include/linux/sradix-tree.h
rm -f "$srcdir"/linux-${_basekernel}/include/linux/uksm.h
rm -f "$srcdir"/linux-${_basekernel}/lib/sradix-tree.c
rm -f "$srcdir"/linux-${_basekernel}/mm/uksm.c
fi
2020-08-17 09:43:41 -05:00
if [ "${_distro}" = "Arch" ]; then
2020-08-17 07:14:17 -05:00
remove_deps
fi
msg2 'exit cleanup done\n'
if [ -n "$_runtime" ]; then
msg2 "compilation time : \n$_runtime"
fi
2020-06-23 09:00:15 -05:00
}
2020-08-17 07:14:17 -05:00
trap exit_cleanup EXIT