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