2003-05-07 19:19:00

by Thomas Horsten

[permalink] [raw]
Subject: [PATCH] 2.5.69 Changes to Kconfig and i386 Makefile to include support for various K7 optimizations

Hi all,

I made this patch to support the various K7 model-specific optimizations that
the later GCC compilers can use.

Please have a look, and pass me any comments.

I also have the same patch for 2.4, if you are interested it's available on
my Linux page on http://www.infowares.com/linux

// Thomas

diff -r -u linux-2.5.69.orig/arch/i386/Kconfig linux-2.5.69/arch/i386/Kconfig
--- linux-2.5.69.orig/arch/i386/Kconfig 2003-05-05 00:53:02.000000000 +0100
+++ linux-2.5.69/arch/i386/Kconfig 2003-05-07 18:00:11.000000000 +0100
@@ -273,6 +273,48 @@

endchoice

+#
+# Select the exact K7 model for optimization purposes
+#
+choice
+ prompt "K7 Model Selection"
+ depends on MK7
+ default K7_STD
+
+config K7_STD
+ bool "Standard Athlon/Duron/Other"
+ help
+ Select this if you have a standard Athlon or Duron processor, or
+ another varian that is not listed below. Kernels compiled with this
+ option should work on a system that uses any member of the K7 family
+ of processors.
+
+config K7_TBIRD
+ bool "Athlon Thunderbird"
+ help
+ Select this if you have the "Thunderbird" version of the Athlon CPU,
+ to enable optimizations specific to that processor.
+
+config K7_ATHLON4
+ bool "Athlon 4 (Palomino)"
+ help
+ Select this if you have an Athlon 4 CPU, also known as "Palomino",
+ to enable optimizations specific to that processor.
+
+config K7_ATHLONXP
+ bool "Athlon XP"
+ help
+ Select this if you have an Athlon XP CPU, to enable optimizations
+ specific to that processor.
+
+config K7_ATHLONMP
+ bool "Athlon MP"
+ help
+ Select this if you have an Athlon XP CPU, to enable optimizations
+ specific to that processor.
+
+endchoice
+
config X86_GENERIC
bool "Generic x86 support"
help
diff -r -u linux-2.5.69.orig/arch/i386/Makefile
linux-2.5.69/arch/i386/Makefile ---
linux-2.5.69.orig/arch/i386/Makefile 2003-05-05 00:53:12.000000000 +0100 +++
linux-2.5.69/arch/i386/Makefile 2003-05-07 18:10:08.000000000 +0100 @@ -39,7
+39,11 @@
cflags-$(CONFIG_MPENTIUMIII) += $(call
check_gcc,-march=pentium3,-march=i686) cflags-$(CONFIG_MPENTIUM4) += $(call
check_gcc,-march=pentium4,-march=i686) cflags-$(CONFIG_MK6) += $(call
check_gcc,-march=k6,-march=i586)
-cflags-$(CONFIG_MK7) += $(call check_gcc,-march=athlon,-march=i686
$(align)-functions=4) +cflags-$(CONFIG_K7_STD) += $(call
check_gcc,-march=athlon,-march=i686 $(align)-functions=4)
+cflags-$(CONFIG_K7_TBIRD) += $(call check_gcc,-march=athlon-tbird,$(call
check_gcc,-march=athlon,-march=i686 $(align)-functions=4))
+cflags-$(CONFIG_K7_ATHLON4) += $(call check_gcc,-march=athlon-4,$(call
check_gcc,-march=athlon,-march=i686 $(align)-functions=4))
+cflags-$(CONFIG_K7_ATHLONXP) += $(call check_gcc,-march=athlon-xp,$(call
check_gcc,-march=athlon,-march=i686 $(align)-functions=4))
+cflags-$(CONFIG_K7_ATHLONMP) += $(call check_gcc,-march=athlon-mp,$(call
check_gcc,-march=athlon,-march=i686 $(align)-functions=4))
cflags-$(CONFIG_MK8) += $(call check_gcc,-march=k8,$(call
check_gcc,-march=athlon,-march=i686 $(align)-functions=4))
cflags-$(CONFIG_MCRUSOE) += -march=i686 $(align)-functions=0
$(align)-jumps=0 $(align)-loops=0 cflags-$(CONFIG_MWINCHIPC6) += $(call
check_gcc,-march=winchip-c6,-march=i586)


2003-05-07 19:54:31

by Ken Witherow

[permalink] [raw]
Subject: Re: [PATCH] 2.5.69 Changes to Kconfig and i386 Makefile to include support for various K7 optimizations

On Wed, 7 May 2003, Thomas Horsten wrote:

> +config K7_ATHLONXP
> + bool "Athlon XP"
> + help
> + Select this if you have an Athlon XP CPU, to enable optimizations
> + specific to that processor.
> +
> +config K7_ATHLONMP
> + bool "Athlon MP"
> + help
> + Select this if you have an Athlon XP CPU, to enable optimizations
> + specific to that processor.

I do believe Athlon XP when you mean MP is a copy/paste typo :)

