1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux 1 2 #ifndef _UAPI_LINUX_IOPRIO_H 3 #define _UAPI_LINUX_IOPRIO_H 4 5 #include <linux/stddef.h> 6 #include <linux/types.h> 7 8 /* 9 * Gives us 8 prio classes with 13-bits of dat 10 */ 11 #define IOPRIO_CLASS_SHIFT 13 12 #define IOPRIO_NR_CLASSES 8 13 #define IOPRIO_CLASS_MASK (IOPRIO_NR_CLA 14 #define IOPRIO_PRIO_MASK ((1UL << IOPRI 15 16 #define IOPRIO_PRIO_CLASS(ioprio) \ 17 (((ioprio) >> IOPRIO_CLASS_SHIFT) & IO 18 #define IOPRIO_PRIO_DATA(ioprio) ((iopr 19 20 /* 21 * These are the io priority classes as implem 22 * schedulers. RT is the realtime class, it al 23 * ATA disks supporting NCQ IO priority, RT cl 24 * high priority NCQ commands. BE is the best- 25 * default for any process. IDLE is the idle s 26 * served when no one else is using the disk. 27 */ 28 enum { 29 IOPRIO_CLASS_NONE = 0, 30 IOPRIO_CLASS_RT = 1, 31 IOPRIO_CLASS_BE = 2, 32 IOPRIO_CLASS_IDLE = 3, 33 34 /* Special class to indicate an invali 35 IOPRIO_CLASS_INVALID = 7, 36 }; 37 38 /* 39 * The RT and BE priority classes both support 40 * can be specified using the lower 3-bits of 41 */ 42 #define IOPRIO_LEVEL_NR_BITS 3 43 #define IOPRIO_NR_LEVELS (1 << 44 #define IOPRIO_LEVEL_MASK (IOPRI 45 #define IOPRIO_PRIO_LEVEL(ioprio) ((iopr 46 47 #define IOPRIO_BE_NR IOPRIO 48 49 /* 50 * Possible values for the "which" argument of 51 * ioprio_set() system calls (see "man ioprio_ 52 */ 53 enum { 54 IOPRIO_WHO_PROCESS = 1, 55 IOPRIO_WHO_PGRP, 56 IOPRIO_WHO_USER, 57 }; 58 59 /* 60 * Fallback BE class priority level. 61 */ 62 #define IOPRIO_NORM 4 63 #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 127 #endif /* _UAPI_LINUX_IOPRIO_H */ 128
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.