0

I have an AMD processor with 4 physical cores and SMT enabled. Because of the latter, I see 8 virtual cores in a Linux box.

For example, stress command can spawn a number of workers spinning on sqrt(). If I run stress with -c 1 option, using mpstat I would see that one virtual core usage is 100%. Thus, from my understanding, one virtual core is loaded fully, which basically means that one physical core is loaded fully. Do I get it right?

Is there any way to certainly load one physical CPU? I want to see how Linux shows it in the metrics.

PS. I want to understand how to monitor the CPU load on a system with virtual cores and, I'm not sure If my approach is right, but I don't have any other ideas so far.

mate200
  • 1
  • 1

1 Answers1

0

Very few single threads can fully load all resources on a CPU. This is why SMT exists, to drive utilization up by oversubscribing logical processors on physical cores. However, SMT threads are weaker than cores.

A conservative thing to do is plan capacity based on cores, not threads. That way, tasks minimize contention over processor resources.

Watch your application's performance metrics, the user experience focused ones like user response time or job throughput. When those start to degrade, look at performance counters like load average or CPU busy. As well as all the other subsystems, like memory, storage and file system, network, and so on. Look for bottlenecks and symptoms. Brendan Gregg's Linux performance page is a good reference for a comprehensive approach to analyzing performance.

Linux is SMP (and NUMA) aware, the scheduler will avoid expensive core and socket transitions where possible. And load each core up with one task first. Verify a system has more than 1 "Thread(s) per core" with lscpu. Start a couple of CPU heavy jobs. Per CPU monitoring tools like mpstat -P ALL 5 will show a pattern of some CPUs are loaded, and some not.

John Mahowald
  • 32,050
  • 2
  • 19
  • 34