1
votes

In Linux kernel (2.6) is there a difference between the performance of the "schedule()" routine in a system that has only one processor than in a system with multiple processors?

I have tried to find the answer in the book "Understanding the Linux kernel (3rd ed.)" but no luck finding the answer.

1
schedule() costs about 10 µs on decent CPUs, is this really a problem?myaut
There are several factors: scheduler groups and domains, task balancer, so it can even vary for 2 CPU / 4 Core system vs. single-processor 8 Core system, there is no clean answer to your question without running experiments (you may try to do so, but it is hard to rule out other significant factors and provide representative workload).myaut

1 Answers

2
votes

Difficult to answer this.

One simplistic answer is "yes, of course, there is a difference in performance between one cpu and multiple cpus since, when there are multiple CPUs, the kernel must lock various data structures thereby potentially encountering contention, and must decide which CPU a task can next run on, and so forth -- decisions that need not be made (or can be made trivially) when there is only a single CPU."

Another simplistic answer is, "no, the performance impact of the various decisions is minimal and represents a negligible percentage of the total combined CPU 'bandwidth'".

The full answer requires knowledge and consideration of the thousands of factors that go into the scheduling decision on all the available CPUs in any given scenario: Is there an explicit affinity mask set for each process? What interrupts and soft interrupts are being serviced by each CPU? Are the processes being scheduled on each CPU I/O-bound or CPU-bound? Are there processes communicating with other processes where both can run simultaneously on different processors? So many factors, it's impossible to enumerate all the possibilities.