IBM's DeveloperWorks has published an article describing how the Linux 2.6 kernel supports "processor affinity" -- that is, ensuring that a particular process runs on a particular processor or set of processors within a multi-processor machine. Processor affinity can improve real-time performance, as well as cache hit-rates in complex calculations.
In determining where to run a process, the Linux 2.6 scheduler takes a look at the cpus_allowed
bitmask within each process's task_struct
data structure. This bitmask can be read or manipulated using the sched_get_affinity()
or sched_set_affinity()
functions, respectively.
Most often, processor affinity manipulations are done to improve real-time performance in multiprocessor systems, by essentially assigning long-running, time-critical processes to their own dedicated processor.
For example, systems integrator Concurrent uses technology resembling processor affinity -- which it calls CPU Shielding -- in its RedHawk Linux implementation. Real-time Linux vendor FSMLabs offers an add-on to its real-time Linux product called CPU Reservations that also resembles processor affinity. And, fabless networking chip house Cavium Networks says some of its customers use processor affinity to ensure adequate data-plane performance when running both data- and control layer applications on the same multi-core chips.
Besides its utility in real-time applications, processor affinity may yield performance improvements in cases where complex calculations require large numbers of inter-related processes, since distributing these across multiple CPUs could result in undesirable cache clobbering.
The DeveloperWorks article includes a simple sample application demonstrating processor affinity. The article can be found here.
Linux "processor affinity" explained
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.