[opensuse-kernel] [PATCH] Add support for per-kernel sysctl.conf files
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 <jeffm@suse.com> --- 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
On Thu, May 05, 2011 at 02:04:49PM -0400, Jeff Mahoney wrote:
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.
Looks very cool, nice job. greg k-h -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org
On Thu, May 05, 2011 at 02:04:49PM -0400, Jeff Mahoney wrote:
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.
Nice.
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
I would do this at build time and only tar up the sysctl dir here. This would make life easier for those that work on the kernel-source package instead of git. What do you think? Michal diff --git a/rpm/kernel-binary.spec.in b/rpm/kernel-binary.spec.in index 3a82dee..b25bf4b 100644 --- a/rpm/kernel-binary.spec.in +++ b/rpm/kernel-binary.spec.in @@ -452,6 +452,15 @@ 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 +sysctl_file=%buildroot/boot/sysctl.conf-%kernelrelease-%build_flavor +for file in %my_builddir/sysctl/{defaults,%cpu_arch/arch-defaults,%cpu_arch_flavor}; do + if [ -f "$file" ]; then + cat "$file" + fi +done >$sysctl_file +if [ ! -s $sysctl_file ]; then + rm $sysctl_file +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/check-cvs-add b/scripts/check-cvs-add index 592d4a4..577df98 100755 --- a/scripts/check-cvs-add +++ b/scripts/check-cvs-add @@ -38,7 +38,7 @@ if [ "$1" = "--committed" ]; then added="$(git ls-tree -r --name-only HEAD | grep '^patches\..*/' | sort -u)" not_in_git="$(join -v1 <(echo "$patches") <(echo "$added")) - $(git ls-files -d -o -m --directory --exclude-standard kabi/ | sort -u)" + $(git ls-files -d -o -m --directory --exclude-standard kabi/ sysctl/ | sort -u)" else # only if the patches are added added="$(git ls-files --cached | grep '^patches\..*/' | sort -u)" diff --git a/scripts/tar-up.sh b/scripts/tar-up.sh index ffa4532..cfbe5c4 100755 --- a/scripts/tar-up.sh +++ b/scripts/tar-up.sh @@ -311,6 +311,13 @@ done echo "kabi.tar.bz2" stable_tar $build_dir/kabi.tar.bz2 kabi +if grep -q '^Source.*\<sysctl\.tar\.bz2' "$build_dir/kernel-source.spec.in" +then + echo "sysctl.tar.bz2" + stable_tar $build_dir/sysctl.tar.bz2 sysctl +fi + + # 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 -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 05/06/2011 05:22 AM, Michal Marek wrote:
On Thu, May 05, 2011 at 02:04:49PM -0400, Jeff Mahoney wrote:
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.
Nice.
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
I would do this at build time and only tar up the sysctl dir here. This would make life easier for those that work on the kernel-source package instead of git. What do you think?
Sure, no objection from me. Thanks for cleaning it up. - -Jeff
diff --git a/rpm/kernel-binary.spec.in b/rpm/kernel-binary.spec.in index 3a82dee..b25bf4b 100644 --- a/rpm/kernel-binary.spec.in +++ b/rpm/kernel-binary.spec.in @@ -452,6 +452,15 @@ 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 +sysctl_file=%buildroot/boot/sysctl.conf-%kernelrelease-%build_flavor +for file in %my_builddir/sysctl/{defaults,%cpu_arch/arch-defaults,%cpu_arch_flavor}; do + if [ -f "$file" ]; then + cat "$file" + fi +done >$sysctl_file +if [ ! -s $sysctl_file ]; then + rm $sysctl_file +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/check-cvs-add b/scripts/check-cvs-add index 592d4a4..577df98 100755 --- a/scripts/check-cvs-add +++ b/scripts/check-cvs-add @@ -38,7 +38,7 @@ if [ "$1" = "--committed" ]; then added="$(git ls-tree -r --name-only HEAD | grep '^patches\..*/' | sort -u)" not_in_git="$(join -v1 <(echo "$patches") <(echo "$added")) - $(git ls-files -d -o -m --directory --exclude-standard kabi/ | sort -u)" + $(git ls-files -d -o -m --directory --exclude-standard kabi/ sysctl/ | sort -u)" else # only if the patches are added added="$(git ls-files --cached | grep '^patches\..*/' | sort -u)" diff --git a/scripts/tar-up.sh b/scripts/tar-up.sh index ffa4532..cfbe5c4 100755 --- a/scripts/tar-up.sh +++ b/scripts/tar-up.sh @@ -311,6 +311,13 @@ done echo "kabi.tar.bz2" stable_tar $build_dir/kabi.tar.bz2 kabi
+if grep -q '^Source.*\<sysctl\.tar\.bz2' "$build_dir/kernel-source.spec.in" +then + echo "sysctl.tar.bz2" + stable_tar $build_dir/sysctl.tar.bz2 sysctl +fi + + # 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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iEUEARECAAYFAk3EAEwACgkQLPWxlyuTD7JfbACgkJNvcx0Gay+0Kwlhaqk98fUn rfMAlA9KV0H3Xjt2sdz1MOudXcDzUGA= =XoNX -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org
participants (3)
-
Greg KH
-
Jeff Mahoney
-
Michal Marek