1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 #ifndef _UAPI_LINUX_IOPRIO_H 2 #ifndef _UAPI_LINUX_IOPRIO_H 3 #define _UAPI_LINUX_IOPRIO_H 3 #define _UAPI_LINUX_IOPRIO_H 4 4 5 #include <linux/stddef.h> << 6 #include <linux/types.h> << 7 << 8 /* 5 /* 9 * Gives us 8 prio classes with 13-bits of dat 6 * Gives us 8 prio classes with 13-bits of data for each class 10 */ 7 */ 11 #define IOPRIO_CLASS_SHIFT 13 8 #define IOPRIO_CLASS_SHIFT 13 12 #define IOPRIO_NR_CLASSES 8 !! 9 #define IOPRIO_CLASS_MASK 0x07 13 #define IOPRIO_CLASS_MASK (IOPRIO_NR_CLA << 14 #define IOPRIO_PRIO_MASK ((1UL << IOPRI 10 #define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1) 15 11 16 #define IOPRIO_PRIO_CLASS(ioprio) \ 12 #define IOPRIO_PRIO_CLASS(ioprio) \ 17 (((ioprio) >> IOPRIO_CLASS_SHIFT) & IO 13 (((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK) 18 #define IOPRIO_PRIO_DATA(ioprio) ((iopr 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)) 19 18 20 /* 19 /* 21 * These are the io priority classes as implem !! 20 * These are the io priority groups as implemented by the BFQ and mq-deadline 22 * schedulers. RT is the realtime class, it al 21 * schedulers. RT is the realtime class, it always gets premium service. For 23 * ATA disks supporting NCQ IO priority, RT cl 22 * ATA disks supporting NCQ IO priority, RT class IOs will be processed using 24 * high priority NCQ commands. BE is the best- 23 * high priority NCQ commands. BE is the best-effort scheduling class, the 25 * default for any process. IDLE is the idle s 24 * default for any process. IDLE is the idle scheduling class, it is only 26 * served when no one else is using the disk. 25 * served when no one else is using the disk. 27 */ 26 */ 28 enum { 27 enum { 29 IOPRIO_CLASS_NONE = 0, !! 28 IOPRIO_CLASS_NONE, 30 IOPRIO_CLASS_RT = 1, !! 29 IOPRIO_CLASS_RT, 31 IOPRIO_CLASS_BE = 2, !! 30 IOPRIO_CLASS_BE, 32 IOPRIO_CLASS_IDLE = 3, !! 31 IOPRIO_CLASS_IDLE, 33 << 34 /* Special class to indicate an invali << 35 IOPRIO_CLASS_INVALID = 7, << 36 }; 32 }; 37 33 38 /* 34 /* 39 * The RT and BE priority classes both support !! 35 * The RT and BE priority classes both support up to 8 priority levels. 40 * can be specified using the lower 3-bits of << 41 */ 36 */ 42 #define IOPRIO_LEVEL_NR_BITS 3 !! 37 #define IOPRIO_NR_LEVELS 8 43 #define IOPRIO_NR_LEVELS (1 << !! 38 #define IOPRIO_BE_NR IOPRIO_NR_LEVELS 44 #define IOPRIO_LEVEL_MASK (IOPRI << 45 #define IOPRIO_PRIO_LEVEL(ioprio) ((iopr << 46 << 47 #define IOPRIO_BE_NR IOPRIO << 48 39 49 /* << 50 * Possible values for the "which" argument of << 51 * ioprio_set() system calls (see "man ioprio_ << 52 */ << 53 enum { 40 enum { 54 IOPRIO_WHO_PROCESS = 1, 41 IOPRIO_WHO_PROCESS = 1, 55 IOPRIO_WHO_PGRP, 42 IOPRIO_WHO_PGRP, 56 IOPRIO_WHO_USER, 43 IOPRIO_WHO_USER, 57 }; 44 }; 58 45 59 /* 46 /* 60 * Fallback BE class priority level. !! 47 * Fallback BE priority level. 61 */ 48 */ 62 #define IOPRIO_NORM 4 49 #define IOPRIO_NORM 4 63 #define IOPRIO_BE_NORM IOPRIO_NORM 50 #define IOPRIO_BE_NORM IOPRIO_NORM 64 << 65 /* << 66 * The 10 bits between the priority class and << 67 * optionally define I/O hints for any combina << 68 * level. Depending on the kernel configuratio << 69 * the target I/O device being used, hints can << 70 * without affecting the I/O scheduling orderi << 71 * class and level. << 72 */ << 73 #define IOPRIO_HINT_SHIFT IOPRIO << 74 #define IOPRIO_HINT_NR_BITS 10 << 75 #define IOPRIO_NR_HINTS (1 << << 76 #define IOPRIO_HINT_MASK (IOPRI << 77 #define IOPRIO_PRIO_HINT(ioprio) \ << 78 (((ioprio) >> IOPRIO_HINT_SHIFT) & IOP << 79 << 80 /* << 81 * I/O hints. << 82 */ << 83 enum { << 84 /* No hint */ << 85 IOPRIO_HINT_NONE = 0, << 86 << 87 /* << 88 * Device command duration limits: ind << 89 * duration limit for the commands tha << 90 * These will currently only be effect << 91 * support the command duration limits << 92 * enabled, then the commands issued t << 93 * one of these hints set will have th << 94 * set to the value of the hint. << 95 */ << 96 IOPRIO_HINT_DEV_DURATION_LIMIT_1 = 1, << 97 IOPRIO_HINT_DEV_DURATION_LIMIT_2 = 2, << 98 IOPRIO_HINT_DEV_DURATION_LIMIT_3 = 3, << 99 IOPRIO_HINT_DEV_DURATION_LIMIT_4 = 4, << 100 IOPRIO_HINT_DEV_DURATION_LIMIT_5 = 5, << 101 IOPRIO_HINT_DEV_DURATION_LIMIT_6 = 6, << 102 IOPRIO_HINT_DEV_DURATION_LIMIT_7 = 7, << 103 }; << 104 << 105 #define IOPRIO_BAD_VALUE(val, max) ((val) < 0 << 106 << 107 /* << 108 * Return an I/O priority value based on a cla << 109 */ << 110 static __always_inline __u16 ioprio_value(int << 111 int << 112 { << 113 if (IOPRIO_BAD_VALUE(prioclass, IOPRIO << 114 IOPRIO_BAD_VALUE(priolevel, IOPRIO << 115 IOPRIO_BAD_VALUE(priohint, IOPRIO_ << 116 return IOPRIO_CLASS_INVALID << << 117 << 118 return (prioclass << IOPRIO_CLASS_SHIF << 119 (priohint << IOPRIO_HINT_SHIFT << 120 } << 121 << 122 #define IOPRIO_PRIO_VALUE(prioclass, priolevel << 123 ioprio_value(prioclass, priolevel, IOP << 124 #define IOPRIO_PRIO_VALUE_HINT(prioclass, prio << 125 ioprio_value(prioclass, priolevel, pri << 126 51 127 #endif /* _UAPI_LINUX_IOPRIO_H */ 52 #endif /* _UAPI_LINUX_IOPRIO_H */ 128 53
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.