# Which cpu option is for Intel Core2 and how to optimize the FreeBSD's kernel?



## fender0107401 (Feb 22, 2009)

I found the following information in the freebsd handbook chapter 8:


> > cpu          I486_CPU
> > cpu          I586_CPU
> > cpu          I686_CPU
> 
> ...



http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html

And I also found this in /sys/amd64/conf/NOTES:


> #####################################################################
> # CPU OPTIONS
> 
> #
> ...



I want know which cpu option is for Intel Core2?

I think I can specify the "cpu option" in my kernel_conf_file to tune my kernel for specific hardware and gain more performance.

But I am not sure about this.

If my understanding is wrong, how to optimize FreeBSD's kernel for specific cpu?

I asked similar question two weeks ago, but still confused.


----------



## dclau (Feb 22, 2009)

The answer is right there, in your quote 


> ...you can check the /var/run/dmesg.boot file to view your boot messages.


The output of this can help:
	
	



```
dmesg | grep -i cpu
```
Compare it with /usr/src/share/mk/bsd.cpu.mk. Somewhere on this forum was a similar discussion, months ago. Perhaps a deeper search will reveal something more useful than my post.

*edit: http://forums.freebsd.org/showthread.php?t=816
Seems like your option should be _prescott_


----------



## fronclynne (Feb 22, 2009)

AFIK, in amd64, the only valid CPU is HAMMER.


----------



## fender0107401 (Feb 23, 2009)

dclau said:
			
		

> The answer is right there, in your quote
> The output of this can help:
> 
> 
> ...



I have seen the page that you give me, and this is my system information(I am planning buy a new core2 or phenom processor):


> uname -a
> FreeBSD PC-486.Workstation 7.0-RELEASE-p8 FreeBSD 7.0-RELEASE-p8 #0: Fri Jan  9 17:37:21 CST 2009     root@PC-486.Workstation:/usr/obj/usr/src/sys/MYKERNEL  amd64
> dmesg | grep -i cpu
> CPU: Intel(R) Pentium(R) D CPU 2.80GHz (2802.82-MHz K8-class CPU)
> ...


I tried prescott and PRESCOTT, but it doesn't work. 


			
				fronclynne said:
			
		

> AFIK, in amd64, the only valid CPU is HAMMER.


Why? Is there no difference between amd64 and em64t?


----------



## fronclynne (Feb 23, 2009)

*I hop eth ish elps.*



			
				fender0107401 said:
			
		

> I tried prescott and PRESCOTT, but it doesn't work.
> 
> Why? Is there no difference between amd64 and em64t?



Not in your KERNCONF, I gather.

Just like the i386 only takes I[456]86_CPU.

You can further tune it in /etc/make.conf, but beware that things may break in horrible ways if you get too excited.


----------



## Brandybuck (Feb 23, 2009)

Set "I686_CPU" in your kernel configuration file for 32-bit, or "HAMMER" for 64-bit. In your make.conf you want to use "core2", which will do the right thing for both 32- and 64-bit.

p.s. Note that Intel Core 2 in 64-bit mode is considered an amd64 architecture, and not ia64 arch.


----------



## phoenix (Mar 4, 2009)

For 32-bit installs of FreeBSD, you will want to keep I586_CPU as well as I686_CPU.

I586_CPU enables a bunch of memory optimisations that aren't enabled with I686_CPU, even though all Intel and AMD CPUs since the PentiumPro and AthlonXP include those instructions.

There are several threads in 2008 and 2007 on the FreeBSD mailing lists regarding this "issue", and the general consensus was to have both in your 32-bit kernel config file to get the best performance.


----------



## richardpl (Mar 6, 2009)

phoenix_rizzen said:
			
		

> For 32-bit installs of FreeBSD, you will want to keep I586_CPU as well as I686_CPU.
> 
> I586_CPU enables a bunch of memory optimisations that aren't enabled with I686_CPU, even though all Intel and AMD CPUs since the PentiumPro and AthlonXP include those instructions.
> 
> There are several threads in 2008 and 2007 on the FreeBSD mailing lists regarding this "issue", and the general consensus was to have both in your 32-bit kernel config file to get the best performance.



Somebody asked similar question regarding keeping I586_CPU and I*4*86_CPU on one of mailing list (at and of 2008 I think) and answer was that modern CPUs do not benefit with such options in kernel.

