From: Daeyeong Lee Date: Tue, 13 Feb 2018 06:50:41 +0000 (+0900) Subject: [COMMON] base: arch_topology: Add sched_domain flag detection for cluster X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=12c91487032cc450bf728cb4c1698fe8b66eced0;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] base: arch_topology: Add sched_domain flag detection for cluster Change-Id: Iade8db08000fd74c10030475fe2377babb5a59eb Signed-off-by: Daeyeong Lee --- diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index cf92aa817dac..4a4c4c9dd3e8 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -143,9 +143,9 @@ static int register_cpu_capacity_sysctl(void) } subsys_initcall(register_cpu_capacity_sysctl); -enum asym_cpucap_type { no_asym, asym_thread, asym_core, asym_die }; +enum asym_cpucap_type { no_asym, asym_thread, asym_core, asym_cluster, asym_die }; static enum asym_cpucap_type asym_cpucap = no_asym; -enum share_cap_type { no_share_cap, share_cap_thread, share_cap_core, share_cap_die}; +enum share_cap_type { no_share_cap, share_cap_thread, share_cap_core, share_cap_cluster, share_cap_die}; static enum share_cap_type share_cap = no_share_cap; #ifdef CONFIG_CPU_FREQ @@ -173,6 +173,12 @@ int detect_share_cap_flag(void) continue; } + if (cpumask_equal(topology_cluster_cpumask(cpu), + policy->related_cpus)) { + share_cap_level = share_cap_cluster; + continue; + } + if (cpumask_equal(cpu_cpu_mask(cpu), policy->related_cpus)) { share_cap_level = share_cap_die; @@ -226,7 +232,7 @@ int topology_detect_flags(void) check_core: if (asym_level >= asym_core) - goto check_die; + goto check_cluster; for_each_cpu(core, topology_core_cpumask(cpu)) { capacity = topology_get_cpu_scale(NULL, core); @@ -235,6 +241,20 @@ check_core: if (max_capacity != 0) asym_level = asym_core; + max_capacity = capacity; + } + } +check_cluster: + if (asym_level >= asym_cluster) + goto check_die; + + for_each_cpu(core, topology_cluster_cpumask(cpu)) { + capacity = topology_get_cpu_scale(NULL, core); + + if (capacity > max_capacity) { + if (max_capacity != 0) + asym_level = asym_cluster; + max_capacity = capacity; } } @@ -290,6 +310,19 @@ int topology_core_flags(void) return flags; } +int topology_cluster_flags(void) +{ + int flags = 0; + + if (asym_cpucap == asym_cluster) + flags |= SD_ASYM_CPUCAPACITY; + + if (share_cap == share_cap_cluster) + flags |= SD_SHARE_CAP_STATES; + + return flags; +} + int topology_cpu_flags(void) { int flags = 0; diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h index e7fe03600c02..b54a4257257c 100644 --- a/include/linux/arch_topology.h +++ b/include/linux/arch_topology.h @@ -12,6 +12,7 @@ void topology_normalize_cpu_scale(void); int topology_detect_flags(void); int topology_smt_flags(void); int topology_core_flags(void); +int topology_cluster_flags(void); int topology_cpu_flags(void); int topology_update_cpu_topology(void);