[COMMON] base: arch_topology: Add sched_domain flag detection for cluster
authorDaeyeong Lee <daeyeong.lee@samsung.com>
Tue, 13 Feb 2018 06:50:41 +0000 (15:50 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:32:53 +0000 (17:32 +0900)
Change-Id: Iade8db08000fd74c10030475fe2377babb5a59eb
Signed-off-by: Daeyeong Lee <daeyeong.lee@samsung.com>
drivers/base/arch_topology.c
include/linux/arch_topology.h

index cf92aa817dac3305ea5be55e175fc9f8dd4592bf..4a4c4c9dd3e879d55ef0fe7d75c1b2e8938ddb8d 100644 (file)
@@ -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;
index e7fe03600c0212f1dc4842119ffcb367d98d8fdb..b54a4257257c18e920f50a77f5887d4065040110 100644 (file)
@@ -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);