ioprio_set(2) System Calls Manual ioprio_set(2) ioprio_get, ioprio_set - / - LIBRARY Standard C library (libc, -lc) #include /* IOPRIO_* */ #include /* SYS_* */ #include int syscall(SYS_ioprio_get, int which, int who); int syscall(SYS_ioprio_set, int which, int who, int ioprio); Note: glibc provides no wrappers for these system calls, necessitating the use of syscall(2). ioprio_get() ioprio_set() - . which who (), . which who; : IOPRIO_WHO_PROCESS who , . who 0, . IOPRIO_WHO_PGRP who , . who 0, , . IOPRIO_WHO_USER who , , . ioprio_get() which IOPRIO_WHO_PGRP IOPRIO_WHO_USER, who , . , , (IOPRIO_CLASS_RT ; IOPRIO_CLASS_IDLE -- ), , ( , ). ioprio, ioprio_set(), , , (). ioprio : IOPRIO_PRIO_VALUE(class, data) class (data) ioprio, . IOPRIO_PRIO_CLASS(mask) mask ( ioprio) -, : IOPRIO_CLASS_RT, IOPRIO_CLASS_BE IOPRIO_CLASS_IDLE. IOPRIO_PRIO_DATA(mask) mask ( ioprio) (data). , 0 ioprio . - (O_DIRECT, O_SYNC) . - , , . ioprio_get() ioprio - , , which who. -1, errno . ioprio_set() 0. -1, errno . EINVAL which ioprio. , ioprio. EPERM , ioprio (). ioprio_set() . ESRCH , which who . Linux. Linux 2.6.13. -. , clone(2) CLONE_IO. -. , - , ioprio_set() . , , gettid(2) clone(2). , -, -. 2.6.17 : Completely Fair Queuing (CFQ). If no I/O scheduler has been set for a thread, then by default the I/O priority will follow the CPU nice value (setpriority(2)). Before Linux 2.6.24, once an I/O priority had been set using ioprio_set(), there was no way to reset the I/O scheduling behavior to the default. Since Linux 2.6.24, specifying ioprio as 0 can be used to reset to the default I/O scheduling behavior. - I/O schedulers are selected on a per-device basis via the special file /sys/block/device/queue/scheduler. - /sys. , , : $ cat /sys/block/sda/queue/scheduler noop anticipatory deadline [cfq] , ( sda), . . , cfq sda: $ su Password: # echo cfq > /sys/block/sda/queue/scheduler - (CFQ) 3 (. . CFQ Time Sliced) CFQ -, . , : IOPRIO_CLASS_RT (1) - . : . : - . 8 (), . 0; -- 7. . IOPRIO_CLASS_BE (2) (best-effort) , , -. () - . nice (. getpriority(2)). . 0 ( ) 7 ( ). IOPRIO_CLASS_IDLE (3) (idle) . , , - . . , , . - CFQ Documentation/block/ioprio.txt. - : - , . CAP_SYS_NICE . Attempts to set very high priorities (IOPRIO_CLASS_RT) require the CAP_SYS_ADMIN capability. Up to Linux 2.6.24 also required CAP_SYS_ADMIN to set a very low priority (IOPRIO_CLASS_IDLE), but since Linux 2.6.25, this is no longer required. ioprio_set() , EPERM. glibc does not yet provide a suitable header file defining the function prototypes and macros described on this page. Suitable definitions can be found in linux/ioprio.h. . ionice(1), getpriority(2), open(2), capabilities(7), cgroups(7) Documentation/block/ioprio.txt Linux Azamat Hackimov , Dmitriy S. Seregin , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . ioprio_set(2)