2

I have three processes running on Intel Core 2 Duo CPU. From watching output of 'top' and graphs of CPU load (drawn by MRTG, data collection via SNMP) I can see that CPU load is never more than 50%, and, most of the day, when those processes are busy CPU load has a ceiling at 50 %. I mean, CPU load grows up to 50% in the morning and stays there until late evening.

My first thought was that only one core was used at 100% thus giving 50% of both CPUs. But, as there are three processes running and from 'top' I see that both cores are being loaded, so this is not the case. schedtool shows that CPU affinity for those three processes is at default, 0x03, allowing them to use both cores. If I force one process to one core (schedtool -a 0x01), and two others to second (schedtool -a 0x02), cumulative usage grows beyond 50%.

Why three processes seem to consume only 50% of two cores? Why forcing them to different CPUs allows usage to grow higher? Any hints?

P.S. Processes in question are Counter-Strike servers.

thor
  • 648
  • 1
  • 7
  • 18
  • Does the number of players fluctuate or is it always the same ? – Antoine Benkemoun Jan 03 '11 at 13:18
  • What linux version? From what you say it looks likea bug in the scheduler - obviously, because as you say when you force the different proceses to use diferent cores, load grows higher. – TomTom Jan 03 '11 at 13:27
  • Yes, number of players does fluctuate. There are almost no players at night and CPU load drops to 0%. As the number of players grow in the morning, CPU load goes up to 50% and stays there. – thor Jan 04 '11 at 05:47
  • Linux version is Debian 5.0.7 (Lenny). – thor Jan 04 '11 at 05:47
  • 1
    `cat /proc/cpuinfo` do your CPUs run full speed at 50% usage? – Nils Aug 21 '11 at 20:41

1 Answers1

1

With CPU affinity, the OS may avoid some context switches and result in higher CPU usage. I doubt the gain would be significant unless you have some high network or disk IO.

Also top summarizes data over multiple cores and I've seen odd rounding/math errors. In top, try viewing each core (hit 1 while in top). This will give you a better idea of how each CPU is used.

From the man

The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment, if 'Irix mode' is Off, top will operate in 'Solaris mode' where a task's cpu usage will be divided by the total number of CPUs. You toggle 'Irix/Solaris' modes with the 'I' interactive command.

May want to check into using sysstat for more details CPU metrics. The command mpstat will help you here:

mpstat -P ALL 
01:06:12 PM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
01:06:12 PM  all    0.06    0.00    0.02    1.84    0.00    0.00    0.03   98.05     96.39
01:06:12 PM    0    0.06    0.00    0.02    1.84    0.00    0.00    0.02   98.05     50.98
01:06:12 PM    1    0.58    0.00    0.67    1.81    0.00    0.00    4.10   92.85     50.98
01:06:12 PM    2    0.35    0.00    0.73    1.85    0.00    0.00    4.10   92.98     50.98
01:06:12 PM    3    0.12    0.00    0.38    1.06    0.00    0.00    4.09   94.35     50.98

will spit out all cores.

jeffatrackaid
  • 4,112
  • 18
  • 22