2008-02-13 16:00:55

by Thomas Petazzoni

[permalink] [raw]
Subject: [PATCH] Configure out TSC support

Hi,

The following patch allows to remove the code needed to support the TSC
timer on x86 32 bits. The TSC seems to be mandatory on x86 64 bits. The
patch adds a X86_TSC_TIMER option to enable/disable the support.

A X86_TSC option already exists, but it is not an option, it's simply
set to true when the processor has a TSC. However, the purpose of the
patch is to disable the TSC support even if the processor has it.

Comments welcome.

Thanks,

Thomas

---

Add a new configuration option that allows the TSC timer support code
to not be compiled, in order to make some space savings on the kernel
code size. The option depends on X86_32, because on 64 bits, the TSC
seems to be mandatory.

The results are:

text data bss dec hex filename
1068092 126308 98304 1292704 13b9a0 vmlinux.before
1066956 126296 98304 1291556 13b524 vmlinux.after
-1136 -12 0 -1148 -47C +/

This patch is part of the Linux Tiny project, and is based on previous
work done by Zwane Mwaikambo <[email protected]>.

Signed-off-by: Thomas Petazzoni <[email protected]>

---
arch/x86/Kconfig | 6 ++++++
arch/x86/kernel/Makefile | 3 ++-
include/asm/tsc.h | 4 ++++
3 files changed, 12 insertions(+), 1 deletion(-)

Index: linux/arch/x86/Kconfig
===================================================================
--- linux.orig/arch/x86/Kconfig
+++ linux/arch/x86/Kconfig
@@ -395,6 +395,12 @@
def_bool y
depends on X86_32 && NUMA && (X86_SUMMIT || X86_GENERICARCH)

+config X86_TSC_TIMER
+ default y
+ bool "Enable TSC timer" if EMBEDDED && X86_32
+ help
+ Enable support for the Time Stamp Counter timer.
+
config X86_CYCLONE_TIMER
def_bool y
depends on X86_32 && X86_SUMMIT || X86_GENERICARCH
Index: linux/arch/x86/kernel/Makefile
===================================================================
--- linux.orig/arch/x86/kernel/Makefile
+++ linux/arch/x86/kernel/Makefile
@@ -19,8 +19,9 @@
obj-y += quirks.o i8237.o topology.o kdebugfs.o
obj-y += alternative.o i8253.o
obj-$(CONFIG_X86_64) += pci-nommu_64.o bugs_64.o
-obj-y += tsc_$(BITS).o io_delay.o rtc.o
+obj-y += io_delay.o rtc.o

+obj-$(CONFIG_X86_TSC_TIMER) += tsc_$(BITS).o
obj-y += i387.o
obj-y += ptrace.o
obj-y += ds.o
Index: linux/include/asm/tsc.h
===================================================================
--- linux.orig/include/asm/tsc.h
+++ linux/include/asm/tsc.h
@@ -45,7 +45,11 @@
return (cycles_t) __native_read_tsc();
}

+#ifdef CONFIG_X86_TSC_TIMER
extern void tsc_init(void);
+#else
+static inline void tsc_init(void) { }
+#endif
extern void mark_tsc_unstable(char *reason);
extern int unsynchronized_tsc(void);
extern void init_tsc_clocksource(void);


--
Thomas Petazzoni, Free Electrons
Free Embedded Linux Training Materials
on http://free-electrons.com/training
(More than 1500 pages!)


Attachments:
signature.asc (189.00 B)

2008-02-17 17:04:21

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] Configure out TSC support


* Thomas Petazzoni <[email protected]> wrote:

> The following patch allows to remove the code needed to support the
> TSC timer on x86 32 bits. The TSC seems to be mandatory on x86 64
> bits. The patch adds a X86_TSC_TIMER option to enable/disable the
> support.
>
> A X86_TSC option already exists, but it is not an option, it's simply
> set to true when the processor has a TSC. However, the purpose of the
> patch is to disable the TSC support even if the processor has it.

thanks, applied.

Ingo

2008-02-18 02:28:42

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] Configure out TSC support


> * Thomas Petazzoni <[email protected]> wrote:
>
> > The following patch allows to remove the code needed to support the
> > TSC timer on x86 32 bits. The TSC seems to be mandatory on x86 64
> > bits. The patch adds a X86_TSC_TIMER option to enable/disable the
> > support.
> >
> > A X86_TSC option already exists, but it is not an option, it's
> > simply set to true when the processor has a TSC. However, the
> > purpose of the patch is to disable the TSC support even if the
> > processor has it.

make randconfig testing found a build failure due to this patch:

arch/x86/mach-generic/built-in.o: In function `acpi_madt_oem_check':
summit.c:(.text+0x290): undefined reference to `mark_tsc_unstable'
arch/x86/mach-generic/built-in.o: In function `mps_oem_check':
summit.c:(.text+0x310): undefined reference to `mark_tsc_unstable'
[...]

config attached.

Ingo


Attachments:
(No filename) (897.00 B)
config (53.66 kB)
Download all attachments