# K-6, K6-2, K6-3: What is what?

## jakertberry

I think it's about time we figure out how to get those K6/K6-2/K6-3 processors working. I've been trying to build a K6-3 Gentoo box for a long time and have yet to figure out a solution that works.

Here's the problem: There's a nasty "bug" with AMD's old marketing (from bug 24379):

There are 6 different cores (that is based on the 'flags' field in /proc/cpuinfo):

[all also have 'fpu vme de pse tsc msr mce cx8']

mmx

mmx 3dnow syscall k6_mtrr 

mmx 3dnow pge syscall mtrr   

mmx 3dnow pge sep mtrr <-K6-2

mmx 3dnow pge syscall 3dnowext k6_mtrr <-K6-3

There are only 4 unique values for the 'model name' field:

AMD-K6(tm) 3D processor

AMD-K6(tm) 3D+ Processor

AMD-K6(tm)-III Processor

AMD-K6tm w/ multimedia extensions

How do we figure out which one is what? If you've got a K6 processor, post your cpuinfo here, as well as your make.conf if you got it to work. I'll start off with what I have (I'm not posting my make.conf as I can't get it to work--it keeps failing on compiles):

```
cat /proc/cpuinfo

processor       : 0

vendor_id       : AuthenticAMD

cpu family      : 5

model           : 9

model name      : AMD-K6(tm) 3D+ Processor

stepping        : 1

cpu MHz         : 451.031

cache size      : 256 KB

fdiv_bug        : no

hlt_bug         : no

f00f_bug        : no

coma_bug        : no

fpu             : yes

fpu_exception   : yes

cpuid level     : 1

wp              : yes

flags           : fpu vme de pse tsc msr mce cx8 pge mmx syscall 3dnow k6_mtrr

bogomips        : 903.74
```

The processor core is stamped with "AMD K6-3." It can't be a true K6-3 though because there's no 3dnowext. So it's a "3D+" processor, whatever that is.

Which -march or -mtune am I to use? So far it's failed with i586, k6-2, and k6-3...Last edited by jakertberry on Wed Jan 06, 2021 3:41 am; edited 1 time in total

----------

## Sachankara

Unless I remember it incorrectly, K6-3 is a K6-2 with speed throttling for laptops. You should use the i586 stage 3 tbz2 file. I'd recommend something like "-Os -mtune=i586 -pipe" for that CPU. MMX and 3DNow really doesn't add any performance to the applications on those old processors, unless they've been specifically written for a certain subset of CPU features (like mplayer).

----------

## jakertberry

@Sachankara

The -Os seemed to be my problem. I've been doing -O2 for a long time and it always failed. Last I checked it compiled further than gcc (where it usually failed) and failed at perl. I'm doing a emerge --resume to see if it was just another sporadic compile bug.

I'll post my make.conf when I'm at the PC again...

----------

## odessit

 *Sachankara wrote:*   

> Unless I remember it incorrectly, K6-3 is a K6-2 with speed throttling for laptops. 

 

No, the chips that were typically used in laptops were the K6-2+ and K6-3+ same Super Socket 7 as desktop chips made them quite common in the desktops as well.

both of them have good speed improvements over the non-plus versions (better cache, better float/integer performance)

-Os -mtune=i586 -pipe - sounds reasonable

----------

## jakertberry

```
# These settings were set by the catalyst build script that automatically built this stage

# Please consult /etc/make.conf.example for a more detailed example

# Last edited: 8/21/06 by jaker

CHOST="i586-pc-linux-gnu"

#

CFLAGS="-march=k6-2"

#

CFLAGS="${CFLAGS} -Os"

CFLAGS="${CFLAGS} -fomit-frame-pointer"

CFLAGS="${CFLAGS} -pipe"

#

CXXFLAGS="${CFLAGS}"

#

#LDFLAGS="-Wl,-O1 -Wl,--sort-common -s"

#

ACCEPT_KEYWORDS="x86"

PORTAGE_TMPDIR=/var/tmp

PORTDIR=/usr/portage

DISTDIR=${PORTDIR}/distfiles

PKGDIR=${PORTDIR}/packages

PORT_LOGDIR=/var/log/portage

PORTDIR_OVERLAY=/usr/local/portage

MAKEOPTS="-j2"

GENTOO_MIRRORS="http://gentoo.chem.wisc.edu/gentoo http://gentoo.osuosl.org http://www.ibiblio.org/pub/Linux/distributions/gentoo"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

RSYNC_RETRIES="3"

RSYNC_TIMEOUT=180

PORTAGE_NICENESS=3

AUTOCLEAN="yes"

FEATURES="distlocks sandbox userpriv usersandbox"
```

This seems to be working for me with random fails on long compiles (but a emerge --resume fixes it the second time)

----------

## depontius

 *jakertberry wrote:*   

> I think it's about time we figure out how to get those K6/K6-2/K6-3 processors working. I've been trying to build a K6-3 Gentoo box for a long time and have yet to figure out a solution that works.
> 
> Here's the problem: There's a nasty "bug" with AMD's old marketing (from bug 24379):
> 
> There are 6 different cores (that is based on the 'flags' field in /proc/cpuinfo):
> ...

 

