This patch adds support for per-kernel sysctl.conf files installed in
/boot/sysctl.conf-$(uname -r).
Since we don't really want to maintain yet another tree of mostly
identical files, I implemented simple inheritance.
The order of operation is, for flavor x86_64-desktop:
- sysctl/defaults
- sysctl/x86_64/arch-defaults
- sysctl/x86_64/desktop
I didn't bother implementing filtering, so using the example files below:
- All flavors will get kernel.hung_task_timeout=0.
- All x86_ flavors will also get vm.dirty_ratio=40.
- x86-desktop will /also/ get vm.dirty_ratio=20.
Since the sysctl lines are processed and overridden in order, this is
fine.
I have a separate (simple) patch to boot.sysctl to implement that part
of it.
Signed-off-by: Jeff Mahoney
---
rpm/kernel-binary.spec.in | 4 ++++
rpm/kernel-source.spec.in | 1 +
scripts/tar-up.sh | 20 ++++++++++++++++++++
sysctl/defaults | 1 +
sysctl/x86_64/arch-defaults | 1 +
sysctl/x86_64/desktop | 1 +
6 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/rpm/kernel-binary.spec.in b/rpm/kernel-binary.spec.in
index 3a82dee..9bed9a9 100644
--- a/rpm/kernel-binary.spec.in
+++ b/rpm/kernel-binary.spec.in
@@ -452,6 +452,10 @@ ln -s $image$suffix %buildroot/boot/$image$suffix
ln -s initrd$suffix %buildroot/boot/initrd$suffix
cp -p .config %buildroot/boot/config-%kernelrelease-%build_flavor
+if [ -f %my_builddir/sysctl/%cpu_arch_flavor ]; then
+ cp -p %my_builddir/sysctl/%cpu_arch_flavor \
+ %buildroot/boot/sysctl.conf-%kernelrelease-%build_flavor
+fi
%if %install_vdso
# Install the unstripped vdso's that are linked in the kernel image
diff --git a/rpm/kernel-source.spec.in b/rpm/kernel-source.spec.in
index 6560706..1156d2a 100644
--- a/rpm/kernel-source.spec.in
+++ b/rpm/kernel-source.spec.in
@@ -101,6 +101,7 @@ Source111: patches.rt.tar.bz2
Source112: patches.trace.tar.bz2
Source113: patches.kabi.tar.bz2
Source120: kabi.tar.bz2
+Source121: sysctl.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
Prefix: /usr/src
diff --git a/scripts/tar-up.sh b/scripts/tar-up.sh
index ffa4532..7ee43f3 100755
--- a/scripts/tar-up.sh
+++ b/scripts/tar-up.sh
@@ -311,6 +311,26 @@ done
echo "kabi.tar.bz2"
stable_tar $build_dir/kabi.tar.bz2 kabi
+echo "sysctl.tar.bz2"
+for config in $(scripts/guards --list < config.conf); do
+ arch=${config%%/*}
+ flavor=${config##*/}
+
+ mkdir -p $tmpdir/sysctl/$arch
+ for file in sysctl/defaults sysctl/$arch/arch-defaults \
+ sysctl/$arch/$flavor; do
+ if [ -f "$file" ]; then
+ cat $file
+ fi
+ done > $tmpdir/sysctl/$arch/$flavor
+done
+
+# We don't need to ship empty files or directories
+find $tmpdir/sysctl -size 0 -exec rm -f {} \;
+rmdir $tmpdir/sysctl/* 2> /dev/null
+
+stable_tar -C $tmpdir $build_dir/sysctl.tar.bz2 sysctl
+
# Create empty dummys for any *.tar.bz2 archive mentioned in the spec file
# not already created: patches.addon is empty by intention; others currently
# may contain no patches.
diff --git a/sysctl/defaults b/sysctl/defaults
new file mode 100644
index 0000000..ac9d6d9
--- /dev/null
+++ b/sysctl/defaults
@@ -0,0 +1 @@
+kernel.hung_task_timeout=0
diff --git a/sysctl/x86_64/arch-defaults b/sysctl/x86_64/arch-defaults
new file mode 100644
index 0000000..b6f94d4
--- /dev/null
+++ b/sysctl/x86_64/arch-defaults
@@ -0,0 +1 @@
+sys.vm.dirty_ratio=40
diff --git a/sysctl/x86_64/desktop b/sysctl/x86_64/desktop
new file mode 100644
index 0000000..ef6e377
--- /dev/null
+++ b/sysctl/x86_64/desktop
@@ -0,0 +1 @@
+sys.vm.dirty_ratio=20
--
Jeff Mahoney
SUSE Labs
--
To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-kernel+help@opensuse.org