From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758007AbcGKMau (ORCPT ); Mon, 11 Jul 2016 08:30:50 -0400 Received: from www.linutronix.de ([62.245.132.108]:57102 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933893AbcGKMas (ORCPT ); Mon, 11 Jul 2016 08:30:48 -0400 Message-Id: <20160711122532.380628012@linutronix.de> User-Agent: quilt/0.63-1 Date: Mon, 11 Jul 2016 12:28:38 -0000 From: Anna-Maria Gleixner To: LKML Cc: Peter Zijlstra , Ingo Molnar , Sebastian Andrzej Siewior , "Suzuki K. Poulose" , Punit Agrawal , Anna-Maria Gleixner Subject: [patch 21/66] bus: arm-cci: convert to hotplug statemachine References: <20160711122450.923603742@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=0021-bus-arm-cci-convert-to-hotplug-statemachine.patch X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastian Andrzej Siewior Install the callbacks via the state machine and let the core invoke the callbacks on the already online CPUs. Signed-off-by: Sebastian Andrzej Siewior Cc: "Suzuki K. Poulose" Cc: Punit Agrawal Signed-off-by: Anna-Maria Gleixner --- drivers/bus/arm-cci.c | 54 +++++++++++++++------------------------------ include/linux/cpuhotplug.h | 1 2 files changed, 20 insertions(+), 35 deletions(-) --- a/drivers/bus/arm-cci.c +++ b/drivers/bus/arm-cci.c @@ -144,7 +144,6 @@ struct cci_pmu { int num_cntrs; atomic_t active_events; struct mutex reserve_mutex; - struct notifier_block cpu_nb; cpumask_t cpus; }; @@ -1503,31 +1502,22 @@ static int cci_pmu_init(struct cci_pmu * return perf_pmu_register(&cci_pmu->pmu, name, -1); } -static int cci_pmu_cpu_notifier(struct notifier_block *self, - unsigned long action, void *hcpu) +static struct cci_pmu *cpuhp_cci_pmu; +static int cci_pmu_offline_cpu(unsigned int cpu) { - struct cci_pmu *cci_pmu = container_of(self, - struct cci_pmu, cpu_nb); - unsigned int cpu = (long)hcpu; unsigned int target; - switch (action & ~CPU_TASKS_FROZEN) { - case CPU_DOWN_PREPARE: - if (!cpumask_test_and_clear_cpu(cpu, &cci_pmu->cpus)) - break; - target = cpumask_any_but(cpu_online_mask, cpu); - if (target >= nr_cpu_ids) // UP, last CPU - break; - /* - * TODO: migrate context once core races on event->ctx have - * been fixed. - */ - cpumask_set_cpu(target, &cci_pmu->cpus); - default: - break; - } - - return NOTIFY_OK; + if (!cpumask_test_and_clear_cpu(cpu, &cpuhp_cci_pmu->cpus)) + return 0; + target = cpumask_any_but(cpu_online_mask, cpu); + if (target >= nr_cpu_ids) // UP, last CPU + return 0; + /* + * TODO: migrate context once core races on event->ctx have + * been fixed. + */ + cpumask_set_cpu(target, &cpuhp_cci_pmu->cpus); + return 0; } static struct cci_pmu_model cci_pmu_models[] = { @@ -1765,23 +1755,17 @@ static int cci_pmu_probe(struct platform mutex_init(&cci_pmu->reserve_mutex); atomic_set(&cci_pmu->active_events, 0); cpumask_set_cpu(smp_processor_id(), &cci_pmu->cpus); - - cci_pmu->cpu_nb = (struct notifier_block) { - .notifier_call = cci_pmu_cpu_notifier, - /* - * to migrate uncore events, our notifier should be executed - * before perf core's notifier. - */ - .priority = CPU_PRI_PERF + 1, - }; - - ret = register_cpu_notifier(&cci_pmu->cpu_nb); + cpuhp_cci_pmu = cci_pmu; + ret = cpuhp_setup_state(CPUHP_AP_PERF_ARM_CCI_ONLINE, + "AP_PERF_ARM_CCI_ONLINE", NULL, + cci_pmu_offline_cpu); if (ret) return ret; ret = cci_pmu_init(cci_pmu, pdev); if (ret) { - unregister_cpu_notifier(&cci_pmu->cpu_nb); + cpuhp_remove_state_nocalls(CPUHP_AP_PERF_ARM_CCI_ONLINE); + cpuhp_cci_pmu = NULL; return ret; } --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -45,6 +45,7 @@ enum cpuhp_state { CPUHP_AP_PERF_X86_CSTATE_ONLINE, CPUHP_AP_PERF_S390_CF_ONLINE, CPUHP_AP_PERF_S390_SF_ONLINE, + CPUHP_AP_PERF_ARM_CCI_ONLINE, CPUHP_AP_NOTIFY_ONLINE, CPUHP_AP_ONLINE_DYN, CPUHP_AP_ONLINE_DYN_END = CPUHP_AP_ONLINE_DYN + 30,