Retrieve configuration information from kernel
Subsystems (10)
PATCH 1/1 Retrieve configuration information from kernel
I am including a patch that allows a user to embed kernel configuration in the kernel and retrieve it later either from a running kernel or from the kernel image file. This is an enhancement to Randy's patch that was discussed on LKML before and is part of -ac series kernels.
This patch provides three choices for embedding kernel configuration:
1. Include configuration in running kernel image. This adds to the footprint of the running kernel but allows configuration to be retrieved using "cat /proc/ikconfig/config".
2. Include configuration in kernel image file but not in the running kernel. This adds to the kernel image file size but not the footprint of running kernel. Configuration can be extracted from kernel image file using scripts/extract-ikconfig. This script is in principle the same as what Randy had written originally. I have made it little more robust and structured it to accomodate more than just x86 architecture.
3. Not include kernel configuration in the running kernel or kernel image file.
With these three choices, users can make the appropriate tradeoff. This feature is especially useful for support folks who need to know the kernel configuration for a customer's kernel with fairly high degree of confidence that they are getting the right configuration. This feature is turned off in the default configuration.
Linus, please apply.
--
Khalid
====================================================================
Khalid Aziz Linux and Open Source Lab
(970)898-9214 Hewlett-Packard
[email protected] Fort Collins, CO
---------CUT HERE-------------CUT HERE--------------CUT HERE-----------------
arch/alpha/defconfig +2 -0
@@ -18,6 +18,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/arm/defconfig +2 -0
@@ -80,6 +80,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_NWFPE=y CONFIG_KCORE_ELF=y # CONFIG_KCORE_AOUT is not set
arch/cris/defconfig +2 -0
@@ -17,6 +17,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set # CONFIG_SYSCTL is not set +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_BINFMT_ELF=y # CONFIG_ETRAX_KGDB is not set # CONFIG_ETRAX_WATCHDOG is not set
arch/i386/defconfig +2 -0
@@ -19,6 +19,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/ia64/defconfig +2 -0
@@ -14,6 +14,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/m68k/defconfig +2 -0
@@ -42,6 +42,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_KCORE_ELF=y # CONFIG_KCORE_AOUT is not set CONFIG_BINFMT_AOUT=y
arch/mips/defconfig +2 -0
@@ -93,6 +93,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Memory Technology Devices (MTD)
arch/mips64/defconfig +3 -0
@@ -56,6 +56,9 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set + CONFIG_BINFMT_ELF=y CONFIG_MIPS32_COMPAT=y CONFIG_BINFMT_ELF32=y
arch/parisc/defconfig +2 -0
@@ -37,6 +37,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_BINFMT_SOM=y CONFIG_BINFMT_ELF=y # CONFIG_BINFMT_MISC is not set
arch/ppc/defconfig +2 -0
@@ -64,6 +64,8 @@ CONFIG_PCI=y CONFIG_NET=y CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_KCORE_ELF=y
arch/ppc64/defconfig +2 -0
@@ -20,6 +20,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/s390/defconfig +2 -0
@@ -22,6 +22,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/s390x/defconfig +2 -0
@@ -22,6 +22,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/sh/defconfig +2 -0
@@ -45,6 +45,8 @@ # CONFIG_SYSVIPC is not set # CONFIG_BSD_PROCESS_ACCT is not set # CONFIG_SYSCTL is not set +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_KCORE_ELF=y # CONFIG_KCORE_AOUT is not set CONFIG_BINFMT_ELF=y
arch/sparc/defconfig +2 -0
@@ -17,6 +17,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/sparc64/defconfig +2 -0
@@ -14,6 +14,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
arch/um/defconfig +2 -0
@@ -20,6 +20,8 @@ CONFIG_SYSVIPC=y CONFIG_BSD_PROCESS_ACCT=y CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set CONFIG_BINFMT_AOUT=y CONFIG_BINFMT_ELF=y CONFIG_BINFMT_MISC=y
arch/x86_64/defconfig +2 -0
@@ -24,6 +24,8 @@ CONFIG_SYSVIPC=y # CONFIG_BSD_PROCESS_ACCT is not set CONFIG_SYSCTL=y +# CONFIG_IKCONFIG is not set +# CONFIG_IKCONFIG_PROC is not set # # Loadable module support
init/Config.help +19 -0
@@ -80,6 +80,25 @@ building a kernel for install/rescue disks or your system is very limited in memory. +CONFIG_IKCONFIG + This option enables the complete Linux kernel ".config" file contents, + information on compiler used to build the kernel, kernel running when + this kernel was built and kernel version from Makefile to be saved in + kernel. It provides documentation of which kernel options are used in + a running kernel or in an on-disk kernel. This information can be + extracted from the kernel image file with the script + scripts/extract-ikconfig and used as input to rebuild the current + kernel or to build another kernel. It can also be extracted from a + running kernel by reading /proc/ikconfig/config and + /proc/ikconfig/built_with, if enabled. /proc/ikconfig/config will list the + configuration that was used to build the kernel and + /proc/ikconfig/built_with will list information on the compiler and + host machine that was used to build the kernel. + +CONFIG_IKCONFIG_PROC + This option enables access to kernel configuration file and build + information through /proc/ikconfig. + CONFIG_MODULES Kernel modules are small pieces of compiled code which can be inserted in or removed from the running kernel, using the programs
init/Config.in +2 -0
@@ -9,6 +9,8 @@ bool 'System V IPC' CONFIG_SYSVIPC bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT bool 'Sysctl support' CONFIG_SYSCTL +bool 'Kernel .config support' CONFIG_IKCONFIG +dep_bool ' Enable access to .config through /proc/ikconfig' CONFIG_IKCONFIG_PROC $CONFIG_IKCONFIG endmenu mainmenu_option next_comment
kernel/Makefile +13 -0
@@ -21,6 +21,11 @@ obj-$(CONFIG_CPU_FREQ) += cpufreq.o obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend.o +obj-$(CONFIG_IKCONFIG) += configs.o + +# files to be removed upon make clean +clean-files := ikconfig.h + ifneq ($(CONFIG_IA64),y) # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
@@ -32,3 +37,11 @@ endif include $(TOPDIR)/Rules.make + +$(obj)/ikconfig.h: $(TOPDIR)/scripts/mkconfigs $(TOPDIR)/.config $(TOPDIR)/Makefile + chmod 755 $(TOPDIR)/scripts/mkconfigs + $(TOPDIR)/scripts/mkconfigs $(TOPDIR)/.config $(TOPDIR)/Makefile > $(obj)/ikconfig.h + +$(obj)/configs.o: $(obj)/ikconfig.h $(obj)/configs.c \ + $(TOPDIR)/include/linux/version.h \ + $(TOPDIR)/include/linux/compile.h
kernel/configs.c +206 -0
206 lines not on this page · raw message
scripts/extract-ikconfig +101 -0
101 lines not on this page · raw message
scripts/mkconfigs +81 -0
81 lines not on this page · raw message
On Mon, Oct 21, 2002 at 11:11:51AM -0600, Khalid Aziz wrote:
I like the concept.
Few comments:
Touching all defconfigs is not good. Try to limit the impact of the patch. People just have to press return two more times when running oldconfig.
kernel/Makefile line 47
Quoted 10 lines
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/kernel/Makefile linux-2.5.44-ikconfig/kernel/Makefile
include $(TOPDIR)/Rules.makekernel/Makefile +8
-0+ +$(obj)/ikconfig.h: $(TOPDIR)/scripts/mkconfigs $(TOPDIR)/.config $(TOPDIR)/Makefile + chmod 755 $(TOPDIR)/scripts/mkconfigs + $(TOPDIR)/scripts/mkconfigs $(TOPDIR)/.config $(TOPDIR)/Makefile > $(obj)/ikconfig.h + +$(obj)/configs.o: $(obj)/ikconfig.h $(obj)/configs.c \ + $(TOPDIR)/include/linux/version.h \ + $(TOPDIR)/include/linux/compile.h
Please avoid using $(TOPDIR)
The build is running from root of the kernel tree anyway, so it is nor required. Use $(CONFIG_SHELL) when executing scripts, to avoid the necessity to have the executable bit set.
Sam
Quoted 18 lines · Khalid Aziz
I am including a patch that allows a user to embed kernel configuration in the kernel and retrieve it later either from a running kernel or from the kernel image file. This is an enhancement to Randy's patch that was discussed on LKML before and is part of -ac series kernels.
This patch provides three choices for embedding kernel configuration:
1. Include configuration in running kernel image. This adds to the footprint of the running kernel but allows configuration to be retrieved using "cat
/proc/ikconfig/config".2. Include configuration in kernel image file but not in the running kernel. This adds to the kernel image file size but not the footprint of running kernel. Configuration can be extracted from kernel image file using
scripts/extract-ikconfig. This script is in principle the same as what Randy had written originally. I have made it little more robust and structured it to accomodate more than just x86 architecture.
Quoted 8 lines
3. Not include kernel configuration in the running kernel or kernel image file.
With these three choices, users can make the appropriate tradeoff. This feature is especially useful for support folks who need to know the kernel configuration for a customer's kernel with fairly high degree of confidence that they are getting the right configuration. This feature is turned off in the default configuration.
Hi Kahlid,
I've actually been using a similar (albiet not as complex) solution based on a patch[1] I forward ported to 2.5 from WOLK[2]. You might want to have a look at it, since the nice thing about it was that the .conf file was compressed via gzip prior to inclusion in the kernel. Thus the memory footprint was reduced as well. Another neat attribute was the "make cloneconfig" command which was included in the top-level Makefile. Basically it would parse /proc/blah.gz and send the information directly to Config, generating the configuration non-interactively. Not a big deal, just one less step in the scheme of things. Otherwise, I'd say it looks good to me.
Cheers,
Nicholas
[1] 163_config.gz-2.4.18-pre3.patch
[2]
http://unc.dl.sourceforge.net/sourceforge/wolk/linux-2.4.18-wolk3.6-patchset.tar.bz2