Benchmarking custom and generic kernel I found that there is no performance drop.


----------



## oliverh (Mar 7, 2009)

This is my experience too, I even don't see much gain in optimizing for different cputypes apart from some theoretic benchmark noise.


----------



## Mel_Flynn (Mar 7, 2009)

Most workloads are not primarily CPU, hence performance increases are slim. For a VPN router with loads of connections I'd think about it (though it's probably smarter to get an accellerator). For desktop use, web- or database serving, this will not make a measurable difference.


----------



## roddierod (Mar 9, 2009)

phoenix_rizzen said:
			
		

> For 32-bit installs of FreeBSD, you will want to keep I586_CPU as well as I686_CPU.
> 
> I586_CPU enables a bunch of memory optimisations that aren't enabled with I686_CPU, even though all Intel and AMD CPUs since the PentiumPro and AthlonXP include those instructions.
> 
> There are several threads in 2008 and 2007 on the FreeBSD mailing lists regarding this "issue", and the general consensus was to have both in your 32-bit kernel config file to get the best performance.



Out of curiosity, I tried this the other day. I have a dual Opteron machine and I had the cpu option as i686. I changed that to i586 to see if they memory optimsations would work.

When I rebooted the machine I got a kernel panic. And there was a message that the cpu type was unknown. What was even worse was that when I tried to boot kernel.old it gave me and invalid format error.

I had to use a FreeBSD live cd to boot the system and then copy the generic kernel and loader to my system. This was on a 7.1 system.


----------



## DutchDaemon (Mar 9, 2009)

Did you _change_ i686 to i586, or did you _add_ i586 to i686?


----------



## roddierod (Mar 9, 2009)

i changed from i686 to i586.


----------



## DutchDaemon (Mar 9, 2009)

Not the best of ideas, Roddie  You should have added it. They're somewhat complementary (as the story goes), not mutually exclusive.


----------



## roddierod (Mar 9, 2009)

Oh :r

Maybe I try again...


----------



## BuSerD (Sep 20, 2009)

*Read Carefully my friends*

Anyone notice an overlap?


```
%dmesg | grep CPU | head -1
CPU: Intel(R) Core(TM)2 Duo CPU     E8500  @ 3.16GHz (3166.32-MHz [b]K8-class[/b] CPU)
%grep -i hammer /sys/amd64/conf/NOTES
cpu             HAMMER                  # aka [b]K8[/b], aka Opteron & Athlon64
```

It seems to me that HAMMER is the answer but I don't see any reason to add/remove i586 and/or i686. I don't use either and I don't have any problems but I also have used both and noticed no difference. Take note that the handbook does state "for a custom kernel it is best to specify only the CPU you have" so you will be fine with either or any combination of these.


----------



## SirDice (Sep 20, 2009)

IIRC HAMMER is used only on amd64 versions, not i386.


----------



## fronclynne (Sep 21, 2009)

*I am quite late to this game*



			
				BuSerD said:
			
		

> Anyone notice an overlap?
> 
> 
> ```
> ...


If you try to use [red]i586[/red] or [red]i686[/red] in an AMD64 kernconf, I wager it'll noisily fail to build.

_edit:_ et voila

```
make buildkernel

--------------------------------------------------------------
>>> Kernel build for EARTH80 started on Mon Sep 21 13:37:37 EDT 2009
--------------------------------------------------------------
===> EARTH80
mkdir -p /usr/obj/home/8/src/sys

--------------------------------------------------------------
>>> stage 1: configuring the kernel
--------------------------------------------------------------
cd /home/8/src/sys/amd64/conf;  PATH=/usr/obj/home/8/src/tmp/legacy/usr/sbin:/usr/obj/home/8/src/tmp/legacy/usr/bin:/usr/obj/home/8/src/tmp/legacy/usr/games:/usr/obj/home/8/src/tmp/usr/sbin:/usr/obj/home/8/src/tmp/usr/bin:/usr/obj/home/8/src/tmp/usr/games:/sbin:/bin:/usr/sbin:/usr/bin  config  -d /usr/obj/home/8/src/sys/EARTH80  /home/8/src/sys/amd64/conf/EARTH80
/home/8/src/sys/amd64/conf/EARTH80: unknown option "i686"
*** Error code 1

Stop in /home/8/src.
*** Error code 1

Stop in /home/8/src.
```


----------

