[torquedev] cpuset support

Chris Samuel csamuel at vpac.org
Thu Jan 10 00:44:21 MST 2008


Just came across this BSD licensed portable library
for manipulating Linux CPU affinity for processes.

http://www.open-mpi.org/projects/plpa/

Portable Linux Processor Affinity (PLPA)

> PLPA is an attempt to solve the problem that there
> are multiple API's for processor affinity within
> Linux. Specifically, the functions sched_setaffinity()
> and sched_getaffinity() have numbers and types of
> parameters depending on your Linux vendor and/or
> version of GLibc. This is quite problematic for
> applications attempting to use processor affinity
> in Linux for compile-time, link-time, and run-time reasons.

It uses the sched_setaffinity() function to bind processes
to CPUs and acquires topology information via sysfs (which
means it needs newer kernels).

I still suspect that we may do a lot better with cpusets
than sched_setaffinity(), but this could be a useful
starting point that could be extended to both fall back
to parsing /proc/cpuinfo if the kernel isn't new enough
and also to use cpusets in preference to sched_setaffinity(),
but falling back to that if the cpusets VFS isn't mounted.

Everyone wins then - they get better support for older
kernels and we don't have to write as much code.. :-)

Anyway, it builds a library and comes with some example
command line programs, one of which will dump out the
topology that it learns from the system: plpa-info --topo

Here is an example of it on a couple of CentOS 5 systems:


Dual core Opteron (single socket occupied):

Kernel affinity support: yes
Kernel topology support: yes
Number of processor sockets: 1
Socket 0: 2 cores


Dual core Opteron (both sockets occupied):

Kernel affinity support: yes
Kernel topology support: yes
Number of processor sockets: 2
Socket 0: 2 cores
Socket 1: 2 cores


Quad core Opteron (two sockets occupied):

Kernel affinity support: yes
Kernel topology support: yes
Number of processor sockets: 2
Socket 0: 4 cores
Socket 1: 4 cores


Here it is on Ubuntu 7.10 with a single P4 processor:

Kernel affinity support: yes
Kernel topology support: yes
Number of processor sockets: 1
Socket 0: 1 core


Here is it *not* working on a SLES9 box on a Power5
system with dual core chips:

Kernel affinity support: yes
Kernel topology support: no
Number of processor sockets: unknown
Kernel topology not supported -- cannot show topology information



cheers,
Chris
-- 
Christopher Samuel - (03) 9925 4751 - Systems Manager
 The Victorian Partnership for Advanced Computing
 P.O. Box 201, Carlton South, VIC 3053, Australia
VPAC is a not-for-profit Registered Research Agency


More information about the torquedev mailing list