Skip to contentSkip to conversation

x86: Add "make tinyconfig" to configure the tiniest possible kernel

PATCH In review Josh Triplett 5 participants 21 messages Aug 6, 2014 – Aug 15, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Add "make tinyconfig" to configure the tiniest possible kernel

Since commit 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a ("kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT") in 3.15-rc1, "make allnoconfig" disables every possible config option.

However, a few configuration options (CC_OPTIMIZE_FOR_SIZE, OPTIMIZE_INLINING) produce a smaller kernel when turned on, and a few choices exist (compression, highmem, allocator) for which a non-default option produces a smaller kernel.

Add a "tinyconfig" target, which starts from allnoconfig and then sets these options to configure the tiniest possible kernel. This provides a better baseline for embedded systems or efforts to reduce kernel size.

---
 arch/x86/Makefile            | 6 ++++++
 arch/x86/configs/tiny.config | 5 +++++
 2 files changed, 11 insertions(+)
 create mode 100644 arch/x86/configs/tiny.config
arch/x86/Makefile +6 -0
index c65fd96..f20abcd 100644
@@ -253,6 +253,11 @@ kvmconfig:
 	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m -O $(objtree) $(objtree)/.config $(srctree)/arch/x86/configs/kvm_guest.config
 	$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
 
+PHONY += tinyconfig
+tinyconfig: allnoconfig
+	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m -O $(objtree) $(objtree)/.config $(srctree)/arch/x86/configs/tiny.config
+	$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
+
 define archhelp
   echo  '* bzImage      - Compressed kernel image (arch/x86/boot/bzImage)'
   echo  '  install      - Install kernel using'
@@ -267,4 +272,5 @@ define archhelp
   echo  '                  FDARGS="..."  arguments for the booted kernel'
   echo  '                  FDINITRD=file initrd for the booted kernel'
   echo  '  kvmconfig	- Enable additional options for guest kernel support'
+  echo  '  tinyconfig   - Configure the tiniest possible kernel'
 endef
arch/x86/configs/tiny.config new file +5 -0
new file mode 100644
index 0000000..8f0e54c
@@ -0,0 +1,5 @@
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_KERNEL_XZ=y
+CONFIG_NOHIGHMEM=y
+CONFIG_OPTIMIZE_INLINING=y
+CONFIG_SLOB=y
Signature · 1 line
2.0.1
#1 lore raw
Quoted 4 lines · Josh Triplett

Since commit 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a ("kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT") in 3.15-rc1, "make allnoconfig" disables every possible config option.

Quoted 9 lines

However, a few configuration options (CC_OPTIMIZE_FOR_SIZE, OPTIMIZE_INLINING) produce a smaller kernel when turned on, and a few choices exist (compression, highmem, allocator) for which a non-default option produces a smaller kernel.

Add a "tinyconfig" target, which starts from allnoconfig and then sets these options to configure the tiniest possible kernel. This provides a better baseline for embedded systems or efforts to reduce kernel size.

I like it, the only comment that I have is that we already have a xenconfig patchset sitting around that adds a helper function for this functionality in the x86 Makefile that hasn't been merged yet.

The *config functionality is added in
http://marc.info/?l=linux-kernel&m=140233900403377

and then used in
http://marc.info/?l=linux-kernel&m=140233901403381
http://marc.info/?l=linux-kernel&m=140233904503428

and have been pending since June. I was going to ask Luis to rebase and resend, but perhaps you can send the first patch along as a predecessor to your patch and then let tinyconfig use build-virtconfig?

#2 lore raw
Quoted 22 lines · David Rientjes
Quoted 4 lines · Josh Triplett

Since commit 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a ("kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT") in 3.15-rc1, "make allnoconfig" disables every possible config option.

Quoted 9 lines

However, a few configuration options (CC_OPTIMIZE_FOR_SIZE, OPTIMIZE_INLINING) produce a smaller kernel when turned on, and a few choices exist (compression, highmem, allocator) for which a non-default option produces a smaller kernel.

Add a "tinyconfig" target, which starts from allnoconfig and then sets these options to configure the tiniest possible kernel. This provides a better baseline for embedded systems or efforts to reduce kernel size.

I like it, the only comment that I have is that we already have a xenconfig patchset sitting around that adds a helper function for this functionality in the x86 Makefile that hasn't been merged yet.

The *config functionality is added in
http://marc.info/?l=linux-kernel&m=140233900403377

