[RFC PATCH 18/23] sched/task_struct: Add helpers for task classification

From: Ricardo Neri
Date: Fri Sep 09 2022 - 19:08:07 EST


The unprocessed classification that hardware provides for a task may not
be usable by the scheduler. The classification may change too frequently.
An arch-specific implementation may want to consider other factors. For
instance, Intel Thread Director considers the state of the SMT siblings
of core.

Provide per-task helper variables that architectures can use to post-
process the classification that hardware provides.

Cc: Ben Segall <bsegall@xxxxxxxxxx>
Cc: Daniel Bristot de Oliveira <bristot@xxxxxxxxxx>
Cc: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
Cc: Len Brown <len.brown@xxxxxxxxx>
Cc: Mel Gorman <mgorman@xxxxxxx>
Cc: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
Cc: Srinivas Pandruvada <srinivas.pandruvada@xxxxxxxxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Tim C. Chen <tim.c.chen@xxxxxxxxx>
Cc: Valentin Schneider <vschneid@xxxxxxxxxx>
Cc: x86@xxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@xxxxxxxxxxxxxxx>
---
signed char and unsigned char are both signed in riscv architecture.
Use a signed char to avoid compilation warnings.
---
include/linux/sched.h | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 73f9e745d17d..6c8907622f00 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1517,6 +1517,16 @@ struct task_struct {
#ifdef CONFIG_SCHED_TASK_CLASSES
/* Class of task that the scheduler uses for task placement decisions */
short class;
+ /*
+ * A candidate classification that arch-specific implementations
+ * qualify for correctness.
+ */
+ short class_candidate;
+ /*
+ * Counter to filter out transient the candidate classification
+ * of a task
+ */
+ char class_debounce_counter;
#endif

/*
--
2.25.1