How To Change The IO Scheduling Class And Priority In Linux

Article by:
Date Published:
Last Modified:

Overview

This tutorial makes use of the Linux command-line program ionice.

Scheduling classes:

  1. none:
  2. real time: The hgihest-importantance schduling class. There are eight priorites (0-7), with lower numbers meaning higher priorites. This scheduling class cannot be assigned by a non-root user.
  3. best effort: This class will be assigned to any process which didn’t explicitly assign a class.
  4. idle: The process will only get disk time when no other non-idle process has requested disk access for a defined grace period. idle IO usage should no have impact on normal system activity.

To Get The IO Scheduling Class And Priority Of An Existing Process

Use the following command:

1
ionice -p <PID>

where <PID> is the process ID of the process you want to get the IO scheduling class and priority for. The command will return the IO scheduling class <class> and priority <prio> in the form:

1
<class>: prio <priority>

For example:

1
2
$ ionice -p 0
none: prio 4

Thus the process with PID=0 has a scheduling class of none and a priority of 4.

To Set The IO Scheduling Class And Priority Of An Existing Process

To change the IO scheduling class and priority for an already running process:

1
ionice -c <class> -n <class-priority> -p <PID>

To start a process and set the IO scheduling class and priority at the same time:

1
ionice -c <class> -n <class-priority> <COMMAND>

where <COMMAND> is standard command-line command + arguments. For example, to start a process running fstrim / with the lowest IO schdeduling class and lowest priority:

1
ionice -c 3 -n 7 fstrim /

Authors

Geoffrey Hunter

Dude making stuff.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License .

Related Content:

Tags

comments powered by Disqus