Introduction:
I’m renting a 8 CPU machine at Hetzner and I wanted to improve the performance.
At the beginning I was distributing many CPUs to the virtual machines which needed it and less cpus to others.
This included that some cpus would be shared by more than one Xen virtual machine.
I noticed that the performance was quite sluggish.
After having read about it in Internet I opted to assign 1 or maximum 2 CPUs per machine including DOM0
and no CPUs would be shared by the machines that need performance.
At the end this really improved the performance significantly because Xen has less CPU switching to do.

So here is the plan:
DOM0 : CPU 0 & 1
DOMU1 : CPU 2 & 3
DOMU2 : CPU 4 & 5
DOMUx : Shared CPUs 6 & 7 (some machines might get one CPU and others 2 CPUs

The principle is also that we assign vCPUs to Physical CPUs.
I have seen in Internet some ways to assign CPUs to DOM0 but somehow the following method doesn’t seem to work.
in /boot/grub/menu.lst
dom0_max_vcpus=2 dom0_vcpus_pin

Distributing CPUs for DOM0 and DOMUs

Manually assign a vCPU to a physical CPU
Syntax:
xm vcpu-pin ID VCPU CPU
eg.
xm vcpu-pin 14 0 7
Assigns vCPU 0 to physical CPU 7 for the DOMU-ID 14

So here is my method for the DOM0.
Note: Unfortunately this has to be done every time I boot, therefore putting the following content in a system init script which starts after the ‘xend’ daemon has started could be helpful.
DOM0
xm vcpu-pin 0 0 0
xm vcpu-pin 0 1 0
xm vcpu-pin 0 2 0
xm vcpu-pin 0 3 0
xm vcpu-pin 0 4 1
xm vcpu-pin 0 5 1
xm vcpu-pin 0 6 1
xm vcpu-pin 0 7 1

This assigns only the first 2 physical CPUs to 8 vCPUs used by DOM0

Command for listing the cpu distribution:
xm vcpu-list
DOMUs
Assigning CPUs to DOMUs can be done by hand as seen above, but I recommend doing it in their respective Xen configuration files as follows:

Edit the DOMu configuration file: eg. /etc/xen/domu_test.cfg
Add this content
vcpus = 2
cpus = ["4","5"]

This would assign 2 CPUs to the DOMu which will be CPU 2 and 3.

After these configuration changes the DOMU has to be shut down and then restarted.
A ‘Reboot’ command from DOM0 or inside the DOMU will not work.