-
Notifications
You must be signed in to change notification settings - Fork 59
/
0128-itmt_epb-use-epb-to-scale-itmt.patch
92 lines (81 loc) · 2.98 KB
/
0128-itmt_epb-use-epb-to-scale-itmt.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Tue, 16 Nov 2021 17:39:25 +0000
Subject: [PATCH] itmt_epb: use epb to scale itmt
---
arch/x86/include/asm/topology.h | 1 +
arch/x86/kernel/cpu/intel_epb.c | 4 ++++
arch/x86/kernel/itmt.c | 29 ++++++++++++++++++++++++++++-
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
index 2f0b6be8eaab..c31f81e2ea05 100644
--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -174,6 +174,7 @@ extern unsigned int __read_mostly sysctl_sched_itmt_enabled;
/* Interface to set priority of a cpu */
void sched_set_itmt_core_prio(int prio, int core_cpu);
+void sched_set_itmt_power_ratio(int power_ratio, int core_cpu);
/* Interface to notify scheduler that system supports ITMT */
int sched_set_itmt_support(void);
diff --git a/arch/x86/kernel/cpu/intel_epb.c b/arch/x86/kernel/cpu/intel_epb.c
index fbaf12e43f41..c8c2d6f1a8ac 100644
--- a/arch/x86/kernel/cpu/intel_epb.c
+++ b/arch/x86/kernel/cpu/intel_epb.c
@@ -166,6 +166,10 @@ static ssize_t energy_perf_bias_store(struct device *dev,
if (ret < 0)
return ret;
+ /* update the ITMT scheduler logic to use the power policy data */
+ /* scale the val up by 2 so the range is 224 - 256 */
+ sched_set_itmt_power_ratio(256 - val * 2, cpu);
+
return count;
}
diff --git a/arch/x86/kernel/itmt.c b/arch/x86/kernel/itmt.c
index 57027bfed25f..596fd7fb7847 100644
--- a/arch/x86/kernel/itmt.c
+++ b/arch/x86/kernel/itmt.c
@@ -25,6 +25,7 @@
static DEFINE_MUTEX(itmt_update_mutex);
DEFINE_PER_CPU_READ_MOSTLY(int, sched_core_priority);
+DEFINE_PER_CPU_READ_MOSTLY(int, sched_power_ratio);
/* Boolean to track if system has ITMT capabilities */
static bool __read_mostly sched_itmt_capable;
@@ -169,7 +170,12 @@ void sched_clear_itmt_support(void)
int arch_asym_cpu_priority(int cpu)
{
- return per_cpu(sched_core_priority, cpu);
+ int power_ratio = per_cpu(sched_power_ratio, cpu);
+
+ /* a power ratio of 0 (uninitialized) is assumed to be maximum */
+ if (power_ratio == 0)
+ power_ratio = 256 - 2 * 6;
+ return per_cpu(sched_core_priority, cpu) * power_ratio / 256;
}
extern int best_core;
@@ -217,3 +223,24 @@ void sched_set_itmt_core_prio(int prio, int core_cpu)
}
}
}
+
+/**
+ * sched_set_itmt_power_ratio() - Set CPU priority based on ITMT
+ * @power_ratio: The power scaling ratio [1..256] for the core
+ * @core_cpu: The cpu number associated with the core
+ *
+ * Set a scaling to the cpu performance based on long term power
+ * settings (like EPB).
+ *
+ * Note this is for the policy not for the actual dynamic frequency;
+ * the frequency will increase itself as workloads run on a core.
+ */
+
+void sched_set_itmt_power_ratio(int power_ratio, int core_cpu)
+{
+ int cpu;
+
+ for_each_cpu(cpu, topology_sibling_cpumask(core_cpu)) {
+ per_cpu(sched_power_ratio, cpu) = power_ratio;
+ }
+}
--
https://clearlinux.org