Retrieve configuration information from kernel
Subsystems (10)
PATCH 1/1 Retrieve configuration information from kernel
I am including a revised 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 +12 -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,10 @@ endif include $(TOPDIR)/Rules.make + +$(obj)/ikconfig.h: $(TOPDIR)/scripts/mkconfigs $(TOPDIR)/.config $(TOPDIR)/Makefile + $(CONFIG_SHELL) $(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
Quoted 11 lines · Khalid Aziz
I am including a revised 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".
Have you considered compressing the config info in order to reduce the space wastage in the loaded kernel image? Could easily be 10's of KB (not that that's a lot these days). The info would then be retrieved via "gunzip -c", et al. instead of a simple "cat".
--
Paul
Quoted 5 lines · Paul Clements
Have you considered compressing the config info in order to reduce the space wastage in the loaded kernel image? Could easily be 10's of KB (not that that's a lot these days). The info would then be retrieved via "gunzip -c", et al. instead of a simple "cat".
I wanted to start with a simple implementation first. There are a couple of things that can be done in future to further improve meory usage: (1) Drop "CONFIG_" and "# CONFIG_" from each line and add it back when printing from /proc/ikconfig and extract-ikconfig script, (2) Compress the resulting configuration. Something to do in near future :)
Signature · 9 lines
Khalid ==================================================================== Khalid Aziz Linux and Open Source Lab (970)898-9214 Hewlett-Packard [email protected] Fort Collins, CO "The Linux kernel is subject to relentless development" - Alessandro Rubini
Quoted 8 lines · Khalid Aziz
Quoted 5 lines · Paul Clements
Have you considered compressing the config info in order to reduce the space wastage in the loaded kernel image? Could easily be 10's of KB (not that that's a lot these days). The info would then be retrieved via "gunzip -c", et al. instead of a simple "cat".
Quoted 5 lines
I wanted to start with a simple implementation first. There are a couple of things that can be done in future to further improve meory usage: (1) Drop "
CONFIG_" and "#CONFIG_" from each line and add it back when printing from/proc/ikconfigand extract-ikconfig script, (2) Compress the resulting configuration. Something to do in near future :)
Do we really need to store the ones that are not actually set to something? You'll get a bunch of queries when doing a "make oldconfig", but saying N to all of them should just work...after all its the ones that are actually *set* that we care about.
Also, if you wanted to get cute, you could make use of the fact that the config names only use ascii chars from '0' to 'Z' which can be represented by 6 bits, then pack them together in memory. I don't know how much difference this would make after zipping though.
Chris
Signature · 4 lines
Chris Friesen | MailStop: 043/33/F10 Nortel Networks | work: (613) 765-0557 3500 Carling Avenue | fax: (613) 765-2986 Nepean, ON K2H 8E9 Canada | email: [email protected]
Quoted 16 lines · Chris Friesen
Quoted 8 lines · Khalid Aziz
Quoted 5 lines · Paul Clements
Have you considered compressing the config info in order to reduce the space wastage in the loaded kernel image? Could easily be 10's of KB (not that that's a lot these days). The info would then be retrieved via "gunzip -c", et al. instead of a simple "cat".
Quoted 5 lines
I wanted to start with a simple implementation first. There are a couple of things that can be done in future to further improve meory usage: (1) Drop "
CONFIG_" and "#CONFIG_" from each line and add it back when printing from/proc/ikconfigand extract-ikconfig script, (2) Compress the resulting configuration. Something to do in near future :)
Quoted 5 lines
Do we really need to store the ones that are not actually set to something? You'll get a bunch of queries when doing a "make oldconfig", but saying N to all of them should just work...after all its the ones that are actually *set* that we care about.
It is annoying to have to answer a lots of questions when running "make oldconfig". This also makes your life a little difficult when you are using the config file from an earlier kernel version to build a newer kernel. You will get lots of questions to answer including questions for the new features in the new kernel and you can no longer blindly answer "N" to every question.
--
Khalid
====================================================================
Khalid Aziz Linux and Open Source Lab
(970)898-9214 Hewlett-Packard
[email protected] Fort Collins, CO
"The Linux kernel is subject to relentless development"
- Alessandro Rubini
Quoted 7 lines · Khalid Aziz
Quoted 4 lines · Paul Clements
Have you considered compressing the config info in order to reduce the space wastage in the loaded kernel image? Could easily be 10's of KB (not that that's a lot these days). The info would then be retrieved via "gunzip -c", et al. instead of a simple "cat".
Quoted 5 lines
I wanted to start with a simple implementation first. There are a couple of things that can be done in future to further improve meory usage: (1) Drop "
CONFIG_" and "#CONFIG_" from each line and add it back when printing from/proc/ikconfigand extract-ikconfig script, (2) Compress the resulting configuration. Something to do in near future :)
$ wc -c /usr/src/linux-2.4/.config 38092 /usr/src/linux-2.4/.config $ gzip -c /usr/src/linux-2.4/.config | wc -c 10305 $ sed '/^ *$/d;/^#/d;s/^CONFIG_//' /usr/src/linux-2.4/.config | wc -c 17267 $ sed '/^ *$/d;/^#/d;s/^CONFIG_//' /usr/src/linux-2.4/.config | gzip | wc -c 6155
Also it seems like it would be more useful to have the config in the kernel image rather than (just) proc?
Pádraig.
Quoted 9 lines · Padraig Brady
Quoted 7 lines · Khalid Aziz
Quoted 4 lines · Paul Clements
Have you considered compressing the config info in order to reduce the space wastage in the loaded kernel image? Could easily be 10's of KB (not that that's a lot these days). The info would then be retrieved via "gunzip -c", et al. instead of a simple "cat".
Quoted 8 lines
Quoted 5 lines
I wanted to start with a simple implementation first. There are a couple of things that can be done in future to further improve meory usage: (1) Drop "
CONFIG_" and "#CONFIG_" from each line and add it back when printing from/proc/ikconfigand extract-ikconfig script, (2) Compress the resulting configuration. Something to do in near future :)$ wc -c /usr/src/linux-2.4/.config 38092 /usr/src/linux-2.4/.config
That charcater count includes all the comments as well. It may not be much but it is not insignificant.
# wc -c .config 22174 .config # grep "^#\? \?CONFIG_" .config | wc -c 20623
Quoted 6 lines
$ gzip -c /usr/src/linux-2.4/.config | wc -c
10305
$ sed '/^ *$/d;/^#/d;s/^CONFIG_//' /usr/src/linux-2.4/.config | wc -c
17267
$ sed '/^ *$/d;/^#/d;s/^CONFIG_//' /usr/src/linux-2.4/.config | gzip | wc -c
6155Dropping "CONFIG_" and "# CONFIG_" will definitely reduce memory requirements. We do not want to drop the lines "# CONFIG_* is not set". If you do that, you end up having to answer lots of questions when running "make oldconfig".
Quoted 3 lines
Also it seems like it would be more useful to have the config in the kernel image rather than (just) proc?
It IS in the kernel image. Use scripts/extract-ikconfig to extract it from the kernel image file. And if you only need it to be in kernel image, you can choose to not have it under /proc.
--
Khalid
====================================================================
Khalid Aziz Linux and Open Source Lab
(970)898-9214 Hewlett-Packard
[email protected] Fort Collins, CO
"The Linux kernel is subject to relentless development"
- Alessandro Rubini