[PATCH 1/5] task_struct: Add field for per-task userspace scheduler hint

From: K Prateek Nayak
Date: Sat Sep 10 2022 - 06:54:27 EST


- Add a field named "hint" to store the per-task userspace scheduler
hint set via the prctl() interface.
- Hints are inherited from parent on fork. Inherited hints can be reset
from the same prctl() interface used to set hint to default or any
other value.
- Hints are best effort case and scheduler doesn't make any guarantees
of strictly adhering to it.

Signed-off-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
---
include/linux/sched.h | 1 +
init/init_task.c | 1 +
2 files changed, 2 insertions(+)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index e7b2f8a5c711..fc953c9e956a 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -769,6 +769,7 @@ struct task_struct {
int wake_cpu;
#endif
int on_rq;
+ unsigned int hint;

int prio;
int static_prio;
diff --git a/init/init_task.c b/init/init_task.c
index ff6c4b9bfe6b..f5208e6a1934 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -79,6 +79,7 @@ struct task_struct init_task
.static_prio = MAX_PRIO - 20,
.normal_prio = MAX_PRIO - 20,
.policy = SCHED_NORMAL,
+ .hint = 0,
.cpus_ptr = &init_task.cpus_mask,
.user_cpus_ptr = NULL,
.cpus_mask = CPU_MASK_ALL,
--
2.25.1