From: Youngtae Lee Date: Thu, 24 Aug 2017 06:43:54 +0000 (-0700) Subject: smp: Support random core control by bootargs X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4aab5595beebbe445c49dc6a4ffa4981f02efaab;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git smp: Support random core control by bootargs Add early_cpu_mask to remember user cpu want to remove. hotplug and cpufreq driver uses it when control number of online core. Change-Id: I20977beb5e338a977f73db9a943d0ac2d3c52d93 Signed-off-by: Youngtae Lee --- diff --git a/drivers/cpufreq/exynos-acme.c b/drivers/cpufreq/exynos-acme.c index 18d8adb99eaf..41d209af4abf 100644 --- a/drivers/cpufreq/exynos-acme.c +++ b/drivers/cpufreq/exynos-acme.c @@ -977,6 +977,7 @@ static ssize_t show_cpufreq_max_limit(struct kobject *kobj, } struct pm_qos_request cpu_online_max_qos_req; +extern struct cpumask early_cpu_mask; static void enable_domain_cpus(struct exynos_cpufreq_domain *domain) { struct cpumask mask; @@ -984,7 +985,7 @@ static void enable_domain_cpus(struct exynos_cpufreq_domain *domain) if (domain == first_domain()) return; - cpumask_or(&mask, cpu_online_mask, &domain->cpus); + cpumask_or(&mask, &early_cpu_mask, &domain->cpus); pm_qos_update_request(&cpu_online_max_qos_req, cpumask_weight(&mask)); } @@ -995,7 +996,7 @@ static void disable_domain_cpus(struct exynos_cpufreq_domain *domain) if (domain == first_domain()) return; - cpumask_andnot(&mask, cpu_online_mask, &domain->cpus); + cpumask_andnot(&mask, &early_cpu_mask, &domain->cpus); pm_qos_update_request(&cpu_online_max_qos_req, cpumask_weight(&mask)); } diff --git a/drivers/soc/samsung/exynos-cpu_hotplug.c b/drivers/soc/samsung/exynos-cpu_hotplug.c index c4a2deb9754a..44457f504202 100644 --- a/drivers/soc/samsung/exynos-cpu_hotplug.c +++ b/drivers/soc/samsung/exynos-cpu_hotplug.c @@ -136,6 +136,7 @@ bool exynos_cpu_hotplug_enabled(void) * than maximum online CPU. If mininum is greater than maximum, online CPU will * be maximum. */ +extern struct cpumask early_cpu_mask; static struct cpumask create_cpumask(void) { int online_cpu_min, online_cpu_max; @@ -147,11 +148,25 @@ static struct cpumask create_cpumask(void) cpumask_clear(&mask); - for (cpu = 0; cpu < online_cpu_min; cpu++) - cpumask_set_cpu(cpu, &mask); + for_each_possible_cpu (cpu) { + if (!cpumask_test_cpu(cpu, &early_cpu_mask)) + continue; + + if (cpumask_weight(&mask) < online_cpu_min) + cpumask_set_cpu(cpu, &mask); + else + break; + } - for (cpu = nr_cpu_ids - 1; cpu >= online_cpu_max; cpu--) - cpumask_clear_cpu(cpu, &mask); + for (cpu = nr_cpu_ids - 1; cpu >= 0; cpu--) { + if (!cpumask_test_cpu(cpu, &early_cpu_mask)) + continue; + + if (cpumask_weight(&mask) > online_cpu_max) + cpumask_clear_cpu(cpu, &mask); + else + break; + } return mask; } @@ -263,6 +278,7 @@ static int control_cpu_hotplug(bool enable) cpumask_setall(&mask); cpumask_andnot(&mask, &mask, cpu_online_mask); + cpumask_and(&mask, &mask, &early_cpu_mask); /* * If it success to enable all CPUs, clear cpu_hotplug.enabled flag. diff --git a/kernel/smp.c b/kernel/smp.c index c94dd85c8d41..0f2aff5dc1a6 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -499,6 +499,8 @@ EXPORT_SYMBOL(smp_call_function); /* Setup configured maximum number of CPUs to activate */ unsigned int setup_max_cpus = NR_CPUS; EXPORT_SYMBOL(setup_max_cpus); +struct cpumask early_cpu_mask; +EXPORT_SYMBOL(early_cpu_mask); /* @@ -570,12 +572,16 @@ void __init smp_init(void) pr_info("Bringing up secondary CPUs ...\n"); + cpumask_clear(&early_cpu_mask); + cpumask_set_cpu(0, &early_cpu_mask); /* FIXME: This should be done in userspace --RR */ for_each_present_cpu(cpu) { if (num_online_cpus() >= setup_max_cpus) break; - if (!cpu_online(cpu)) + if (!cpu_online(cpu)) { cpu_up(cpu); + cpumask_set_cpu(cpu, &early_cpu_mask); + } } num_nodes = num_online_nodes();