Re: [PATCH v8 3/6] cpufreq: powernv: Remove cpu_to_chip_id() from hot-path

From: Benjamin Herrenschmidt
Date: Fri Mar 18 2016 - 18:38:27 EST


On Fri, 2016-03-18 at 15:04 +1100, Michael Neuling wrote:
>
> Âstatic int nr_chips;
> +static DEFINE_PER_CPU(unsigned int, chip_id);
> Â
> Â/*
> Â * Note: The set of pstates consists of contiguous integers, the
> @@ -317,9 +318,7 @@ static void powernv_cpufreq_throttle_check(void
> *data)
> Â
> ÂÂÂÂÂÂÂÂpmsr = get_pmspr(SPRN_PMSR);
> Â
> -ÂÂÂÂÂÂÂfor (i = 0; i < nr_chips; i++)
> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (chips[i].id == cpu_to_chip_id(cpu))
> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂbreak;
> +ÂÂÂÂÂÂÂi = this_cpu_read(chip_id);

Except it's not a chip_id, so your patch confused me for a good 2mn ...
Call it chip_idx maybe ? ie, index.

Cheers,
Ben.

> ÂÂÂÂÂÂÂÂ/* Check for Pmax Capping */
> ÂÂÂÂÂÂÂÂpmsr_pmax = (s8)PMSR_MAX(pmsr);
> @@ -560,6 +559,7 @@ static int init_chip_info(void)
> ÂÂÂÂÂÂÂÂfor_each_possible_cpu(cpu) {
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂunsigned int id = cpu_to_chip_id(cpu);
> Â
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂper_cpu(chip_id, cpu) = nr_chips;
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (prev_chip_id != id) {
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂprev_chip_id = id;
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂchip[nr_chips++] = id;
> _______________________________________________