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
92
93
94
95
96
97
98
|
From 2a8f391ef5bb8d5c68b731743dd1f2b9f1fb0d46 Mon Sep 17 00:00:00 2001
From: Morten Rasmussen <morten.rasmussen@arm.com>
Date: Fri, 12 Aug 2016 10:53:13 +0100
Subject: [PATCH 65/92] arm64: Set SD_SHARE_CAP_STATES sched_domain flag when
applicable
Energy-aware scheduling relies on the SD_SHARE_CAP_STATES to identify
sharing the same clock source/frequency domain. The assumption is that a
sched_domain exists that match the clock/frequency domain, i.e.
policy->related_cpus in cpufreq terms. The flag is not set for systems
without frequency scaling or systems with per-cpu frequency scaling.
cc: Catalin Marinas <catalin.marinas@arm.com>
cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Morten Rasmussen <morten.rasmussen@arm.com>
(cherry picked from commit 2c36006aa6a75c35269d26b08f2e86bad68d72bd)
Signed-off-by: Gaku Inami <gaku.inami.xw@bp.renesas.com>
---
arch/arm64/kernel/topology.c | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c
index eb2ad75..a8d986e 100644
--- a/arch/arm64/kernel/topology.c
+++ b/arch/arm64/kernel/topology.c
@@ -29,6 +29,7 @@
static DEFINE_PER_CPU(unsigned long, cpu_scale) = SCHED_CAPACITY_SCALE;
static DEFINE_MUTEX(cpu_scale_mutex);
static bool asym_cpucap;
+static bool sd_mc_share_cap, sd_die_share_cap;
static bool update_flags;
unsigned long scale_cpu_capacity(struct sched_domain *sd, int cpu)
@@ -224,6 +225,14 @@ static void normalize_cpu_capacity(void)
pr_debug("cpu_capacity: calling %s for CPUs [%*pbl] (to_visit=[%*pbl])\n",
__func__, cpumask_pr_args(policy->related_cpus),
cpumask_pr_args(cpus_to_visit));
+
+ cpu = cpumask_first(policy->related_cpus);
+
+ if (cpumask_subset(cpu_coregroup_mask(cpu), policy->related_cpus))
+ sd_mc_share_cap = true;
+ else if (cpumask_subset(cpu_cpu_mask(cpu), policy->related_cpus))
+ sd_die_share_cap = true;
+
cpumask_andnot(cpus_to_visit,
cpus_to_visit,
policy->related_cpus);
@@ -239,7 +248,8 @@ static void normalize_cpu_capacity(void)
if (!cap_parsing_failed) {
asym = asym_cpucap;
normalize_cpu_capacity();
- if (asym != asym_cpucap)
+ if (asym != asym_cpucap ||
+ sd_mc_share_cap || sd_die_share_cap)
update_sched_flags();
kfree(raw_capacity);
pr_debug("cpu_capacity: parsing done\n");
@@ -522,7 +532,25 @@ const struct cpumask *cpu_coregroup_mask(int cpu)
static int cpu_cpu_flags(void)
{
- return asym_cpucap ? SD_ASYM_CPUCAPACITY : 0;
+ int die_flags = 0;
+
+ if (asym_cpucap)
+ die_flags |= SD_ASYM_CPUCAPACITY;
+
+ if (sd_die_share_cap)
+ die_flags |= SD_SHARE_CAP_STATES;
+
+ return die_flags;
+}
+
+static int cpu_coregroup_flags(void)
+{
+ int mc_flags = SD_SHARE_PKG_RESOURCES;
+
+ if (sd_mc_share_cap)
+ mc_flags |= SD_SHARE_CAP_STATES;
+
+ return mc_flags;
}
static void update_siblings_masks(unsigned int cpuid)
@@ -608,7 +636,7 @@ static void __init reset_cpu_topology(void)
static struct sched_domain_topology_level arm64_topology[] = {
#ifdef CONFIG_SCHED_MC
- { cpu_coregroup_mask, cpu_core_flags, SD_INIT_NAME(MC) },
+ { cpu_coregroup_mask, cpu_coregroup_flags, SD_INIT_NAME(MC) },
#endif
{ cpu_cpu_mask, cpu_cpu_flags, SD_INIT_NAME(DIE) },
{ NULL, }
--
1.9.1
|