1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 #ifndef _UAPI_LINUX_SCHED_TYPES_H 3 #define _UAPI_LINUX_SCHED_TYPES_H 4 5 #include <linux/types.h> 6 7 struct sched_param { 8 int sched_priority; 9 }; 10 11 #define SCHED_ATTR_SIZE_VER0 48 /* sizeof first published struct */ 12 #define SCHED_ATTR_SIZE_VER1 56 /* add: util_{min,max} */ 13 14 /* 15 * Extended scheduling parameters data structure. 16 * 17 * This is needed because the original struct sched_param can not be 18 * altered without introducing ABI issues with legacy applications 19 * (e.g., in sched_getparam()). 20 * 21 * However, the possibility of specifying more than just a priority for 22 * the tasks may be useful for a wide variety of application fields, e.g., 23 * multimedia, streaming, automation and control, and many others. 24 * 25 * This variant (sched_attr) allows to define additional attributes to 26 * improve the scheduler knowledge about task requirements. 27 * 28 * Scheduling Class Attributes 29 * =========================== 30 * 31 * A subset of sched_attr attributes specifies the 32 * scheduling policy and relative POSIX attributes: 33 * 34 * @size size of the structure, for fwd/bwd compat. 35 * 36 * @sched_policy task's scheduling policy 37 * @sched_nice task's nice value (SCHED_NORMAL/BATCH) 38 * @sched_priority task's static priority (SCHED_FIFO/RR) 39 * 40 * Certain more advanced scheduling features can be controlled by a 41 * predefined set of flags via the attribute: 42 * 43 * @sched_flags for customizing the scheduler behaviour 44 * 45 * Sporadic Time-Constrained Task Attributes 46 * ========================================= 47 * 48 * A subset of sched_attr attributes allows to describe a so-called 49 * sporadic time-constrained task. 50 * 51 * In such a model a task is specified by: 52 * - the activation period or minimum instance inter-arrival time; 53 * - the maximum (or average, depending on the actual scheduling 54 * discipline) computation time of all instances, a.k.a. runtime; 55 * - the deadline (relative to the actual activation time) of each 56 * instance. 57 * Very briefly, a periodic (sporadic) task asks for the execution of 58 * some specific computation --which is typically called an instance-- 59 * (at most) every period. Moreover, each instance typically lasts no more 60 * than the runtime and must be completed by time instant t equal to 61 * the instance activation time + the deadline. 62 * 63 * This is reflected by the following fields of the sched_attr structure: 64 * 65 * @sched_deadline representative of the task's deadline 66 * @sched_runtime representative of the task's runtime 67 * @sched_period representative of the task's period 68 * 69 * Given this task model, there are a multiplicity of scheduling algorithms 70 * and policies, that can be used to ensure all the tasks will make their 71 * timing constraints. 72 * 73 * As of now, the SCHED_DEADLINE policy (sched_dl scheduling class) is the 74 * only user of this new interface. More information about the algorithm 75 * available in the scheduling class file or in Documentation/. 76 * 77 * Task Utilization Attributes 78 * =========================== 79 * 80 * A subset of sched_attr attributes allows to specify the utilization 81 * expected for a task. These attributes allow to inform the scheduler about 82 * the utilization boundaries within which it should schedule the task. These 83 * boundaries are valuable hints to support scheduler decisions on both task 84 * placement and frequency selection. 85 * 86 * @sched_util_min represents the minimum utilization 87 * @sched_util_max represents the maximum utilization 88 * 89 * Utilization is a value in the range [0..SCHED_CAPACITY_SCALE]. It 90 * represents the percentage of CPU time used by a task when running at the 91 * maximum frequency on the highest capacity CPU of the system. For example, a 92 * 20% utilization task is a task running for 2ms every 10ms at maximum 93 * frequency. 94 * 95 * A task with a min utilization value bigger than 0 is more likely scheduled 96 * on a CPU with a capacity big enough to fit the specified value. 97 * A task with a max utilization value smaller than 1024 is more likely 98 * scheduled on a CPU with no more capacity than the specified value. 99 */ 100 struct sched_attr { 101 __u32 size; 102 103 __u32 sched_policy; 104 __u64 sched_flags; 105 106 /* SCHED_NORMAL, SCHED_BATCH */ 107 __s32 sched_nice; 108 109 /* SCHED_FIFO, SCHED_RR */ 110 __u32 sched_priority; 111 112 /* SCHED_DEADLINE */ 113 __u64 sched_runtime; 114 __u64 sched_deadline; 115 __u64 sched_period; 116 117 /* Utilization hints */ 118 __u32 sched_util_min; 119 __u32 sched_util_max; 120 121 }; 122 123 #endif /* _UAPI_LINUX_SCHED_TYPES_H */ 124