already running processes, or to start new processes with
specific I/O settings.
Examples
ionice -c3 -p$$
Sets the scheduler of the current shell to Idle.
ionice
Without additional parameters, this prints the I/O
scheduler settings of the current shell.
ionice -c1 -p42 -n2
Sets the scheduler of the process with process id 42 to
Real Time, and its nice value to 2.
ionice -c3 /bin/bash
Starts the Bash shell with the Idle I/O scheduler.
Changing the I/O Scheduler for Block
Devices
The Linux kernel provides several block device schedulers
that can be selected individually for each block device. All
but the noop scheduler perform a kind of ordering of re-
quested blocks to reduce head movements on the hard
disk. If you use an external storage system that has its own
scheduler, you may want to disable the Linux internal re-
ordering by selecting the noop scheduler.
The Linux I/O Schedulers
noop
The noop scheduler is a very simple scheduler, that per-
forms basic merging and sorting on I/O requests. This
scheduler is mainly used for specialized environments
that run their own schedulers optimized for the used
hardware, such as storage systems or hardware RAID
controllers.
anticipatory
The main principle of anticipatory scheduling is, that af-
ter a read, the scheduler simply expects further reads
from userspace. For this reason, after a read completes,
the anticipatory scheduler will do nothing at all for a few
milliseconds, giving userspace the possibility to ask for
another read. If such a read is requested, it will be per-
formed immediately. Otherwise the scheduler continues
with doing writes after a short time-out.
The advantage of this procedure is a major reduction of
seeks and thus a decreased read latency. This also increas-
es read and write bandwidth.
deadline
The main point of deadline scheduling is to try hard to
answer a request before a given deadline. This results in
very good I/O for a random single I/O in real-time envi-
ronments.
In principle, the deadline uses two lists with all requests.
One is sorted by block sequences to reduce seeking la-
tencies, the other is sorted by expire times for each re-
quest. Normally, requests are served according to the
block sequence, but if a request reaches its deadline, the
scheduler starts to work on this request.
cfq
The Completely Fair Queuing scheduler uses a separate
I/O queue for each process. All of these queues get a
similar time slice for disk access. With this procedure,
the CFQ tries to divide the bandwidth evenly between
all requesting processes. This scheduler has a similar
throughput as the anticipatory scheduler, but the maxi-
mum latency is much shorter.
For the average system, this scheduler yields the best
results, and thus is the default I/O scheduler on SUSE
Linux Enterprise systems.
To print the current scheduler of a block device like /dev/
sda, use the following command:
cat /sys/block/sda/queue/scheduler
noop anticipatory deadline [cfq]
In this case, the scheduler for /dev/sda is set to cfq, the
Completely Fair Queuing scheduler. This is the de-
fault scheduler on SUSE Linux Enterprise Real Time.
To change the schedulers, echo one of the names noop,
anticipatory, deadline, or cfq into /sys/block/
<device>/scheduler. For example, if you want to set
the I/O scheduler of the device /dev/sda to noop, use
the command echo "noop" >
/sys/block/sda/scheduler. To set other variables in
the /sys file system, use a similar approach.
Tuning the Block Device I/O Scheduler
All schedulers, except for the noop scheduler, have several
common parameters that may be tuned for each block de-
vice. You can access these parameters with sysfs in the
/sys/block/<device>/queue/iosched/ directory.
The following parameters are tuneable for the respective
scheduler:
Anticipatory Scheduler
antic_expire
Time in milliseconds that the anticipatory scheduler
waits for another read request close to the last read
request performed. The anticipatory scheduler will
not wait for upcoming read requests, if this value is
set to zero.
read_expire
Deadline of a read request in milliseconds. This
scheduler also controls the interval between expired
requests. By default, read_expire is set to 125 millisec-
onds. Until a read request is served which is next on
the list, it can thus take up to 250 milliseconds.
4
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