Quoted 7 lines

and then used in
http://marc.info/?l=linux-kernel&m=140233901403381
http://marc.info/?l=linux-kernel&m=140233904503428

and have been pending since June. I was going to ask Luis to rebase and resend, but perhaps you can send the first patch along as a predecessor to your patch and then let tinyconfig use build-virtconfig?

Sure, no problem. I ended up modifying that patch a bit, but I included a mini-changelog in it noting that I based it on Luis's patch. Will send a 2-patch v2 series momentarily, in response to this mail.

- Josh Triplett

#3 lore raw

PATCH 1/2 x86, platform, kconfig: move kvmconfig functionality to a helper

The new mergeconfig helper makes it easier to add other partial configurations similar to kvmconfig.

Based on a patch by Luis R. Rodriguez <[email protected]>.

Modified to make the helper name more general than just virtualization, and factor out more of the common file path.

---

Hopefully the above changelog message makes the origin of this patch clear; it didn't seem appropriate to keep a Signed-off-by when modifying the patch, but I wanted to preserve the credit.

 arch/x86/Makefile | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
arch/x86/Makefile +7 -3
index c65fd96..1568678 100644
@@ -247,11 +247,15 @@ archclean:
 	$(Q)$(MAKE) $(clean)=$(boot)
 	$(Q)$(MAKE) $(clean)=arch/x86/tools
 
+define mergeconfig
+$(if $(wildcard $(objtree)/.config),, $(error You need an existing .config for this target))
+$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m -O $(objtree) $(objtree)/.config $(srctree)/arch/x86/configs/$(1).config
+$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
+endef
+
 PHONY += kvmconfig
 kvmconfig:
-	$(if $(wildcard $(objtree)/.config),, $(error You need an existing .config for this target))
-	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m -O $(objtree) $(objtree)/.config $(srctree)/arch/x86/configs/kvm_guest.config
-	$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
+	$(call mergeconfig,kvm_guest)
 
 define archhelp
   echo  '* bzImage      - Compressed kernel image (arch/x86/boot/bzImage)'
Signature · 1 line
2.1.0.rc1
Acked-by on v1 1/2
#4 lore raw

Re: [PATCH 1/2] x86, platform, kconfig: move kvmconfig functionality to a helper

Quoted 10 lines · Josh Triplett

The new mergeconfig helper makes it easier to add other partial configurations similar to kvmconfig.

Based on a patch by Luis R. Rodriguez <[email protected]>.

Modified to make the helper name more general than just virtualization, and factor out more of the common file path.

For the original patch from Luis:

For this patch:

Thanks for generalizing this part of the Makefile, after it's merged it will make Luis's set reduce down to a single change.

#5 lore raw

Re: [PATCH 1/2] x86, platform, kconfig: move kvmconfig functionality to a helper

Quoted 12 lines · David Rientjes
Quoted 10 lines · Josh Triplett

The new mergeconfig helper makes it easier to add other partial configurations similar to kvmconfig.

Based on a patch by Luis R. Rodriguez <[email protected]>.

Modified to make the helper name more general than just virtualization, and factor out more of the common file path.

Quoted 8 lines

For the original patch from Luis:

For this patch:

Thanks for generalizing this part of the Makefile, after it's merged it will make Luis's set reduce down to a single change.

Thank you as well for suggesting this refactoring; I should have thought to do the same rather than copying and pasting the contents of kvmconfig.

Should this go in via Andrew's -mm tree, or via tip for x86?

- Josh Triplett

#6 lore raw

Re: [PATCH 1/2] x86, platform, kconfig: move kvmconfig functionality to a helper

Quoted 17 lines · Josh Triplett
Quoted 17 lines
Quoted 10 lines

The new mergeconfig helper makes it easier to add other partial configurations similar to kvmconfig.

Based on a patch by Luis R. Rodriguez <[email protected]>.

Modified to make the helper name more general than just virtualization, and factor out more of the common file path.

For the original patch from Luis:

For this patch:

Quoted 9 lines
Quoted 2 lines

Thanks for generalizing this part of the Makefile, after it's merged it will make Luis's set reduce down to a single change.

Thank you as well for suggesting this refactoring; I should have thought to do the same rather than copying and pasting the contents of kvmconfig.

Should this go in via Andrew's -mm tree, or via tip for x86?

