Skip to contentSkip to conversation

Retrieve configuration information from kernel

PATCH In review Khalid Aziz 3 participants 3 messages Oct 21, 2002

Subsystems (10)
Arm (32-bit) Kbuild MIPS s390 +6 more subsystems
lore
Share & tools
lore
#0 lore raw

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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/alpha/defconfig linux-2.5.44-ikconfig/arch/alpha/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/arm/defconfig linux-2.5.44-ikconfig/arch/arm/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/cris/defconfig linux-2.5.44-ikconfig/arch/cris/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/i386/defconfig linux-2.5.44-ikconfig/arch/i386/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/ia64/defconfig linux-2.5.44-ikconfig/arch/ia64/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/m68k/defconfig linux-2.5.44-ikconfig/arch/m68k/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/mips/defconfig linux-2.5.44-ikconfig/arch/mips/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/mips64/defconfig linux-2.5.44-ikconfig/arch/mips64/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/parisc/defconfig linux-2.5.44-ikconfig/arch/parisc/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/ppc/defconfig linux-2.5.44-ikconfig/arch/ppc/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/ppc64/defconfig linux-2.5.44-ikconfig/arch/ppc64/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/s390/defconfig linux-2.5.44-ikconfig/arch/s390/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/s390x/defconfig linux-2.5.44-ikconfig/arch/s390x/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/sh/defconfig linux-2.5.44-ikconfig/arch/sh/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/sparc/defconfig linux-2.5.44-ikconfig/arch/sparc/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/sparc64/defconfig linux-2.5.44-ikconfig/arch/sparc64/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/um/defconfig linux-2.5.44-ikconfig/arch/um/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/arch/x86_64/defconfig linux-2.5.44-ikconfig/arch/x86_64/defconfig
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/init/Config.help linux-2.5.44-ikconfig/init/Config.help
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/init/Config.in linux-2.5.44-ikconfig/init/Config.in
@@ -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
diff -urN --exclude-from=/linux/diff_exclude_file linux-2.5.44/kernel/Makefile linux-2.5.44-ikconfig/kernel/Makefile
@@ -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

#1 lore raw

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.make

kernel/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

#2 lore raw
In reply to Khalid Aziz
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