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

Ricardo Neri
2022-09-09T23:08:07Z

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@google.com>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim C. Chen <tim.c.chen@intel.com>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
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