xref: /linux/include/uapi/linux/ioprio.h (revision ba05200fcce0a73fa8db16c514fbaa476d1d9399)
106447ae5SOliver Hartkopp /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
206447ae5SOliver Hartkopp #ifndef _UAPI_LINUX_IOPRIO_H
306447ae5SOliver Hartkopp #define _UAPI_LINUX_IOPRIO_H
406447ae5SOliver Hartkopp 
506447ae5SOliver Hartkopp /*
606447ae5SOliver Hartkopp  * Gives us 8 prio classes with 13-bits of data for each class
706447ae5SOliver Hartkopp  */
8*ba05200fSDamien Le Moal #define IOPRIO_CLASS_SHIFT	13
9*ba05200fSDamien Le Moal #define IOPRIO_CLASS_MASK	0x07
1006447ae5SOliver Hartkopp #define IOPRIO_PRIO_MASK	((1UL << IOPRIO_CLASS_SHIFT) - 1)
1106447ae5SOliver Hartkopp 
12*ba05200fSDamien Le Moal #define IOPRIO_PRIO_CLASS(ioprio)	\
13*ba05200fSDamien Le Moal 	(((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK)
14*ba05200fSDamien Le Moal #define IOPRIO_PRIO_DATA(ioprio)	((ioprio) & IOPRIO_PRIO_MASK)
15*ba05200fSDamien Le Moal #define IOPRIO_PRIO_VALUE(class, data)	\
16*ba05200fSDamien Le Moal 	((((class) & IOPRIO_CLASS_MASK) << IOPRIO_CLASS_SHIFT) | \
17*ba05200fSDamien Le Moal 	 ((data) & IOPRIO_PRIO_MASK))
1806447ae5SOliver Hartkopp 
1906447ae5SOliver Hartkopp /*
2025bca50eSDamien Le Moal  * These are the io priority groups as implemented by the BFQ and mq-deadline
2125bca50eSDamien Le Moal  * schedulers. RT is the realtime class, it always gets premium service. For
2225bca50eSDamien Le Moal  * ATA disks supporting NCQ IO priority, RT class IOs will be processed using
2325bca50eSDamien Le Moal  * high priority NCQ commands. BE is the best-effort scheduling class, the
2425bca50eSDamien Le Moal  * default for any process. IDLE is the idle scheduling class, it is only
2525bca50eSDamien Le Moal  * served when no one else is using the disk.
2606447ae5SOliver Hartkopp  */
2706447ae5SOliver Hartkopp enum {
2806447ae5SOliver Hartkopp 	IOPRIO_CLASS_NONE,
2906447ae5SOliver Hartkopp 	IOPRIO_CLASS_RT,
3006447ae5SOliver Hartkopp 	IOPRIO_CLASS_BE,
3106447ae5SOliver Hartkopp 	IOPRIO_CLASS_IDLE,
3206447ae5SOliver Hartkopp };
3306447ae5SOliver Hartkopp 
3406447ae5SOliver Hartkopp /*
3506447ae5SOliver Hartkopp  * 8 best effort priority levels are supported
3606447ae5SOliver Hartkopp  */
3706447ae5SOliver Hartkopp #define IOPRIO_BE_NR	(8)
3806447ae5SOliver Hartkopp 
3906447ae5SOliver Hartkopp enum {
4006447ae5SOliver Hartkopp 	IOPRIO_WHO_PROCESS = 1,
4106447ae5SOliver Hartkopp 	IOPRIO_WHO_PGRP,
4206447ae5SOliver Hartkopp 	IOPRIO_WHO_USER,
4306447ae5SOliver Hartkopp };
4406447ae5SOliver Hartkopp 
4506447ae5SOliver Hartkopp /*
4606447ae5SOliver Hartkopp  * Fallback BE priority
4706447ae5SOliver Hartkopp  */
4806447ae5SOliver Hartkopp #define IOPRIO_NORM	(4)
4906447ae5SOliver Hartkopp 
5006447ae5SOliver Hartkopp #endif /* _UAPI_LINUX_IOPRIO_H */
51