I'm running the same CPU core as you, and always thought of it as the "old" k6-3, the 2.4V part, as opposed to the newer 2.2V parts and the k6-2+ or k6-3+. I've run Gentoo happily on it for years, except that it overheats easily. Right now it's my server, running Gentoo Hardened. Here are some relevant lines from /etc/make.conf:

```
USE="-gnome -esd -eds -kde -arts threads nptl nptlonly pic hardened"

CFLAGS="-march=k6-3 -O2 -pipe"

#CFLAGS="-O2 -pipe"

CHOST="i586-pc-linux-gnu"

CXXFLAGS="${CFLAGS}"
```

The commented CFLAGS line is because I couldn't get the recent busybox to emerge, and thought it might have been a problem with k6-3, so figured I'd try it without '-march='. No go, but one of these days I'll dig harder, or there will be a newer ebuild come out.

----------

## cac

It is a Compaq Persario, exact model escapes me at the moment, but has a K6-2 inside:

```
 cat /proc/cpuinfo

processor       : 0

vendor_id       : AuthenticAMD

cpu family      : 5

model           : 8

model name      : AMD-K6(tm) 3D processor

stepping        : 12

cpu MHz         : 500.318

cache size      : 64 KB

fdiv_bug        : no

hlt_bug         : no

f00f_bug        : no

coma_bug        : no

fpu             : yes

fpu_exception   : yes

cpuid level     : 1

wp              : yes

flags           : fpu vme de pse tsc msr mce cx8 pge mmx syscall 3dnow k6_mtrr

bogomips        : 1001.94
```

make.conf has:

```
CHOST="i586-pc-linux-gnu"

CFLAGS="-Os -mtune=k6-2 -pipe"

CXXFLAGS="${CFLAGS}"
```

I had been running solid for nearly two + (maybe 3 +) years; originially installed it during the gentoo 1.4 days.  Now during the move to 2006.1 and gcc 4.1.1 I am having problems getting gcc to compile.  Trying out CFLAGS="-O2 -mtune=k6-2 -pipe".  I use this as my server, and had dabbled with the hardened stuff before, but never truely configured that properly.  Thought this would make a great time to set it up along with the move to 2006.1, but now I fear that I am making too many changes at once. Ehh, I'll figure it out eventually; thats the fun of gentoo   :Cool:  .

----------

## pteppic

My router box is a 

```
processor       : 0

vendor_id       : AuthenticAMD

cpu family      : 5

model           : 8

model name      : AMD-K6(tm) 3D processor

stepping        : 12

cpu MHz         : 400.912

cache size      : 64 KB

fdiv_bug        : no

hlt_bug         : no

f00f_bug        : no

coma_bug        : no

fpu             : yes

fpu_exception   : yes

cpuid level     : 1

wp              : yes

flags           : fpu vme de pse tsc msr mce cx8 pge mmx syscall 3dnow k6_mtrr

bogomips        : 802.81
```

Being the router it never compiles X or the like, but has never had any trouble (except when using distcc).

Relavent make.conf lines

```
CFLAGS="-march=k6-2 -O2 -pipe -fomit-frame-pointer"

CHOST="i586-pc-linux-gnu"

CXXFLAGS="${CFLAGS}"

USE=" ipv6 nptl nptlonly -sdl -mppe-mppc -alsa -arts -avi -gnome -gstreamer -gtk -gtk2 -kde -qt -X -png -jpeg"
```

----------

## depontius

My impression is that mtune=k6-? optimizes for the k6-?, but emits instructions that will still work on i586, whereas march=k6-? may emit k6-? specific instructions that may not work on i586.

I also thought I heard that mtune was generally deprecated in favor of march, but given my definition, that wouldn't seem so.

----------

## cac

 *depontius wrote:*   

> My impression is that mtune=k6-? optimizes for the k6-?, but emits instructions that will still work on i586, whereas march=k6-? may emit k6-? specific instructions that may not work on i586.
> 
> I also thought I heard that mtune was generally deprecated in favor of march, but given my definition, that wouldn't seem so.

 

Actually it is slightly backwards from what you described; march=k6-? will break compatibility with other x86 archs, while mtune=k6-? will keep compatibility with x86 archs.  mcpu was deprecated in favor of mtune, but AFAIK mtune and march are mutually exclusive.  Obviously, if you want to take full advantage of a CPU, then you want to use march, but for odd-ball CPUs, like the K6-* it is generally thought to keep out gremlins.  Maybe this thinking has changed?   :Confused: 

Either case, I have used mcpu/mtune for several years, and never any breakage because of that.  I was finally able to get up to date with 2006.1/gcc4.1.1 after weeks of compiling and re-compiling.  I think my problems lied with the use of hardened USE flag.  I think I read somewhere that that is causing problems with the latest gcc.

----------

## depontius

Not to be nyah-nyah, but I've been using march for a while, too. OTOH, I haven't been able to build busybox, but taking march=k6-3 out doesn't fix that.

----------

