ayufan-pine64 / linux-build

Pine64 Linux build scripts, tools and instructions (based on Longsleep work)
MIT License
154 stars 36 forks source link

Modules not stripped (huge debug info) #20

Closed MaikStohn closed 7 years ago

MaikStohn commented 7 years ago

The installed directory "/lib/modules/3.10.....-ayufan-.../" contains kernel modules with debug information:

#du -sh /lib/modules/3.10.105-bsp-1.2-ayufan-74/
345 M /lib/modules/3.10.105-bsp-1.2-ayufan-74/

I did the following command on pinebook to strip them:

#find /lib/modules/3.10.105-bsp-1.2-ayufan-74/ -iname "*.ko" -exec strip --strip-debug {} \;

and after this I got:

#du -sh /lib/modules/3.10.105-bsp-1.2-ayufan-74/
33 M /lib/modules/3.10.105-bsp-1.2-ayufan-74/

Saved 312 MByte.

BTW: Also found another 346 MByte of old kernel modules (left there after upgrade: "/lib/modules/3.10.105-bsp-1.2-ayufan-65")

Total recovered 658 MByte of valuable eMMC space today.

ayufan commented 7 years ago

Currently the space is not recycled with modules. I believe that this should be kernel configuration of some sort?

MaikStohn commented 7 years ago

The strip can be done by a make file parameter when you do "make modules":

make ... INSTALL_MOD_STRIP=1 modules

But it is reported to cause issues with CCACHE ( https://superuser.com/questions/705121/why-is-install-mod-strip-not-on-by-default ) Better would be to run the find / strip before packaging them in your release file like:

#find /tmp/modules/3.10.105-bsp-1.2-ayufan-74/ -iname "*.ko" -exec aarch64-linux-gnu-strip --strip-debug {} \;

The deletion of old modules is only possible after reboot, after an upgrade (the running kernel still holds references to old modules / might need them to load when something happens). This could be done by a script executed at startup deleting all modules directories except the active kernel (uname). But if the modules are stripped then it is only leaving around 33 MB for each version which is not a big deal. My recommendation would be not to delete old modules automatically, instead teaching the user with a text that he needs to reboot after update and then manually can delete old modules.

MaikStohn commented 7 years ago

I created pull request #21 for this.

ayufan commented 7 years ago

Can you just disable CONFIG_DEBUG_INFO=y https://github.com/ayufan-pine64/linux-pine64/blob/my-hacks-1.2/arch/arm64/configs/sun50iw1p1smp_linux_defconfig#L3364?

MaikStohn commented 7 years ago

setting CONFIG_DEBUG_INFO=n is just another way to achieve it. I just tried it.

ayufan commented 7 years ago

Can you create a PR with change?

On Wed, Jul 5, 2017 at 10:58 PM, Maik Stohn notifications@github.com wrote:

setting CONFIG_DEBUG_INFO=n is just another way to achieve it. I just tried it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ayufan-pine64/linux-build/issues/20#issuecomment-313224958, or mute the thread https://github.com/notifications/unsubscribe-auth/ACTpQY_9ljSm9pT7qZZKsgf39GG7JAUfks5sK_j7gaJpZM4OMtmJ .

MaikStohn commented 7 years ago

I created pull request #21 before which was doing it with a simple change in the "install_kernel_modules.sh" script (located in this repository).

A change to kernel config is not located in this repository and would require a change upstream (longsleep) or would require to make "hackish" patch to kernel config before kernel compilation.

So please have a look at pull request #21 again. The proposed solution is an accepted way for many other embedded linux distributions.

ayufan commented 7 years ago

@MaikStohn Please create a PR to this repository: https://github.com/ayufan-pine64/linux-pine64. Kernel is released from this branch.

MaikStohn commented 7 years ago

Ok, didn't see your branch (README pointed to longsleep repo).

While researching the CONFIG_DEBUG_INFO parameter I came across more DEBUG settings which I will do some tests before. One interesting thing is the CONFIG_DEBUG_KERNEL which might have performance impacts: http://hildstrom.com/projects/aestest/

I do some test compilations later today and propose a pull request to your kernel repo.

ayufan commented 7 years ago

Awesome. I will happily release new kernel.

I also start to think about adopting the model used for ayufan-rock64, where I generate installable debian package for kernel. This is easier to maintain, and clean later too.

MaikStohn commented 7 years ago

After disabling DEBUG for kernel and modules the kernel performs just a little bit faster and the modules directory is 30 MB in total now.

I created a pull request in the other repo which alters the default template for the "LINUX" target.