for example, add the following script in /sbin/cpuset
_release_agent:
#!/bin/sh
logger cpuset: releasing $1
rmdir /dev/cpuset/$1
After adding the script to your system, run chmod 755
/sbin/cpuset_release_agent to make the script
executable.
Determine the Cpuset of a Specific Process
All processes with the process id PID have an entry in
/proc/PID/cpuset. If you run the command cat
/proc/PID/cpuset on a PID that runs in the cpuset
exampleset, you will find the results in /exampleset.
Specifying a CPU Affinity with
taskset
The default behavior of the kernel, is to keep a process
running on the same CPU, if the system load is balanced
over the available CPUs. Otherwise, the kernel tries to im-
prove the load balancing by moving processes to an idling
CPU. In some situations, however, it is desirable to set a
CPU affinity for a given process. In this case, the kernel will
not move the process away from the selected CPUs. For
example, if you use shielding, the shielded CPUs will not
run any process that does not have an affinity to the
shielded CPUs. Another possibility is to run all low priority
tasks on a selected CPU to remove load from the other
CPUs.
Note, that if a task is running inside a specific cpuset, the
affinity mask must match at least one of the CPUs available
in this set. The taskset command will not move a process
outside the cpuset it is running in.
To set or retrieve the CPU affinity of a task, a bitmask is
used, that is represented by a hexadecimal number. If you
count the bits of this bitmask, the lowest bit represents the
first logical CPU as they are found in /proc/cpuinfo. For
example:
0x00000001
is processor #0.
0x00000002
is processor #1.
0x00000003
is processor #0 and processor #1.
0xFFFFFFFE
all but the first CPU.
If a given mask does not contain any valid CPU on the sys-
tem, an error is returned. If taskset returns without an error,
the given program has been scheduled to the specified list
of CPUs.
The command taskset can either be used to start a new
process with a given CPU affinity, or to redefine the CPU
affinity of a already running process.
Examples
taskset -p pid
Retrieves the current CPU affinity of the process with
PID pid.
taskset -p mask pid
Sets the CPU affinity of the process with PID pid to
mask.
taskset mask command
Runs command with a CPU affinity of mask.
Changing I/O Priorities with ionice
Handling I/O is one of the critical issues for all high-perfor-
mance systems. If a task has lots of CPU power available,
but must wait for the disk, it will not work as efficient as it
could. The Linux kernel provides three different scheduling
classes to determine the I/O handling for a process. All of
these classes can be fine-tuned with a nice level.
The Best Effort Scheduler
The Best Effort scheduler is the default I/O scheduler,
and is used for all processes that do not specify a differ-
ent I/O scheduler class. By default, this scheduler sets its
niceness according to the nice value of the running
process.
There are eight different nice levels available for this
scheduler. The lowest priority is represented by a nice
level of seven, the highest priority is zero.
This scheduler has the scheduling class number 2.
The Real Time Scheduler
The real-time I/O class always gets the highest priority
for disk access. The other schedulers will only be served,
if no real-time request is present. This scheduling class
may easily lock up the system if not implemented with
care.
The real-time scheduler defines nice levels just like the
Best Effort scheduler.
This scheduler has the scheduling class number 1.
The Idle Scheduler
The Idle scheduler does not define any nice levels. I/O
is only done in this class, if no other scheduler runs an
I/O request. This scheduler has the lowest available pri-
ority and can be used for processes that are not time-
critical at all.
This scheduler has the scheduling class number 3.
To change I/O schedulers and nice values, use the ionice
command. This provides a means to tune the scheduler of
3
Need help?
Do you have a question about the LINUX ENTERPRISE REAL TIME 10 SP1 and is the answer not in the manual?
Questions and answers