• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI_LINUX_IOPRIO_H
3 #define _UAPI_LINUX_IOPRIO_H
4 
5 /*
6  * Gives us 8 prio classes with 13-bits of data for each class
7  */
8 #define IOPRIO_CLASS_SHIFT	13
9 #define IOPRIO_CLASS_MASK	0x07
10 #define IOPRIO_PRIO_MASK	((1UL << IOPRIO_CLASS_SHIFT) - 1)
11 
12 #define IOPRIO_PRIO_CLASS(ioprio)	\
13 	(((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK)
14 #define IOPRIO_PRIO_DATA(ioprio)	((ioprio) & IOPRIO_PRIO_MASK)
15 #define IOPRIO_PRIO_VALUE(class, data)	\
16 	((((class) & IOPRIO_CLASS_MASK) << IOPRIO_CLASS_SHIFT) | \
17 	 ((data) & IOPRIO_PRIO_MASK))
18 
19 /*
20  * These are the io priority groups as implemented by the BFQ and mq-deadline
21  * schedulers. RT is the realtime class, it always gets premium service. For
22  * ATA disks supporting NCQ IO priority, RT class IOs will be processed using
23  * high priority NCQ commands. BE is the best-effort scheduling class, the
24  * default for any process. IDLE is the idle scheduling class, it is only
25  * served when no one else is using the disk.
26  */
27 enum {
28 	IOPRIO_CLASS_NONE,
29 	IOPRIO_CLASS_RT,
30 	IOPRIO_CLASS_BE,
31 	IOPRIO_CLASS_IDLE,
32 };
33 
34 /*
35  * The RT and BE priority classes both support up to 8 priority levels.
36  */
37 #define IOPRIO_NR_LEVELS	8
38 #define IOPRIO_BE_NR		IOPRIO_NR_LEVELS
39 
40 enum {
41 	IOPRIO_WHO_PROCESS = 1,
42 	IOPRIO_WHO_PGRP,
43 	IOPRIO_WHO_USER,
44 };
45 
46 /*
47  * Fallback BE priority level.
48  */
49 #define IOPRIO_NORM	4
50 #define IOPRIO_BE_NORM	IOPRIO_NORM
51 
52 #endif /* _UAPI_LINUX_IOPRIO_H */
53