[RFC 1/3] Introduce latency-tolerance as an per-task attribute

From: Parth Shah
Date: Mon Nov 25 2019 - 04:46:36 EST


Latency-tolerance indicates the latency requirements of a task with respect
to the other tasks in the system. The value of the attribute can be within
the range of [-20, 19] both inclusive to be in-line with the values just
like task nice values.

latency_tolerance = -20 indicates the task to have the least latency as
compared to the tasks having latency_tolerance = +19.

The latency_tolerance may affect only the CFS SCHED_CLASS by getting
latency requirements from the userspace.

Signed-off-by: Parth Shah <parth@xxxxxxxxxxxxx>
---
include/linux/sched.h | 3 +++
include/linux/sched/latency_tolerance.h | 13 +++++++++++++
2 files changed, 16 insertions(+)
create mode 100644 include/linux/sched/latency_tolerance.h

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 2c2e56bd8913..bcc1c1d0856d 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -25,6 +25,7 @@
#include <linux/resource.h>
#include <linux/latencytop.h>
#include <linux/sched/prio.h>
+#include <linux/sched/latency_tolerance.h>
#include <linux/sched/types.h>
#include <linux/signal_types.h>
#include <linux/mm_types_task.h>
@@ -666,6 +667,8 @@ struct task_struct {
#endif
int on_rq;

+ int latency_tolerance;
+
int prio;
int static_prio;
int normal_prio;
diff --git a/include/linux/sched/latency_tolerance.h b/include/linux/sched/latency_tolerance.h
new file mode 100644
index 000000000000..7a00abe05bc4
--- /dev/null
+++ b/include/linux/sched/latency_tolerance.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_SCHED_LATENCY_TOLERANCE_H
+#define _LINUX_SCHED_LATENCY_TOLERANCE_H
+
+#define MAX_LATENCY_TOLERANCE 19
+#define MIN_LATENCY_TOLERANCE -20
+
+#define LATENCY_TOLERANCE_WIDTH \
+ (MAX_LATENCY_TOLERANCE - MIN_LATENCY_TOLERANCE + 1)
+
+#define DEFAULT_LATENCY_TOLERANCE 0
+
+#endif /* _LINUX_SCHED_LATENCY_TOLERANCE_H */
--
2.17.2