Este contenido no está disponible en el idioma seleccionado.
Chapter 13. Setting the disk scheduler
The disk scheduler is responsible for ordering the I/O requests submitted to a storage device.
You can configure the scheduler in several different ways:
- Set the scheduler using TuneD, as described in Setting the disk scheduler using TuneD
-
Set the scheduler using
udev, as described in Setting the disk scheduler using udev rules - Temporarily change the scheduler on a running system, as described in Temporarily setting a scheduler for a specific disk
In Red Hat Enterprise Linux 9, block devices support only multi-queue scheduling. This enables the block layer performance to scale well with fast solid-state drives (SSDs) and multi-core systems.
The traditional, single-queue schedulers, which were available in Red Hat Enterprise Linux 7 and earlier versions, have been removed.
13.1. Available disk schedulers Copiar enlaceEnlace copiado en el portapapeles!
The following multi-queue disk schedulers are supported in Red Hat Enterprise Linux 9:
none- Implements a first-in first-out (FIFO) scheduling algorithm. It merges requests at the generic block layer through a simple last-hit cache.
mq-deadlineAttempts to provide a guaranteed latency for requests from the point at which requests reach the scheduler.
The
mq-deadlinescheduler sorts queued I/O requests into a read or write batch and then schedules them for execution in increasing logical block addressing (LBA) order. By default, read batches take precedence over write batches, because applications are more likely to block on read I/O operations. Aftermq-deadlineprocesses a batch, it checks how long write operations have been starved of processor time and schedules the next read or write batch as appropriate.This scheduler is suitable for most use cases, but particularly those in which the write operations are mostly asynchronous.
bfqTargets desktop systems and interactive tasks.
The
bfqscheduler ensures that a single application is never using all of the bandwidth. In effect, the storage device is always as responsive as if it was idle. In its default configuration,bfqfocuses on delivering the lowest latency rather than achieving the maximum throughput.bfqis based oncfqcode. It does not grant the disk to each process for a fixed time slice but assigns a budget measured in the number of sectors to the process.This scheduler is suitable while copying large files and the system does not become unresponsive in this case.
kyberThe scheduler tunes itself to achieve a latency goal by calculating the latencies of every I/O request submitted to the block I/O layer. You can configure the target latencies for read, in the case of cache-misses, and synchronous write requests.
This scheduler is suitable for fast devices, for example NVMe, SSD, or other low latency devices.
13.2. Different disk schedulers for different use cases Copiar enlaceEnlace copiado en el portapapeles!
Depending on the task that your system performs, the following disk schedulers are recommended as a baseline prior to any analysis and tuning tasks:
| Use case | Disk scheduler |
|---|---|
| Traditional HDD with a SCSI interface |
Use |
| High-performance SSD or a CPU-bound system with fast storage |
Use |
| Desktop or interactive tasks |
Use |
| Virtual guest |
Use |
13.3. The default disk scheduler Copiar enlaceEnlace copiado en el portapapeles!
Block devices use the default disk scheduler unless you specify another scheduler.
For non-volatile Memory Express (NVMe) block devices specifically, the default scheduler is none and Red Hat recommends not changing this.
The kernel selects a default disk scheduler based on the type of device. The automatically selected scheduler is typically the optimal setting. If you require a different scheduler, Red Hat recommends to use udev rules or the TuneD application to configure it. Match the selected devices and switch the scheduler only for those devices.
13.4. Determining the active disk scheduler Copiar enlaceEnlace copiado en el portapapeles!
This procedure determines which disk scheduler is currently active on a given block device.
Procedure
Read the content of the
/sys/block/device/queue/schedulerfile:cat /sys/block/device/queue/scheduler [mq-deadline] kyber bfq none
# cat /sys/block/device/queue/scheduler [mq-deadline] kyber bfq noneCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the file name, replace device with the block device name, for example
sdc.The active scheduler is listed in square brackets (
[ ]).
13.5. Setting the disk scheduler using TuneD Copiar enlaceEnlace copiado en el portapapeles!
This procedure creates and enables a TuneD profile that sets a given disk scheduler for selected block devices. The setting persists across system reboots.
In the following commands and configuration, replace:
-
device with the name of the block device, for example
sdf -
selected-scheduler with the disk scheduler that you want to set for the device, for example
bfq
Prerequisites
-
The
TuneDservice is installed and enabled. For details, see Installing and enabling TuneD.
Procedure
Optional: Select an existing TuneD profile on which your profile will be based. For a list of available profiles, see TuneD profiles distributed with RHEL.
To see which profile is currently active, use:
tuned-adm active
$ tuned-adm activeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new directory to hold your TuneD profile:
mkdir /etc/tuned/my-profile
# mkdir /etc/tuned/my-profileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Find the system unique identifier of the selected block device:
udevadm info --query=property --name=/dev/device | grep -E '(WWN|SERIAL)'
$ udevadm info --query=property --name=/dev/device | grep -E '(WWN|SERIAL)' ID_WWN=0x5002538d00000000_ ID_SERIAL=Generic-_SD_MMC_20120501030900000-0:0 ID_SERIAL_SHORT=20120501030900000Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe command in the this example will return all values identified as a World Wide Name (WWN) or serial number associated with the specified block device. Although it is preferred to use a WWN, the WWN is not always available for a given device and any values returned by the example command are acceptable to use as the device system unique ID.
Create the
/etc/tuned/my-profile/tuned.confconfiguration file. In the file, set the following options:Optional: Include an existing profile:
[main] include=existing-profile
[main] include=existing-profileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the selected disk scheduler for the device that matches the WWN identifier:
[disk] devices_udev_regex=IDNAME=device system unique id elevator=selected-scheduler
[disk] devices_udev_regex=IDNAME=device system unique id elevator=selected-schedulerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Here:
-
Replace IDNAME with the name of the identifier being used (for example,
ID_WWN). Replace device system unique id with the value of the chosen identifier (for example,
0x5002538d00000000).To match multiple devices in the
devices_udev_regexoption, enclose the identifiers in parentheses and separate them with vertical bars:devices_udev_regex=(ID_WWN=0x5002538d00000000)|(ID_WWN=0x1234567800000000)
devices_udev_regex=(ID_WWN=0x5002538d00000000)|(ID_WWN=0x1234567800000000)Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Replace IDNAME with the name of the identifier being used (for example,
Enable your profile:
tuned-adm profile my-profile
# tuned-adm profile my-profileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the TuneD profile is active and applied:
tuned-adm active
$ tuned-adm active Current active profile: my-profileCopy to Clipboard Copied! Toggle word wrap Toggle overflow tuned-adm verify
$ tuned-adm verify Verification succeeded, current system settings match the preset profile. See TuneD log file ('/var/log/tuned/tuned.log') for details.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Read the contents of the
/sys/block/device/queue/schedulerfile:cat /sys/block/device/queue/scheduler [mq-deadline] kyber bfq none
# cat /sys/block/device/queue/scheduler [mq-deadline] kyber bfq noneCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the file name, replace device with the block device name, for example
sdc.The active scheduler is listed in square brackets (
[]).
13.6. Setting the disk scheduler using udev rules Copiar enlaceEnlace copiado en el portapapeles!
This procedure sets a given disk scheduler for specific block devices using udev rules. The setting persists across system reboots.
In the following commands and configuration, replace:
-
device with the name of the block device, for example
sdf -
selected-scheduler with the disk scheduler that you want to set for the device, for example
bfq
Procedure
Find the system unique identifier of the block device:
udevadm info --name=/dev/device | grep -E '(WWN|SERIAL)'
$ udevadm info --name=/dev/device | grep -E '(WWN|SERIAL)' E: ID_WWN=0x5002538d00000000 E: ID_SERIAL=Generic-_SD_MMC_20120501030900000-0:0 E: ID_SERIAL_SHORT=20120501030900000Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe command in the this example will return all values identified as a World Wide Name (WWN) or serial number associated with the specified block device. Although it is preferred to use a WWN, the WWN is not always available for a given device and any values returned by the example command are acceptable to use as the device system unique ID.
Configure the
udevrule. Create the/etc/udev/rules.d/99-scheduler.rulesfile with the following content:ACTION=="add|change", SUBSYSTEM=="block", ENV{IDNAME}=="device system unique id", ATTR{queue/scheduler}="selected-scheduler"ACTION=="add|change", SUBSYSTEM=="block", ENV{IDNAME}=="device system unique id", ATTR{queue/scheduler}="selected-scheduler"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Here:
-
Replace IDNAME with the name of the identifier being used (for example,
ID_WWN). -
Replace device system unique id with the value of the chosen identifier (for example,
0x5002538d00000000).
-
Replace IDNAME with the name of the identifier being used (for example,
Reload
udevrules:udevadm control --reload-rules
# udevadm control --reload-rulesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the scheduler configuration:
udevadm trigger --type=devices --action=change
# udevadm trigger --type=devices --action=changeCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify the active scheduler:
cat /sys/block/device/queue/scheduler
# cat /sys/block/device/queue/schedulerCopy to Clipboard Copied! Toggle word wrap Toggle overflow
13.7. Temporarily setting a scheduler for a specific disk Copiar enlaceEnlace copiado en el portapapeles!
This procedure sets a given disk scheduler for specific block devices. The setting does not persist across system reboots.
Procedure
Write the name of the selected scheduler to the
/sys/block/device/queue/schedulerfile:echo selected-scheduler > /sys/block/device/queue/scheduler
# echo selected-scheduler > /sys/block/device/queue/schedulerCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the file name, replace device with the block device name, for example
sdc.
Verification
Verify that the scheduler is active on the device:
cat /sys/block/device/queue/scheduler
# cat /sys/block/device/queue/schedulerCopy to Clipboard Copied! Toggle word wrap Toggle overflow