The answer could be "both", if Ingo doesn't pick it up then Andrew sometimes picks it up and sends them along later.

#7 lore raw

PATCH 2/2 x86: Add "make tinyconfig" to configure the tiniest possible kernel

In reply to Josh Triplett

Since commit 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a ("kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT") in 3.15-rc1, "make allnoconfig" disables every possible config option.

However, a few configuration options (CC_OPTIMIZE_FOR_SIZE, OPTIMIZE_INLINING) produce a smaller kernel when turned on, and a few choices exist (compression, highmem, allocator) for which a non-default option produces a smaller kernel.

Add a "tinyconfig" option, which starts from allnoconfig and then sets these options to configure the tiniest possible kernel. This provides a better baseline for embedded systems or efforts to reduce kernel size.

---

v2: Based this on Luis's helper, added in patch 1/2, which eliminates the previously duplicated implementation from kvmconfig.

 arch/x86/Makefile            | 5 +++++
 arch/x86/configs/tiny.config | 5 +++++
 2 files changed, 10 insertions(+)
 create mode 100644 arch/x86/configs/tiny.config
arch/x86/Makefile +5 -0
index 1568678..2b5ca16 100644
@@ -257,6 +257,10 @@ PHONY += kvmconfig
 kvmconfig:
 	$(call mergeconfig,kvm_guest)
 
+PHONY += tinyconfig
+tinyconfig: allnoconfig
+	$(call mergeconfig,tiny)
+
 define archhelp
   echo  '* bzImage      - Compressed kernel image (arch/x86/boot/bzImage)'
   echo  '  install      - Install kernel using'
@@ -271,4 +275,5 @@ define archhelp
   echo  '                  FDARGS="..."  arguments for the booted kernel'
   echo  '                  FDINITRD=file initrd for the booted kernel'
   echo  '  kvmconfig	- Enable additional options for guest kernel support'
+  echo  '  tinyconfig   - Configure the tiniest possible kernel'
 endef
arch/x86/configs/tiny.config new file +5 -0
new file mode 100644
index 0000000..8f0e54c
@@ -0,0 +1,5 @@
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_KERNEL_XZ=y
+CONFIG_NOHIGHMEM=y
+CONFIG_OPTIMIZE_INLINING=y
+CONFIG_SLOB=y
Signature · 1 line
2.1.0.rc1
#8 lore raw

arch/x86/Makefile PHONY += kvmconfig · line 261

Quoted 10 lines · Josh Triplett
arch/x86/Makefile +2 -0
index 1568678..2b5ca16 100644
@@ -257,6 +257,10 @@ PHONY += kvmconfig
 kvmconfig:
 	$(call mergeconfig,kvm_guest)
 
+PHONY += tinyconfig
+tinyconfig: allnoconfig

Calling allnoconfig here makes "make tinyconfig" default to CONFIG_X86_32 even on 64 bit platforms and the caller would need to explicitly do "make ARCH=x86_64 tinyconfig" to avoid it. It's not clear that this is intended from the documentation of tinyconfig, that tiniest == 32 bit by default.

Quoted 22 lines
arch/x86/Makefile +3 -0
+	$(call mergeconfig,tiny)
+
 define archhelp
   echo  '* bzImage      - Compressed kernel image (arch/x86/boot/bzImage)'
   echo  '  install      - Install kernel using'
@@ -271,4 +275,5 @@ define archhelp
   echo  '                  FDARGS="..."  arguments for the booted kernel'
   echo  '                  FDINITRD=file initrd for the booted kernel'
   echo  '  kvmconfig	- Enable additional options for guest kernel support'
+  echo  '  tinyconfig   - Configure the tiniest possible kernel'
 endef
arch/x86/configs/tiny.config new file +5 -0
new file mode 100644
index 0000000..8f0e54c
@@ -0,0 +1,5 @@
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_KERNEL_XZ=y
+CONFIG_NOHIGHMEM=y
+CONFIG_OPTIMIZE_INLINING=y
+CONFIG_SLOB=y
#9 lore raw
Quoted 9 lines · David Rientjes
Quoted 8 lines · Josh Triplett
arch/x86/Makefile +0 -0
index 1568678..2b5ca16 100644
@@ -257,6 +257,10 @@ PHONY += kvmconfig
 kvmconfig:
 	$(call mergeconfig,kvm_guest)
 
Quoted 8 lines

arch/x86/Makefile PHONY += kvmconfig · line 261

