On 14/08/2013 13:15, Bruce Hill wrote:
On Wed, Aug 14, 2013 at 12:18:41PM +0700, Pandu Poluan wrote:
Hello list!

My company has 2 HP DL585 G5 servers and 5 Dell R... something servers. All
using AMD processors. They currently are acting as XenServer hosts.

How do I determine the 'least common denominator' for Gentoo VMs (running
as XenServer guests), especially for gcc flags?

I know that the (theoretical) best performance is to use -march=native ,
but since the processors of the HP servers are not exactly the same as the
Dell's, I'm concerned that compiling with -march=native will render the VMs
unable to migrate between the different hosts.

A couple of points:

* The effect of setting -march=native depends on the characteristics of
  the CPU (be it virtual or otherwise)
* The characteristics of the vCPU are defined by qemu's -cpu parameter
* qemu can emulate features not implemented by the host CPU (at a cost)

One way to go about it is to start qemu with a -cpu model that exposes features that all of your host CPUs have in common (or a subset thereof). In that case, -march=native is fine because all of the features that it detects as being available will be supported in hardware on the host side.

Another way is to expose the host CPU fully with "-cpu host" and to define your guest CFLAGS according to the most optimal subset. If you are looking for a 'perfect' configuration then this this would be the most effective method, if applied correctly.

Irrespective of the method, by examining /proc/cpuinfo and using the diff technique mentioned by Bruce, you should be able to determine the optimal configuration.

Finally, in cases where the host CPUs differ significantly - in that native would imply a different -march value - you may choose to augment your CFLAGS with -mtune=generic to even out performance across the board. I don't think this would apply to you though.


Note: Yes I know the HP servers are much older than the Dell ones, but if I
go -march=native then perform an emerge when the guest is on the Dell host,
the guest VM might not be able to migrate to the older HPs.

To check what options CFLAGS set as -march=native would use:
gcc -march=native -E -v - </dev/null 2>&1 | sed -n 's/.* -v - //p'
(the first thing in the output is what CPU -march=native would enable)

Then you can run:
diff -u <(gcc -Q --help=target) <(gcc -march=native -Q --help=target)
to display target-specific options, versus native ones.
Assuming the 2 HP servers are identical, and the 5 Dell servers are identical,
you then only need to get the commonality of two processors (HP and Dell).
Since they're both AMD, you should have a good set of common features to help
you determine that "least common denominator", or target.


Reply via email to