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