Quoted 2 lines
arch/x86/Makefile +2 -0
+PHONY += tinyconfig
+tinyconfig: allnoconfig

Calling allnoconfig here makes "make tinyconfig" default to CONFIG_X86_32 even on 64 bit platforms and the caller would need to explicitly do "make ARCH=x86_64 tinyconfig" to avoid it. It's not clear that this is intended from the documentation of tinyconfig, that tiniest == 32 bit by default.

Calling allnoconfig was quite intentional; this is intended to be the smallest possible configuration, and unlike kvmconfig (which modifies an existing configuration to make it suitable for a KVM guest), this intentionally creates a specific new configuration from scratch.

32-bit produces a far smaller kernel than 64-bit, so having that as the default for tinyconfig seems quite appropriate. As you showed, it's easy enough to override it if needed. I'd expect many potential users of tinyconfig for embedded systems to start with tinyconfig and then immediately use menuconfig to enable a pile of additional options.

- Josh Triplett

#10 lore raw
Quoted 24 lines · Josh Triplett
Quoted 9 lines · David Rientjes
Quoted 8 lines · Josh Triplett
arch/x86/Makefile +0 -0
index 1568678..2b5ca16 100644
@@ -257,6 +257,10 @@ PHONY += kvmconfig
 kvmconfig:
 	$(call mergeconfig,kvm_guest)
 
Quoted 8 lines

arch/x86/Makefile PHONY += kvmconfig · line 261

Quoted 2 lines
arch/x86/Makefile +2 -0
+PHONY += tinyconfig
+tinyconfig: allnoconfig

Calling allnoconfig here makes "make tinyconfig" default to CONFIG_X86_32 even on 64 bit platforms and the caller would need to explicitly do "make ARCH=x86_64 tinyconfig" to avoid it. It's not clear that this is intended from the documentation of tinyconfig, that tiniest == 32 bit by default.

Calling allnoconfig was quite intentional; this is intended to be the smallest possible configuration, and unlike kvmconfig (which modifies an existing configuration to make it suitable for a KVM guest), this intentionally creates a specific new configuration from scratch.

Quoted 6 lines

32-bit produces a far smaller kernel than 64-bit, so having that as the default for tinyconfig seems quite appropriate. As you showed, it's easy enough to override it if needed. I'd expect many potential users of tinyconfig for embedded systems to start with tinyconfig and then immediately use menuconfig to enable a pile of additional options.

In that case, any reason to make tinyconfig x86 only?

#11 lore raw
Quoted 25 lines · David Rientjes
Quoted 24 lines · Josh Triplett
Quoted 9 lines · David Rientjes
Quoted 8 lines · Josh Triplett
arch/x86/Makefile +0 -0
index 1568678..2b5ca16 100644
@@ -257,6 +257,10 @@ PHONY += kvmconfig
 kvmconfig:
 	$(call mergeconfig,kvm_guest)
 
Quoted 8 lines

arch/x86/Makefile PHONY += kvmconfig · line 261

Quoted 2 lines
arch/x86/Makefile +2 -0
+PHONY += tinyconfig
+tinyconfig: allnoconfig

Calling allnoconfig here makes "make tinyconfig" default to CONFIG_X86_32 even on 64 bit platforms and the caller would need to explicitly do "make ARCH=x86_64 tinyconfig" to avoid it. It's not clear that this is intended from the documentation of tinyconfig, that tiniest == 32 bit by default.

Calling allnoconfig was quite intentional; this is intended to be the smallest possible configuration, and unlike kvmconfig (which modifies an existing configuration to make it suitable for a KVM guest), this intentionally creates a specific new configuration from scratch.

Quoted 7 lines
Quoted 5 lines

32-bit produces a far smaller kernel than 64-bit, so having that as the default for tinyconfig seems quite appropriate. As you showed, it's easy enough to override it if needed. I'd expect many potential users of tinyconfig for embedded systems to start with tinyconfig and then immediately use menuconfig to enable a pile of additional options.

In that case, any reason to make tinyconfig x86 only?

The set of configuration options may vary by architecture. For instance, NOHIGHMEM only exists on x86. So, at a minimum, different architectures will require different versions of tiny.config.

The target itself and the common options could theoretically be shared, but that would require splitting the configuration, and it isn't obvious where the non-arch-specific tiny.config would live. There doesn't appear to be any precedent for that kind of setup; only x86 has a configuration other than defconfigs (specifically, kvm_guest.config). I don't think it's likely that new targets like this will pop up often in the future, either.

