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
最新推荐文章于 2024-04-12 23:09:42 发布
本文介绍了Linux 2.6内核如何通过处理器亲和性功能确保特定进程运行在指定处理器上,从而提高实时性能及缓存命中率。文中提到Linux调度器会检查每个进程的数据结构来确定其运行位置,并可通过特定函数读取或修改这些设置。此外,还介绍了一些公司如何利用类似技术优化其产品。
2751

被折叠的 条评论
为什么被折叠?



