1

I was trying to benchmark application performance across bare metal and hypervisors. I have a 24-core server on which hyper-v is running. On the same machine, I have centos7 installed. I can set the number of cores a VM can get from hyper-v console, but how can I do the same for bare-metal case as well?

I'm aware of using nr_cpus or max_cpus parameters in grub or even hot unplugging the core via /sys/devices/system/cpu/cpu/online source but I'm facing a small problem there. Hyper-V doesn't allow hard-affinity for processors, and when I try to switch off certain cores in bare-metal manually, the performance in VM is better. I need a method in which the number of cores can be fixed but the id of those are allowed to change.

helloworld
  • 21
  • 1
  • 1
    See if you can limit the number of cores in the system BIOS. I've had to do this in the past on some HPE DL 380 Gen 8 (or 9) servers to satisfy some database (TimesTen) licensing limitations - our architecture team only purchased licensing for 12 cores on a 20/24 core bare metal servers. – Brandon Xavier Jul 21 '22 at 10:54
  • Tried masking the CPUs from BIOS and it worked as expected. Thanks – helloworld Jul 22 '22 at 05:42
  • Please make your comment into an answer, so it can be accepted and voted on. – John Mahowald Jul 22 '22 at 22:58

1 Answers1

1

On the bare metal CentOS 7 machine, you can use the nr_cpus kernel boot parameter. From the docs:

nr_cpus=        [SMP] Maximum number of processors that an SMP kernel
                could support.

Alternatively, you can use cgroups or the cpulimit tool for limiting the CPU time available to specific user-space programs.

shodanshok
  • 44,038
  • 6
  • 98
  • 162