Re: [patch V2 35/67] arm/perf: Convert to hotplug state machine

From: Mark Rutland
Date: Fri Jul 15 2016 - 09:08:40 EST


Hi,

On Wed, Jul 13, 2016 at 05:16:36PM +0000, Anna-Maria Gleixner wrote:
> From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
>
> Straight forward conversion w/o bells and whistles.
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Cc: Mark Rutland <mark.rutland@xxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Will Deacon <will.deacon@xxxxxxx>
> Signed-off-by: Anna-Maria Gleixner <anna-maria@xxxxxxxxxxxxx>
> ---
> drivers/perf/arm_pmu.c | 36 +++++++++++++++---------------------
> include/linux/cpuhotplug.h | 1 +
> include/linux/perf/arm_pmu.h | 1 -
> 3 files changed, 16 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c
> index 140436a..ae9fc6c 100644
> --- a/drivers/perf/arm_pmu.c
> +++ b/drivers/perf/arm_pmu.c
> @@ -691,24 +691,15 @@ static int cpu_pmu_request_irq(struct arm_pmu *cpu_pmu, irq_handler_t handler)
> * UNKNOWN at reset, the PMU must be explicitly reset to avoid reading
> * junk values out of them.
> */
> -static int cpu_pmu_notify(struct notifier_block *b, unsigned long action,
> - void *hcpu)
> +static int arm_perf_starting_cpu(unsigned int cpu)
> {
> - int cpu = (unsigned long)hcpu;
> - struct arm_pmu *pmu = container_of(b, struct arm_pmu, hotplug_nb);
> -
> - if ((action & ~CPU_TASKS_FROZEN) != CPU_STARTING)
> - return NOTIFY_DONE;
> -
> - if (!cpumask_test_cpu(cpu, &pmu->supported_cpus))
> - return NOTIFY_DONE;
> -
> - if (pmu->reset)
> - pmu->reset(pmu);
> - else
> - return NOTIFY_DONE;
> -
> - return NOTIFY_OK;
> + if (!__oprofile_cpu_pmu)
> + return 0;
> + if (!cpumask_test_cpu(cpu, &__oprofile_cpu_pmu->supported_cpus))
> + return 0;
> + if (__oprofile_cpu_pmu->reset)
> + __oprofile_cpu_pmu->reset(__oprofile_cpu_pmu);
> + return 0;
> }

We may have multiple PMUs (e.g. two in big.LITTLE systems), and
__oprofile_cpu_pmu only contains one of these. So this conversion is not
correct.

We were relying on the notifier list implicitly containing a list of
those PMUs. It seems like we need an explicit list here.

We keep __oprofile_cpu_pmu around for legacy 32-bit users of OProfile
(on non-hetereogeneous systems), and that's all that the variable should
be used for.

Thanks,
Mark.