Nonetheless, I could modify scripts/kconfig/Makefile to add this target instead, if someone has a good suggestion for where the non-arch-specific tiny.config should live. (kernel/configs/ ?)

- Josh Triplett

#12 lore raw
In reply to Josh Triplett
Quoted 4 lines · Josh Triplett

Since commit 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a ("kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT") in 3.15-rc1, "make allnoconfig" disables every possible config option.

Quoted 8 lines

However, a few configuration options (CC_OPTIMIZE_FOR_SIZE, OPTIMIZE_INLINING) produce a smaller kernel when turned on, and a few choices exist (compression, highmem, allocator) for which a non-default option produces a smaller kernel.

Add a "tinyconfig" option, which starts from allnoconfig and then sets these options to configure the tiniest possible kernel. This provides a better baseline for embedded systems or efforts to reduce kernel size.

In general I dislike the whole approach where we introduce makefile magic to support diverse config snippets.
Another approch where we factor out this from the MAkefile seems much leaner.

And for this specific patch then this is not x86 specific at all.
If we keep the logic in the makefiles than we should:
1) Make the infrastructure general
2) Document it
3) Find another home for the config snippets that are non-arch specific like this one

Sam

arch/x86/configs/tiny.config line 5

Quoted 11 lines
arch/x86/configs/tiny.config new file +5 -0
new file mode 100644
index 0000000..8f0e54c
@@ -0,0 +1,5 @@
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_KERNEL_XZ=y
+CONFIG_NOHIGHMEM=y
+CONFIG_OPTIMIZE_INLINING=y
+CONFIG_SLOB=y

All the above are general options that apply equal to arm than to x86.

Sam

#13 lore raw
Quoted 18 lines · Sam Ravnborg
Quoted 4 lines · Josh Triplett

Since commit 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a ("kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT") in 3.15-rc1, "make allnoconfig" disables every possible config option.

Quoted 8 lines

However, a few configuration options (CC_OPTIMIZE_FOR_SIZE, OPTIMIZE_INLINING) produce a smaller kernel when turned on, and a few choices exist (compression, highmem, allocator) for which a non-default option produces a smaller kernel.

Add a "tinyconfig" option, which starts from allnoconfig and then sets these options to configure the tiniest possible kernel. This provides a better baseline for embedded systems or efforts to reduce kernel size.

In general I dislike the whole approach where we introduce makefile magic to support diverse config snippets.
Another approch where we factor out this from the MAkefile seems much leaner.

Quoted 5 lines

And for this specific patch then this is not x86 specific at all.
If we keep the logic in the makefiles than we should:
1) Make the infrastructure general
2) Document it
3) Find another home for the config snippets that are non-arch specific like this one

I'll refactor this and resubmit.

Quoted 4 lines
Quoted 4 lines
arch/x86/configs/tiny.config new file +0 -1
new file mode 100644
index 0000000..8f0e54c
--- /dev/null
Quoted 8 lines

arch/x86/configs/tiny.config line 5

Quoted 7 lines

+++ b/arch/x86/configs/tiny.config

arch/x86/configs/tiny.config new file +5 -0
@@ -0,0 +1,5 @@
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_KERNEL_XZ=y
+CONFIG_NOHIGHMEM=y
+CONFIG_OPTIMIZE_INLINING=y
+CONFIG_SLOB=y

All the above are general options that apply equal to arm than to x86.

NOHIGHMEM isn't.

- Josh Triplett

#14 lore raw
Quoted 14 lines
Quoted 13 lines

arch/x86/configs/tiny.config line 5

Quoted 12 lines
arch/x86/configs/tiny.config new file +5 -0
new file mode 100644
index 0000000..8f0e54c
@@ -0,0 +1,5 @@
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_KERNEL_XZ=y
+CONFIG_NOHIGHMEM=y
+CONFIG_OPTIMIZE_INLINING=y
+CONFIG_SLOB=y

All the above are general options that apply equal to arm than to x86.

Quoted 1 line

NOHIGHMEM isn't.

You are right - as it is x86 specific it should had been prefixed with X86_ to document so.

As the symbol is only relevant for X86 it will not hurt anyone else, so it is OK to have it.
But it would be nice to document in tiny.config that
this is a X86 specific symbol.

Sam

#15 lore raw

