Re: [PATCH RFC 0/4] Introduce uts_release

From: Greg KH
Date: Wed Jan 31 2024 - 11:22:58 EST


On Wed, Jan 31, 2024 at 10:48:47AM +0000, John Garry wrote:
> When hacking it is a waste of time and compute energy that we need to
> rebuild much kernel code just for changing the head git commit, like this:
>
> > touch include/generated/utsrelease.h
> > time make -j3
> mkdir -p /home/john/mnt_sda4/john/kernel-dev2/tools/objtool && make O=/home/john/mnt_sda4/john/kernel-dev2 subdir=tools/objtool --no-print-directory -C objtool
> INSTALL libsubcmd_headers
> CALL scripts/checksyscalls.sh
> CC init/version.o
> AR init/built-in.a
> CC kernel/sys.o
> CC kernel/module/main.o
> AR kernel/module/built-in.a
> CC drivers/base/firmware_loader/main.o
> CC kernel/trace/trace.o
> AR drivers/base/firmware_loader/built-in.a
> AR drivers/base/built-in.a
> CC net/ethtool/ioctl.o
> AR kernel/trace/built-in.a
> AR kernel/built-in.a
> AR net/ethtool/built-in.a
> AR net/built-in.a
> AR drivers/built-in.a
> AR built-in.a
> ...
>
> Files like drivers/base/firmware_loader/main.c needs to be recompiled as
> it includes generated/utsrelease.h for UTS_RELEASE macro, and utsrelease.h
> is regenerated when the head commit changes.
>
> Introduce global char uts_release[] in init/version.c, which this
> mentioned code can use instead of UTS_RELEASE, meaning that we don't need
> to rebuild for changing the head commit - only init/version.c needs to be
> rebuilt. Whether all the references to UTS_RELEASE in the codebase are
> proper is a different matter.
>
> For an x86_64 defconfig build for this series on my old laptop, here is
> before and after rebuild time:
>
> before:
> real 0m53.591s
> user 1m1.842s
> sys 0m9.161s
>
> after:
> real 0m37.481s
> user 0m46.461s
> sys 0m7.199s
>
> Sending as an RFC as I need to test more of the conversions and I would
> like to also convert more UTS_RELEASE users to prove this is proper
> approach.

I like it, I also think that v4l2 includes this as well as all of those
drivers seem to rebuild when this changes, does that not happen for you
too?

Anyway, if the firmware changes work, I'm all for this, thanks for
taking it on!

thanks,

greg k-h