Skip to content

Commit c9676f8

Browse files
authored
Merge pull request #13 from jserv/sched
Replace CFS/EEVDF with compact O(1) tiny scheduler
2 parents 10a3975 + cff2907 commit c9676f8

2 files changed

Lines changed: 559 additions & 15 deletions

File tree

‎build.sh‎

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ build_linux() {
666666
cd linux-${LINUX_VERSION}
667667

668668
# Apply linux-tiny patches for reduced memory footprint and LTO support
669-
for p in ../patches/0002-*.patch ../patches/0003-*.patch ../patches/0004-*.patch ../patches/0005-*.patch ../patches/0006-*.patch ../patches/0010-*.patch ../patches/0011-*.patch ../patches/0012-*.patch ../patches/0013-*.patch; do
669+
for p in ../patches/0002-*.patch ../patches/0003-*.patch ../patches/0004-*.patch ../patches/0005-*.patch ../patches/0006-*.patch ../patches/0010-*.patch ../patches/0011-*.patch ../patches/0012-*.patch ../patches/0013-*.patch ../patches/0014-*.patch; do
670670
[ -f "${p}" ] || continue
671671
apply_patch_once "${p}"
672672
done
@@ -854,13 +854,20 @@ build_linux() {
854854
# defaults to y under EXPERT and pulls a full decompressor library into
855855
# the image -- olddefconfig silently restores them after defconfig.
856856
# Sub-bucket rollup measured RD_ZSTD = 36,942 bytes (lib/zstd),
857-
# RD_LZ4 = 10,972 bytes (lib/lz4), RD_XZ = 6,598 bytes (lib/xz) of
858-
# dead .text in the production vmlinux. RD_ZSTD also pulls
859-
# lib/xxhash.c (~3KB). Keep RD_GZIP=y as the boot-path requirement;
860-
# explicitly disable the rest.
857+
# RD_LZ4 = 10,972 bytes (lib/lz4), RD_XZ = 6,598 bytes (lib/xz),
858+
# RD_LZO = 728 bytes (lib/lzo) of dead .text in the production vmlinux;
859+
# RD_LZMA / RD_BZIP2 do not currently land any .text but their default-y
860+
# status lets olddefconfig drift them back on the next time a fs/ or
861+
# net/ symbol gets enabled. RD_ZSTD also pulls lib/xxhash.c (~3KB).
862+
# Keep RD_GZIP=y as the boot-path requirement; explicitly disable the
863+
# rest, including the residuals, so olddefconfig cannot silently
864+
# re-enable them.
861865
echo "# CONFIG_RD_ZSTD is not set" >>.config
862866
echo "# CONFIG_RD_LZ4 is not set" >>.config
863867
echo "# CONFIG_RD_XZ is not set" >>.config
868+
echo "# CONFIG_RD_LZMA is not set" >>.config
869+
echo "# CONFIG_RD_BZIP2 is not set" >>.config
870+
echo "# CONFIG_RD_LZO is not set" >>.config
864871

865872
# Serial-only target: drop the VT terminal layer and accessibility
866873
# console support. CONFIG_TTY stays on -- the AMBA PL011 console
@@ -931,6 +938,20 @@ build_linux() {
931938
echo "# CONFIG_CGROUPS is not set" >>.config
932939
echo "# CONFIG_SCHED_AUTOGROUP is not set" >>.config
933940

941+
# Patch 0014 replaces fair.c (CFS/EEVDF) with a compact O(1) priority
942+
# round-robin SCHED_NORMAL class under CONFIG_SCHED_FAIR_TINY. fair.c
943+
# body is wrapped in #ifndef; the #else branch provides a per-CPU
944+
# bitmap + per-priority FIFO (HIGH/NORMAL/LOW) plus stubs for every
945+
# symbol other TUs (rt.c, deadline.c stub, syscalls.c, topology.c,
946+
# idle.c, build_utility.c) reference. Linux 7.0 has no CONFIG_SMP
947+
# guard inside fair.c so balance code (select_task_rq, sched_balance_*,
948+
# _nohz_idle_balance, ~7.8KB total) stays linked under UP via the
949+
# sched_class table; this knob is the only way to remove it. nice
950+
# values quantise to the three buckets (nice<0 -> HIGH, nice==0 ->
951+
# NORMAL, nice>0 -> LOW); SCHED_IDLE collapses to LOW; rt_sched_class
952+
# still pre-empts via the existing class chain walk.
953+
echo "CONFIG_SCHED_FAIR_TINY=y" >>.config
954+
934955
run_logged "olddefconfig" kernel_make olddefconfig
935956

936957
# Verify critical config options survived olddefconfig resolution.
@@ -989,11 +1010,15 @@ build_linux() {
9891010
"# CONFIG_RD_ZSTD is not set" \
9901011
"# CONFIG_RD_LZ4 is not set" \
9911012
"# CONFIG_RD_XZ is not set" \
1013+
"# CONFIG_RD_LZMA is not set" \
1014+
"# CONFIG_RD_BZIP2 is not set" \
1015+
"# CONFIG_RD_LZO is not set" \
9921016
"# CONFIG_SCHED_DEBUG_OUTPUT is not set" \
9931017
"# CONFIG_SCHED_DEADLINE_CLASS is not set" \
9941018
"# CONFIG_PSI is not set" \
9951019
"# CONFIG_CGROUPS is not set" \
996-
"# CONFIG_SCHED_AUTOGROUP is not set"; do
1020+
"# CONFIG_SCHED_AUTOGROUP is not set" \
1021+
"CONFIG_SCHED_FAIR_TINY=y"; do
9971022
if ! grep -q "^${opt}\$" .config; then
9981023
echo "ERROR: expected '${opt}' in .config after olddefconfig"
9991024
exit 1
@@ -1056,16 +1081,22 @@ build_linux() {
10561081
fi
10571082
done
10581083

1059-
# Decompressor library guard. RD_ZSTD/RD_LZ4/RD_XZ disabled above
1060-
# must cascade to ZSTD_DECOMPRESS / LZ4_DECOMPRESS / XZ_DEC, the
1061-
# umbrella DECOMPRESS_* hidden bools, and XXHASH (selected by
1062-
# ZSTD_DECOMPRESS, also pulled by BCACHE / BTRFS but those need
1063-
# BLOCK=y which this target lacks). If anything else still
1064-
# selects them (a future fs/ or net/ enable, e.g. squashfs+zstd),
1065-
# we must catch that drift loudly so the size win does not
1066-
# silently regress.
1084+
# Decompressor library guard. RD_ZSTD/RD_LZ4/RD_XZ/RD_LZMA/RD_BZIP2/
1085+
# RD_LZO disabled above must cascade to ZSTD_DECOMPRESS /
1086+
# LZ4_DECOMPRESS / XZ_DEC / LZO_DECOMPRESS, the umbrella DECOMPRESS_*
1087+
# hidden bools, and XXHASH (selected by ZSTD_DECOMPRESS, also pulled
1088+
# by BCACHE / BTRFS but those need BLOCK=y which this target lacks).
1089+
# LZO_DECOMPRESS has more upstream selectors than the others
1090+
# (squashfs / btrfs / jffs2 / f2fs / zram / crypto / lib), all of
1091+
# which depend on BLOCK=y or NET=y / crypto knobs that are off here;
1092+
# the negative guard catches any future drift that re-enables one of
1093+
# them. If anything else still selects these symbols (a future fs/ or
1094+
# net/ enable, e.g. squashfs+zstd), we must catch that drift loudly
1095+
# so the size win does not silently regress.
10671096
for sym in ZSTD_DECOMPRESS ZSTD_COMMON LZ4_DECOMPRESS XZ_DEC \
1068-
XXHASH DECOMPRESS_ZSTD DECOMPRESS_LZ4 DECOMPRESS_XZ; do
1097+
LZO_DECOMPRESS \
1098+
XXHASH DECOMPRESS_ZSTD DECOMPRESS_LZ4 DECOMPRESS_XZ \
1099+
DECOMPRESS_LZMA DECOMPRESS_BZIP2 DECOMPRESS_LZO; do
10691100
if grep -q "^CONFIG_${sym}=y\$" .config; then
10701101
echo "ERROR: CONFIG_${sym}=y survived olddefconfig (decompressor guard tripped)"
10711102
exit 1

0 commit comments

Comments
 (0)