PATCH v3 1/2 x86, platform, kconfig: move kvmconfig functionality to a helper

In reply to Josh Triplett

The new mergeconfig helper makes it easier to add other partial configurations similar to kvmconfig. Architecture-independent portions of those partial configurations should go in kernel/configs/${name}.config, and architecture-dependent portions should go in arch/${arch}/configs/${name}.config.

Based on a patch by Luis R. Rodriguez <[email protected]>.

Modified to make the helper name more general than just virtualization, support architecture-dependent and architecture-independent partial configurations, move the helper and kvmconfig to scripts/kconfig/Makefile, and factor out more of the common file path.

---

Note that this leaves kvm_guest.config in arch/x86/configs/ . A KVM expert is welcome to follow up with a patch splitting the options in kvm_guest.config between arch/x86/configs/ and kernel/configs/ .

 arch/x86/Makefile        |  7 -------
 scripts/kconfig/Makefile | 14 ++++++++++++++
 2 files changed, 14 insertions(+), 7 deletions(-)
arch/x86/Makefile +0 -7
index c65fd96..fcc74b7 100644
@@ -247,12 +247,6 @@ archclean:
 	$(Q)$(MAKE) $(clean)=$(boot)
 	$(Q)$(MAKE) $(clean)=arch/x86/tools
 
-PHONY += kvmconfig
-kvmconfig:
-	$(if $(wildcard $(objtree)/.config),, $(error You need an existing .config for this target))
-	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m -O $(objtree) $(objtree)/.config $(srctree)/arch/x86/configs/kvm_guest.config
-	$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
-
 define archhelp
   echo  '* bzImage      - Compressed kernel image (arch/x86/boot/bzImage)'
   echo  '  install      - Install kernel using'
@@ -266,5 +260,4 @@ define archhelp
   echo  '                  bzdisk/fdimage*/isoimage also accept:'
   echo  '                  FDARGS="..."  arguments for the booted kernel'
   echo  '                  FDINITRD=file initrd for the booted kernel'
-  echo  '  kvmconfig	- Enable additional options for guest kernel support'
 endef
