Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1307224 > unrolled thread
| Started by | Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> |
|---|---|
| First post | 2016-01-12 11:30 +0100 |
| Last post | 2016-01-12 12:00 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH RESEND v4 1/4] cpufreq: powernv: Remove cpu_to_chip_id() from hot-path Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> - 2016-01-12 11:30 +0100
Re: [PATCH RESEND v4 1/4] cpufreq: powernv: Remove cpu_to_chip_id() from hot-path Shreyas B Prabhu <shreyas@linux.vnet.ibm.com> - 2016-01-12 12:00 +0100
| From | Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-01-12 11:30 +0100 |
| Subject | [PATCH RESEND v4 1/4] cpufreq: powernv: Remove cpu_to_chip_id() from hot-path |
| Message-ID | <qQ4n8-81P-17@gated-at.bofh.it> |
cpu_to_chip_id() does a DT walk through to find out the chip id by taking a
contended device tree lock. This adds an unnecessary overhead in a hot-path.
So instead of cpu_to_chip_id() use PIR of the cpu to find the chip id.
Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
---
drivers/cpufreq/powernv-cpufreq.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index cb50138..597a084 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -39,6 +39,7 @@
#define PMSR_PSAFE_ENABLE (1UL << 30)
#define PMSR_SPR_EM_DISABLE (1UL << 31)
#define PMSR_MAX(x) ((x >> 32) & 0xFF)
+#define pir_to_chip_id(pir) (((pir) >> 7) & 0x3f)
static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1];
static bool rebooting, throttled, occ_reset;
@@ -312,13 +313,14 @@ static inline unsigned int get_nominal_index(void)
static void powernv_cpufreq_throttle_check(void *data)
{
unsigned int cpu = smp_processor_id();
+ unsigned int chip_id = pir_to_chip_id(hard_smp_processor_id());
unsigned long pmsr;
int pmsr_pmax, i;
pmsr = get_pmspr(SPRN_PMSR);
for (i = 0; i < nr_chips; i++)
- if (chips[i].id == cpu_to_chip_id(cpu))
+ if (chips[i].id == chip_id)
break;
/* Check for Pmax Capping */
@@ -558,7 +560,8 @@ static int init_chip_info(void)
unsigned int prev_chip_id = UINT_MAX;
for_each_possible_cpu(cpu) {
- unsigned int id = cpu_to_chip_id(cpu);
+ unsigned int id =
+ pir_to_chip_id(get_hard_smp_processor_id(cpu));
if (prev_chip_id != id) {
prev_chip_id = id;
--
1.9.1
[toc] | [next] | [standalone]
| From | Shreyas B Prabhu <shreyas@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-01-12 12:00 +0100 |
| Subject | Re: [PATCH RESEND v4 1/4] cpufreq: powernv: Remove cpu_to_chip_id() from hot-path |
| Message-ID | <qQ4Qb-8ey-33@gated-at.bofh.it> |
| In reply to | #1307224 |
On 01/12/2016 03:54 PM, Shilpasri G Bhat wrote:
> cpu_to_chip_id() does a DT walk through to find out the chip id by taking a
> contended device tree lock. This adds an unnecessary overhead in a hot-path.
> So instead of cpu_to_chip_id() use PIR of the cpu to find the chip id.
>
> Reported-by: Anton Blanchard <anton@samba.org>
> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
> ---
> drivers/cpufreq/powernv-cpufreq.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
> index cb50138..597a084 100644
> --- a/drivers/cpufreq/powernv-cpufreq.c
> +++ b/drivers/cpufreq/powernv-cpufreq.c
> @@ -39,6 +39,7 @@
> #define PMSR_PSAFE_ENABLE (1UL << 30)
> #define PMSR_SPR_EM_DISABLE (1UL << 31)
> #define PMSR_MAX(x) ((x >> 32) & 0xFF)
> +#define pir_to_chip_id(pir) (((pir) >> 7) & 0x3f)
Since this is platform specific and true only for power8, this is not
the right place to put it. Either you can move this to arch/powerpc or
you can maintain a cpu to chip map within the driver.
>
> static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1];
> static bool rebooting, throttled, occ_reset;
> @@ -312,13 +313,14 @@ static inline unsigned int get_nominal_index(void)
> static void powernv_cpufreq_throttle_check(void *data)
> {
> unsigned int cpu = smp_processor_id();
> + unsigned int chip_id = pir_to_chip_id(hard_smp_processor_id());
> unsigned long pmsr;
> int pmsr_pmax, i;
>
> pmsr = get_pmspr(SPRN_PMSR);
>
> for (i = 0; i < nr_chips; i++)
> - if (chips[i].id == cpu_to_chip_id(cpu))
> + if (chips[i].id == chip_id)
> break;
>
> /* Check for Pmax Capping */
> @@ -558,7 +560,8 @@ static int init_chip_info(void)
> unsigned int prev_chip_id = UINT_MAX;
>
> for_each_possible_cpu(cpu) {
> - unsigned int id = cpu_to_chip_id(cpu);
> + unsigned int id =
> + pir_to_chip_id(get_hard_smp_processor_id(cpu));
>
> if (prev_chip_id != id) {
> prev_chip_id = id;
>
Thanks,
Shreyas
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web