Immediate values provide a way to use dynamic code patching to update variables
sitting within the instruction stream. It saves caches lines normally used by
static read mostly variables. Enable it by default, but let users disable it
through the EMBEDDED menu with the "Disable immediate values" submenu entry.Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: Adrian Bunk <bunk@stusta.de>
CC: Andi Kleen <andi@firstfloor.org>
CC: Alexey Dobriyan <adobriyan@gmail.com>
CC: Christoph Hellwig <hch@infradead.org>
---
init/Kconfig | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)Index: linux-2.6-lttng/init/Kconfig
===================================================================
--- linux-2.6-lttng.orig/init/Kconfig 2007-09-04 11:53:59.000000000 -0400
+++ linux-2.6-lttng/init/Kconfig 2007-09-04 12:12:03.000000000 -0400
@@ -407,6 +407,17 @@ config CC_OPTIMIZE_FOR_SIZE
config SYSCTL
bool+config IMMEDIATE
+ default y if !DISABLE_IMMEDIATE
+ depends on X86_32 || PPC || PPC64
+ bool
+ help
+ Immediate values are used as read mostly variables that are rarely
+ updated. They use code patching to modify the values inscribed in the
+ instruction stream. It provides a way to save precious cache lines
+ that would otherwise have to be used by these variables. Can be
+ disabled through the EMBEDDED menu.
+
menuconfig EMBEDDED
bool "Configure standard kernel features (for small systems)"
help
@@ -645,6 +656,16 @@ config PROC_KPAGEMAP
information on page-level memory usage. Disabling this interface
will reduce the size of the kernel by around 600 bytes.+config DISABLE_IMMEDIATE
+ default y if EMBEDDED
+ bool "Disable immediate values" if EMBEDDED
+ depends on X86_32 || PPC || PPC64
+ help
+ Disable code patching based immediate values for embedded systems. It
+ consumes slightly more memory and requires to modify the instruction
+ stream each time a variable is updated. S...
It's still unclear to me why DISABLE_IMMEDIATE is needed. It would
There are no such on x86 at least And for other architectures like
PPC it would be better to have a high level CONFIG_READ_ONLY_TEXT
then that does the necessary changes internally. But I'm not sure it's even
supporting r/o text.-Andi
-
It is actually the default on any non embedded configuration. Do you
The idea here is to give embedded system developers incentives to
create an optimized immediate value header for their architecture. I
fear that if it is not trivial to disable when they need to use ROM to
put the kernel code (as kprobes is, meaning, with a single config
option), they will refuse to event think about including an optimized
immediate value header for their architecture.And yes, having a CONFIG_READ_ONLY_TEXT makes sense, but it implies
menu dependencies with not only immediate values but also kprobes,
paravirt, alternatives, (am I missing others ?)As long as we find a way for people to disable _all_ code patching in
their kernel, I'm happy with that. But since every existing code
patching mechanism can currently be disabled one by one, it makes sense
to do the same for the immediate values. Having a global
CONFIG_READ_ONLY_TEXT should IMHO come in a separate effort.--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
-
I would prefer to not have any config options at all and let
#ifdef CONFIG_ARCH_SPECIFIC_READONLY
#include <asm-generic/generic-immediate.h>
#else
/* optimized implementation */
#endifparavirt and alternatives are x86 only.
I don't think CONFIG_READ_ONLY_TEXT on x86 makes sense.
On other architectures they have to deal with kprobes, but they
You're clearly deep into overdesign territory here.
-Andi
-
Yeah, but then you would make immediate.o an obj-y (both for
kernel/Makefile and arch/*/kernel/Makefile) and it would be built
even on systems that would be configured not to use immediate values.Therefore, it would compile-in unused code if we do as you propose,
which I am reluctant to do on embedded systems where code size matters.--
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
-
You can stick a define into generic-immediate.h and put an ifndef
for that around immediate.cOr the recently posted function garbage collection patches would
also take care of it.-Andi
-
| Chuck Ebbert | Why do so many machines need "noapic"? |
| Greg Kroah-Hartman | [PATCH 004/196] Chinese: add translation of SubmittingPatches |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
| Jeremy Allison | Re: [RFC] Heads up on sys_fallocate() |
git: | |
| Corey Minyard | [PATCH 3/3] Convert the UDP hash lock to RCU |
| David Miller | [GIT]: Networking |
| Denys Fedoryshchenko | packetloss, on e1000e worse than r8169? |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