scripts/kconfig/Makefile +14 -0
index 9c4d241..8083b94 100644
@@ -104,6 +104,19 @@ endif
 %_defconfig: $(obj)/conf
 	$(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
 
+configfiles=$(wildcard $(srctree)/kernel/configs/$(1).config $(srctree)/arch/$(SRCARCH)/configs/$(1).config)
+
+define mergeconfig
+$(if $(wildcard $(objtree)/.config),, $(error You need an existing .config for this target))
+$(if $(call configfiles,$(1)),, $(error No configuration exists for this target on this architecture))
+$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m -O $(objtree) $(objtree)/.config $(call configfiles,$(1))
+$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
+endef
+
+PHONY += kvmconfig
+kvmconfig:
+	$(call mergeconfig,kvm_guest)
+
 # Help text used by make help
 help:
 	@echo  '  config	  - Update current config utilising a line-oriented program'
@@ -124,6 +137,7 @@ help:
 	@echo  '  randconfig	  - New config with random answer to all options'
 	@echo  '  listnewconfig   - List new options'
 	@echo  '  olddefconfig	  - Same as silentoldconfig but sets new symbols to their default value'
+	@echo  '  kvmconfig	  - Enable additional options for guest kernel support'
 
 # lxdialog stuff
 check-lxdialog  := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
Signature · 1 line
2.1.0.rc1
#16 lore raw

PATCH v3 2/2 x86: Add "make tinyconfig" to configure the tiniest possible kernel

In reply to Josh Triplett

Since commit 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a ("kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT") in 3.15-rc1, "make allnoconfig" disables every possible config option.

However, a few configuration options (CC_OPTIMIZE_FOR_SIZE, OPTIMIZE_INLINING) produce a smaller kernel when turned on, and a few choices exist (compression, highmem, allocator) for which a non-default option produces a smaller kernel.

Add a "tinyconfig" option, which starts from allnoconfig and then sets these options to configure the tiniest possible kernel. This provides a better baseline for embedded systems or efforts to reduce kernel size.

---

Any architecture with architecture-specific tinification options just needs to create arch/${arch}/configs/tiny.config, and "make tinyconfig" will automatically pick up those options in addition to the architecture-independent ones in kernel/configs/tiny.config.

 arch/x86/configs/tiny.config | 1 +
 kernel/configs/tiny.config   | 4 ++++
 scripts/kconfig/Makefile     | 5 +++++
 3 files changed, 10 insertions(+)
 create mode 100644 arch/x86/configs/tiny.config
 create mode 100644 kernel/configs/tiny.config
arch/x86/configs/tiny.config new file +1 -0
new file mode 100644
index 0000000..4e2ecfa
@@ -0,0 +1 @@
+CONFIG_NOHIGHMEM=y
kernel/configs/tiny.config new file +4 -0
new file mode 100644
index 0000000..c2de56a
@@ -0,0 +1,4 @@
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_KERNEL_XZ=y
+CONFIG_OPTIMIZE_INLINING=y
+CONFIG_SLOB=y
scripts/kconfig/Makefile +5 -0
index 8083b94..ebf40f6 100644
@@ -117,6 +117,10 @@ PHONY += kvmconfig
 kvmconfig:
 	$(call mergeconfig,kvm_guest)
 
+PHONY += tinyconfig
+tinyconfig: allnoconfig
+	$(call mergeconfig,tiny)
+
 # Help text used by make help
 help:
 	@echo  '  config	  - Update current config utilising a line-oriented program'
@@ -138,6 +142,7 @@ help:
 	@echo  '  listnewconfig   - List new options'
 	@echo  '  olddefconfig	  - Same as silentoldconfig but sets new symbols to their default value'
 	@echo  '  kvmconfig	  - Enable additional options for guest kernel support'
+	@echo  '  tinyconfig	  - Configure the tiniest possible kernel'
 
 # lxdialog stuff
 check-lxdialog  := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
Signature · 1 line
2.1.0.rc1
#17 lore raw
Quoted 3 lines · Josh Triplett

Since commit 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a ("kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT") in 3.15-rc1, "make allnoconfig" disables every possible config option.

May I suggest pushing these through the kbuild tree, rather than (judging by the people cc'd) the x86 trees?

Linus

#18 lore raw
Quoted 7 lines · Linus Torvalds
Quoted 3 lines · Josh Triplett

Since commit 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a ("kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT") in 3.15-rc1, "make allnoconfig" disables every possible config option.

May I suggest pushing these through the kbuild tree, rather than (judging by the people cc'd) the x86 trees?

By all means; v3 seems sufficiently generic that it makes more sense for both of these patches to go in through a kbuild tree, or something else suitably general such as Andrew's tree.

Would someone mind picking it up, please?

- Josh Triplett

#19 lore raw
Quoted 6 lines · On Mon, Aug 11, 2014 at 11:15:21AM -0700, [email protected] wrote:
Quoted 5 lines · Linus Torvalds
Quoted 3 lines · Josh Triplett

Since commit 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a ("kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT") in 3.15-rc1, "make allnoconfig" disables every possible config option.

Quoted 8 lines
Quoted 2 lines

May I suggest pushing these through the kbuild tree, rather than (judging by the people cc'd) the x86 trees?

By all means; v3 seems sufficiently generic that it makes more sense for both of these patches to go in through a kbuild tree, or something else suitably general such as Andrew's tree.

Would someone mind picking it up, please?

I will take care that they are channeled through kbuild tree.

We are too late for this merge window so we are not in a hurry.

Sam

#20 lore raw
Quoted 10 lines · Sam Ravnborg
Quoted 9 lines · On Mon, Aug 11, 2014 at 11:15:21AM -0700, [email protected] wrote:
Quoted 7 lines · Linus Torvalds
Quoted 3 lines · Josh Triplett

Since commit 5d2acfc7b974bbd3858b4dd3f2cdc6362dd8843a ("kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT") in 3.15-rc1, "make allnoconfig" disables every possible config option.

May I suggest pushing these through the kbuild tree, rather than (judging by the people cc'd) the x86 trees?

Quoted 8 lines
Quoted 5 lines

By all means; v3 seems sufficiently generic that it makes more sense for both of these patches to go in through a kbuild tree, or something else suitably general such as Andrew's tree.

Would someone mind picking it up, please?

I will take care that they are channeled through kbuild tree.

We are too late for this merge window so we are not in a hurry.

This went in with a helper which I had originally submitted to enable xenconfig but xenconfig patch went nowhere for some reason. What tree should I use to rebase and who should I sent this stuff to? The last series got reviewed bug just collected dust after we agreed on the approach.

Luis