--
Ken Witherow <phantoml AT rochester.rr.com>
ICQ: 21840670 AIM: phantomlordken
http://www.krwtech.com/ken

2003-05-07 20:31:55

by Thomas Horsten

[permalink] [raw]
Subject: Re: [PATCH] 2.5.69 Changes to Kconfig and i386 Makefile to include support for various K7 optimizations

On Wednesday 07 May 2003 21:06, Ken Witherow wrote:
> > +config K7_ATHLONMP
> > + bool "Athlon MP"
> > + help
> > + Select this if you have an Athlon XP CPU, to enable optimizations
> > + specific to that processor.
>
> I do believe Athlon XP when you mean MP is a copy/paste typo :)

You are right, thanks for spotting this :)

I'll fix this and re-post it when I have some more feedback.

// Thomas

2003-05-07 20:49:34

by Thomas Horsten

[permalink] [raw]
Subject: Re: [PATCH] 2.5.69 Changes to Kconfig and i386 Makefile to include support for various K7 optimizations

Also the patch got wordwrapped since I had to resend it from my shell account (it got eaten by the linux-kernel filter the first time for some obscure reason)..

So here it is again, also with the typo fixed that Ken pointed out. Comments received with thanks.

diff -r -u linux-2.5.69.orig/arch/i386/Kconfig linux-2.5.69/arch/i386/Kconfig
--- linux-2.5.69.orig/arch/i386/Kconfig 2003-05-05 00:53:02.000000000 +0100
+++ linux-2.5.69/arch/i386/Kconfig 2003-05-07 18:00:11.000000000 +0100
@@ -273,6 +273,48 @@

endchoice

+#
+# Select the exact K7 model for optimization purposes
+#
+choice
+ prompt "K7 Model Selection"
+ depends on MK7
+ default K7_STD
+
+config K7_STD
+ bool "Standard Athlon/Duron/Other"
+ help
+ Select this if you have a standard Athlon or Duron processor, or
+ another varian that is not listed below. Kernels compiled with this
+ option should work on a system that uses any member of the K7 family
+ of processors.
+
+config K7_TBIRD
+ bool "Athlon Thunderbird"
+ help
+ Select this if you have the "Thunderbird" version of the Athlon CPU,
+ to enable optimizations specific to that processor.
+
+config K7_ATHLON4
+ bool "Athlon 4 (Palomino)"
+ help
+ Select this if you have an Athlon 4 CPU, also known as "Palomino",
+ to enable optimizations specific to that processor.
+
+config K7_ATHLONXP
+ bool "Athlon XP"
+ help
+ Select this if you have an Athlon XP CPU, to enable optimizations
+ specific to that processor.
+
+config K7_ATHLONMP
+ bool "Athlon MP"
+ help
+ Select this if you have an Athlon MP CPU, to enable optimizations
+ specific to that processor.
+
+endchoice
+
config X86_GENERIC
bool "Generic x86 support"
help
diff -r -u linux-2.5.69.orig/arch/i386/Makefile linux-2.5.69/arch/i386/Makefile
--- linux-2.5.69.orig/arch/i386/Makefile 2003-05-05 00:53:12.000000000 +0100
+++ linux-2.5.69/arch/i386/Makefile 2003-05-07 18:10:08.000000000 +0100
@@ -39,7 +39,11 @@
cflags-$(CONFIG_MPENTIUMIII) += $(call check_gcc,-march=pentium3,-march=i686)
cflags-$(CONFIG_MPENTIUM4) += $(call check_gcc,-march=pentium4,-march=i686)
cflags-$(CONFIG_MK6) += $(call check_gcc,-march=k6,-march=i586)
-cflags-$(CONFIG_MK7) += $(call check_gcc,-march=athlon,-march=i686 $(align)-functions=4)
+cflags-$(CONFIG_K7_STD) += $(call check_gcc,-march=athlon,-march=i686 $(align)-functions=4)
+cflags-$(CONFIG_K7_TBIRD) += $(call check_gcc,-march=athlon-tbird,$(call check_gcc,-march=athlon,-march=i686 $(align)-functions=4))
+cflags-$(CONFIG_K7_ATHLON4) += $(call check_gcc,-march=athlon-4,$(call check_gcc,-march=athlon,-march=i686 $(align)-functions=4))
+cflags-$(CONFIG_K7_ATHLONXP) += $(call check_gcc,-march=athlon-xp,$(call check_gcc,-march=athlon,-march=i686 $(align)-functions=4))
+cflags-$(CONFIG_K7_ATHLONMP) += $(call check_gcc,-march=athlon-mp,$(call check_gcc,-march=athlon,-march=i686 $(align)-functions=4))
cflags-$(CONFIG_MK8) += $(call check_gcc,-march=k8,$(call check_gcc,-march=athlon,-march=i686 $(align)-functions=4))
cflags-$(CONFIG_MCRUSOE) += -march=i686 $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
cflags-$(CONFIG_MWINCHIPC6) += $(call check_gcc,-march=winchip-c6,-march=i586)

