Pretty grody, but it seems to be working... it has to happen after module signing (obviously) and after find-debuginfo.sh runs as well, so tacking it onto the end seems sensible, and then just fixing up the file lists as we go. Provides a nice tidy savings to the disk footprint:
kyle@dreadnought:~% for i in kernel-core-3.15.0-0.rc3.git4.1.fc21.x86_64.rpm \ kernel-core-3.15.0-0.rc3.git4.1.fc21.x86_64.rpm.1; do \ rpm -qip $i | grep '^Size'; done Size : 43011603 Size : 81106737
kmod has handed .xz and .gz modules for a long time now, and can cope.
I was thinking we might also %ghost the .ko, and have a %post install script that un-xz the modules in /proc/modules, but none of them are big enough for that to be worthwhile I think (maybe XFS, but I doubt it.)
--Kyle
--- a/kernel.spec +++ b/kernel.spec @@ -12,8 +12,14 @@ Summary: The Linux kernel # architectures are added. %ifarch %{ix86} x86_64 %global signmodules 1 +%global zipmodules 1 %else %global signmodules 0 +%global zipmodules 0 +%endif + +%if %{zipmodules} +%global zipsed -e 's/.ko$/.ko.xz/' %endif
# % define buildid .local @@ -1713,9 +1719,9 @@ BuildKernel() {
# Make sure the files lists start with absolute paths or rpmbuild fails. # Also add in the dir entries - sed -e 's/^lib*//lib/' $RPM_BUILD_ROOT/k-d.list > ../kernel${Flavour:+-${Flavour}}-modules.list - sed -e 's/^lib*/%dir /lib/' $RPM_BUILD_ROOT/module-dirs.list > ../kernel${Flavour:+-${Flavour}}-core.list - sed -e 's/^lib*//lib/' $RPM_BUILD_ROOT/modules.list >> ../kernel${Flavour:+-${Flavour}}-core.list + sed -e 's/^lib*//lib/' %{?zipsed} $RPM_BUILD_ROOT/k-d.list > ../kernel${Flavour:+-${Flavour}}-modules.list + sed -e 's/^lib*/%dir /lib/' %{?zipsed} $RPM_BUILD_ROOT/module-dirs.list > ../kernel${Flavour:+-${Flavour}}-core.list + sed -e 's/^lib*//lib/' %{?zipsed} $RPM_BUILD_ROOT/modules.list >> ../kernel${Flavour:+-${Flavour}}-core.list
# Cleanup rm -f $RPM_BUILD_ROOT/k-d.list @@ -1836,6 +1842,9 @@ popd %{modsign_cmd} signing_key.priv.sign signing_key.x509.sign $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/ \ fi \ fi \ + if [ "%{zipmodules}" -eq "1" ]; then \ + find $RPM_BUILD_ROOT/lib/modules/ -type f -name '*.ko' | xargs xz; \ + fi \ %{nil}
###
On Tue, May 06, 2014 at 01:02:24PM -0400, Kyle McMartin wrote:
Pretty grody, but it seems to be working... it has to happen after module signing (obviously) and after find-debuginfo.sh runs as well, so tacking it onto the end seems sensible, and then just fixing up the file lists as we go. Provides a nice tidy savings to the disk footprint:
kyle@dreadnought:~% for i in kernel-core-3.15.0-0.rc3.git4.1.fc21.x86_64.rpm \ kernel-core-3.15.0-0.rc3.git4.1.fc21.x86_64.rpm.1; do \ rpm -qip $i | grep '^Size'; done Size : 43011603 Size : 81106737
Nice!
kmod has handed .xz and .gz modules for a long time now, and can cope.
I was thinking we might also %ghost the .ko, and have a %post install script that un-xz the modules in /proc/modules, but none of them are big enough for that to be worthwhile I think (maybe XFS, but I doubt it.)
Sounds reasonable.
I'll play around with this a bit tomorrow, but I like the idea. Out of curiosity, do you know if this has noticable impacts on boot times? I wouldn't think it would be drastic.
--Kyle
--- a/kernel.spec +++ b/kernel.spec @@ -12,8 +12,14 @@ Summary: The Linux kernel # architectures are added. %ifarch %{ix86} x86_64 %global signmodules 1 +%global zipmodules 1 %else %global signmodules 0 +%global zipmodules 0 +%endif
No armv7hl? Curious if those boards would benefit from the size savings as well.
+%if %{zipmodules} +%global zipsed -e 's/.ko$/.ko.xz/' %endif
# % define buildid .local @@ -1713,9 +1719,9 @@ BuildKernel() {
# Make sure the files lists start with absolute paths or rpmbuild fails. # Also add in the dir entries
- sed -e 's/^lib*//lib/' $RPM_BUILD_ROOT/k-d.list > ../kernel${Flavour:+-${Flavour}}-modules.list
- sed -e 's/^lib*/%dir /lib/' $RPM_BUILD_ROOT/module-dirs.list > ../kernel${Flavour:+-${Flavour}}-core.list
- sed -e 's/^lib*//lib/' $RPM_BUILD_ROOT/modules.list >> ../kernel${Flavour:+-${Flavour}}-core.list
- sed -e 's/^lib*//lib/' %{?zipsed} $RPM_BUILD_ROOT/k-d.list > ../kernel${Flavour:+-${Flavour}}-modules.list
- sed -e 's/^lib*/%dir /lib/' %{?zipsed} $RPM_BUILD_ROOT/module-dirs.list > ../kernel${Flavour:+-${Flavour}}-core.list
- sed -e 's/^lib*//lib/' %{?zipsed} $RPM_BUILD_ROOT/modules.list >> ../kernel${Flavour:+-${Flavour}}-core.list
Hm. This makes me wonder if the auto-module-Provides thing we're working through now will be impacted. I'll have to go look at what you did in RPM to see what it's looking for to create those, and when.
josh
# Cleanup rm -f $RPM_BUILD_ROOT/k-d.list
@@ -1836,6 +1842,9 @@ popd %{modsign_cmd} signing_key.priv.sign signing_key.x509.sign $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/ \ fi \ fi \
- if [ "%{zipmodules}" -eq "1" ]; then \
- find $RPM_BUILD_ROOT/lib/modules/ -type f -name '*.ko' | xargs xz; \
- fi \
%{nil}
### _______________________________________________ kernel mailing list kernel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/kernel
On Tue, May 06, 2014 at 02:24:23PM -0400, Josh Boyer wrote:
No armv7hl? Curious if those boards would benefit from the size savings as well.
Meh don't want to make the build even slower there...
+%if %{zipmodules} +%global zipsed -e 's/.ko$/.ko.xz/' %endif
# % define buildid .local @@ -1713,9 +1719,9 @@ BuildKernel() {
# Make sure the files lists start with absolute paths or rpmbuild fails. # Also add in the dir entries
- sed -e 's/^lib*//lib/' $RPM_BUILD_ROOT/k-d.list > ../kernel${Flavour:+-${Flavour}}-modules.list
- sed -e 's/^lib*/%dir /lib/' $RPM_BUILD_ROOT/module-dirs.list > ../kernel${Flavour:+-${Flavour}}-core.list
- sed -e 's/^lib*//lib/' $RPM_BUILD_ROOT/modules.list >> ../kernel${Flavour:+-${Flavour}}-core.list
- sed -e 's/^lib*//lib/' %{?zipsed} $RPM_BUILD_ROOT/k-d.list > ../kernel${Flavour:+-${Flavour}}-modules.list
- sed -e 's/^lib*/%dir /lib/' %{?zipsed} $RPM_BUILD_ROOT/module-dirs.list > ../kernel${Flavour:+-${Flavour}}-core.list
- sed -e 's/^lib*//lib/' %{?zipsed} $RPM_BUILD_ROOT/modules.list >> ../kernel${Flavour:+-${Flavour}}-core.list
Hm. This makes me wonder if the auto-module-Provides thing we're working through now will be impacted. I'll have to go look at what you did in RPM to see what it's looking for to create those, and when.
It probably does... could just change the check in kmod.prov I guess and then prune the extension off.
josh
# Cleanup rm -f $RPM_BUILD_ROOT/k-d.list
@@ -1836,6 +1842,9 @@ popd %{modsign_cmd} signing_key.priv.sign signing_key.x509.sign $RPM_BUILD_ROOT/lib/modules/%{KVERREL}/ \ fi \ fi \
- if [ "%{zipmodules}" -eq "1" ]; then \
- find $RPM_BUILD_ROOT/lib/modules/ -type f -name '*.ko' | xargs xz; \
- fi \
%{nil}
### _______________________________________________ kernel mailing list kernel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/kernel
On Tue, May 06, 2014 at 02:24:23PM -0400, Josh Boyer wrote:
On Tue, May 06, 2014 at 01:02:24PM -0400, Kyle McMartin wrote:
Pretty grody, but it seems to be working... it has to happen after module signing (obviously) and after find-debuginfo.sh runs as well, so tacking it onto the end seems sensible, and then just fixing up the file lists as we go. Provides a nice tidy savings to the disk footprint:
kyle@dreadnought:~% for i in kernel-core-3.15.0-0.rc3.git4.1.fc21.x86_64.rpm \ kernel-core-3.15.0-0.rc3.git4.1.fc21.x86_64.rpm.1; do \ rpm -qip $i | grep '^Size'; done Size : 43011603 Size : 81106737
Nice!
kmod has handed .xz and .gz modules for a long time now, and can cope.
I was thinking we might also %ghost the .ko, and have a %post install script that un-xz the modules in /proc/modules, but none of them are big enough for that to be worthwhile I think (maybe XFS, but I doubt it.)
Sounds reasonable.
I'll play around with this a bit tomorrow, but I like the idea. Out of curiosity, do you know if this has noticable impacts on boot times? I wouldn't think it would be drastic.
This really made no noticable difference in boot times on two different machines I had here. The difference in the systemd-analyze output for the initrd timings was in the noise range, as was the overall boot time.
A loop of 1000 modprobe/modprobe -r operations, there was a 5 second real time difference between compressed and non-compressed. That amounts to a 5 millisecond difference per modprobe for that module (hfs.ko if anyone cares).
The installed RPM sizes are significantly smaller, and the initramfs file is somewhat smaller as well. Seems like an overall win to me.
# Also add in the dir entries
- sed -e 's/^lib*//lib/' $RPM_BUILD_ROOT/k-d.list > ../kernel${Flavour:+-${Flavour}}-modules.list
- sed -e 's/^lib*/%dir /lib/' $RPM_BUILD_ROOT/module-dirs.list > ../kernel${Flavour:+-${Flavour}}-core.list
- sed -e 's/^lib*//lib/' $RPM_BUILD_ROOT/modules.list >> ../kernel${Flavour:+-${Flavour}}-core.list
- sed -e 's/^lib*//lib/' %{?zipsed} $RPM_BUILD_ROOT/k-d.list > ../kernel${Flavour:+-${Flavour}}-modules.list
- sed -e 's/^lib*/%dir /lib/' %{?zipsed} $RPM_BUILD_ROOT/module-dirs.list > ../kernel${Flavour:+-${Flavour}}-core.list
- sed -e 's/^lib*//lib/' %{?zipsed} $RPM_BUILD_ROOT/modules.list >> ../kernel${Flavour:+-${Flavour}}-core.list
Hm. This makes me wonder if the auto-module-Provides thing we're working through now will be impacted. I'll have to go look at what you did in RPM to see what it's looking for to create those, and when.
Right. So the kmod.prov script got moved to redhat-rpm-config. I'll look at getting it fixed to strip off the .xz to generate the proper Provides as Kyle suggested in his other reply.
josh
On Wed, May 07, 2014 at 11:51:09AM -0400, Josh Boyer wrote:
Right. So the kmod.prov script got moved to redhat-rpm-config. I'll look at getting it fixed to strip off the .xz to generate the proper Provides as Kyle suggested in his other reply.
One thing I thought about earlier, was hardcoding the debuginfo phase earlier, and then compressing the modules. That way, we could sign the modules as part of the kernel build, and not have to have this hack (since by the time find-debuginfo.sh runs "For real" we've compressed the modules and they'll not be touched.) Possibly worth investigating rather than continuing our gross hardcode of __debug_install_post.
--Kyle
On Wed, May 07, 2014 at 12:02:08PM -0400, Kyle McMartin wrote:
On Wed, May 07, 2014 at 11:51:09AM -0400, Josh Boyer wrote:
Right. So the kmod.prov script got moved to redhat-rpm-config. I'll look at getting it fixed to strip off the .xz to generate the proper Provides as Kyle suggested in his other reply.
One thing I thought about earlier, was hardcoding the debuginfo phase earlier, and then compressing the modules. That way, we could sign the modules as part of the kernel build, and not have to have this hack
Hardcoding as is moving the call to find-debuginfo.sh from the install to the build phase? Or literally rolling our own in the build section? Just curious.
(As an aside, we actually do sign the modules as part of the kernel build already. The config options are setup that way. The signatures just get stripped later, which makes us sign them again. I left it that way in case people are using the Fedora configs to build kernels from git, and it doesn't increase the build time because ARM dominates that.)
(since by the time find-debuginfo.sh runs "For real" we've compressed the modules and they'll not be touched.) Possibly worth investigating rather than continuing our gross hardcode of __debug_install_post.
Yeah, I'm intrigued. Particularly if it results in the debuginfo stripping becoming a parallel thing...
josh
kernel@lists.fedoraproject.org