2003-05-14 13:52:12

by Dave Jones

[permalink] [raw]
Subject: Re: [PATCH] 2.5.69 Changes to Kconfig and i386 Makefile to include support for various K7 optimizations

On Wed, May 07, 2003 at 06:34:26PM +0100, Thomas Horsten wrote:

[ick, backlog]

> I made this patch to support the various K7 model-specific
> optimizations that the later GCC compilers can use.
>
> Please have a look, and pass me any comments.

I don't think this is worth the extra complication. The potential wins
(if any) outweigh the confusion to users who might have no clue as to
what core they have. Additionally, some gcc's got these options wrong.
The athlon4 option was completely wrong for a while for eg.

> I also have the same patch for 2.4, if you are interested it's
> available on my Linux page on http://www.infowares.com/linux

For 2.4, it's an even worse idea IMO.

Dave

--
| Dave Jones. http://www.codemonkey.org.uk
| SuSE Labs

2003-05-14 16:36:15

by Ray Lee

[permalink] [raw]
Subject: Re: [PATCH] 2.5.69 Changes to Kconfig and i386 Makefile to include support for various K7 optimizations

Dave Jones wrote:

> On Wed, May 07, 2003 at 06:34:26PM +0100, Thomas Horsten wrote:
>> Please have a look, and pass me any comments.

> I don't think this is worth the extra complication. The potential wins
> (if any) outweigh the confusion to users who might have no clue as to
> what core they have.

How's about a "This CPU" option instead, a la gcccpuopt [1], that sets
the correct CPU options for the current machine/gcc combo?

[1] http://google.com/search?q=gcccpuopt

Ray

2003-05-14 16:53:11

by Dave Jones

[permalink] [raw]
Subject: Re: [PATCH] 2.5.69 Changes to Kconfig and i386 Makefile to include support for various K7 optimizations

On Wed, May 14, 2003 at 09:49:42AM -0700, Ray Lee wrote:

> > I don't think this is worth the extra complication. The potential wins
> > (if any) outweigh the confusion to users who might have no clue as to
> > what core they have.
> How's about a "This CPU" option instead, a la gcccpuopt [1], that sets
> the correct CPU options for the current machine/gcc combo?

arch/i386/Makefile already does this. the original poster wanted to
increase the granularity further, splitting athlon into several types
of athlon.

Dave

2003-05-14 18:27:23

by Thomas Horsten

[permalink] [raw]
Subject: Re: [PATCH] 2.5.69 Changes to Kconfig and i386 Makefile to include support for various K7 optimizations

On Wednesday 14 May 2003 15:04, Dave Jones wrote:

> > I made this patch to support the various K7 model-specific
> > optimizations that the later GCC compilers can use.
> >
> > Please have a look, and pass me any comments.
>
> I don't think this is worth the extra complication. The potential wins
> (if any) outweigh the confusion to users who might have no clue as to
> what core they have. Additionally, some gcc's got these options wrong.
> The athlon4 option was completely wrong for a while for eg.

I think when GCC supports the different cores, it should be supported by the
kernel scripts, the differences between the cores are real enough to have
potential optimizations at least in theory (as far as I could see the only
difference in GCC 3.2 is whether to use SSE, but that could change in the
future).

Maybe it should be renamed "Advanced CPU model selection", or something like
that, instead of "K7 Model Selection", but the help IMHO makes it clear
enough that you should go with the default if you are not sure and that it
will work on any core.

I think it's a fairly simple patch that doesn't break anything, and there are
certainly options lurking around in Kconfig that are much more obscure than
this :)

> > I also have the same patch for 2.4, if you are interested it's
> > available on my Linux page on http://www.infowares.com/linux
>
> For 2.4, it's an even worse idea IMO.

I completely agree that this shouldn't go into the stock 2.4 kernel, that's
also why I didn't post it here. It's just on my site as a convenience for
those who might want to use the XP specific options etc. in an easy way (like
I use it myself).

// Thomas

2003-05-14 18:42:13

by Dave Jones

[permalink] [raw]
Subject: Re: [PATCH] 2.5.69 Changes to Kconfig and i386 Makefile to include support for various K7 optimizations

On Wed, May 14, 2003 at 07:40:10PM +0100, Thomas Horsten wrote:

> I think when GCC supports the different cores, it should be supported by the
> kernel scripts, the differences between the cores are real enough to have
> potential optimizations at least in theory (as far as I could see the only
> difference in GCC 3.2 is whether to use SSE, but that could change in the
> future).

To use SSE in kernel space, we need to wrap it in kernel_fpu_begin() /
kernel_fpu_end() pairs anyway. gcc doesn't (and can't) know this.

> I think it's a fairly simple patch that doesn't break anything

it's non-obvious that it'll break things when people use broken compilers.
read what I wrote before, several gcc versions got this horribly wrong.
"athlon4" was even tuned for 64bit at one point.

Take away the SSE, take away the broken compiler versions, and you'd be
left with something that would hardly show a blip on a benchmark.

Dave